Skip to content

Archive

Archive for June, 2008

My intent in this blog is to help jumpstart someone who is new to wikis and has been tasked to learn or prepare to deploy a wiki.

1. What is a Wiki?
A wiki is a collaborative tool used to allow a group of people to jointly contribute to a document. Typically, how it works is that say a person wants documentation on a software program. The company will task several individuals to write the documentation. But instead of using Microsoft Word, the IS group puts up a wiki and each of the writers write their content to a wiki page. Now eventually, the jobs of the writers will cross. They may wish to contribute to the pages that the other writers have written because perhaps they know something the original author did not know. The wiki allows all writers to do just that. They can put in thier own two cents wherever they want to in the document.

Now suppose the manager of the document does not like the content of one of the contributors, and he or she feels that the latest changes to the document where really messed up. No problem. The manager of the document will have the ability to roll back the document to any previous version. It is very difficult to break a document in a wiki because the managers always have the ability to take out the trash.

2. Which Software Package is Best
There are some really good potential packages you can use. This is the list of wikis I have now used.

  • Sharepoint
  • JSPWiki
  • PHPWiki
  • MediaWiki
  • Confluence

Sharepoint – Now Sharepoint is not just a wiki. Sharepoint is the collaboration tool that Microsoft wants everyone to use. It is an application that is quite customizable with a lot of out of the box web widgets that can create a really good project managment and organization tool for you. A Wiki is just one of its available web parts.

Personally, I am quite fond of Sharepoint. The last opportunity I had to project manage, I used Sharepoint as the team collaboration tool. All of the writeups for future reference where done with the Sharepoint wiki. For example, one person was tasked to make this integrate image support into the forums. After he built the functionality, he had to write up his specifications on a wiki page. Now, 6 months later, I still have his write up ready for reference. If things have changed, anyone with access can modify the contents.

The Sharepoint Wiki functionality is good for small groups. However, it is not near as robust as some of the other available wikis. What you get is a list of pages and the ability for anybody on the team to edit the page. There is no further organization of your wiki pages. If Sharepoint is your existing collaborative tool, I do recommend using it. However, if you are looking for collaborative wiki for wide scale use with a lot more really useful functionality, I would say that this is not the right tool.

JSPWiki – At first, I was rather impressed with this free open source package built on the Java Platform. I initially put it up for the Powergui team as a beta to see if it would serve their purposes for a wiki. We ran into some pitfalls with it.

  • It did not run well on all platforms. It did best in a Linux / Apache / Tomcat environment. I could not get it to work on Resin. Lastly, it seemed to cause instability when I combined it on the same tomcat application server with Jive Integrated running on a Windows 2003 server sitting behind IIS.
  • It was functionality deficient. You could roll back pages, but it did not have a good diff utility. Also, you could not set up email notifications for page changes. The users also complained about the inability to escape certain characters.
  • On the positive side, the support team including Janne Jalkanin were very helpful even though they were working for free. My hats off to them.

Unfortuneatly, we had to scrap using JSPWiki and turn to a different platform.

PHPWiki – After scraping the JSPWiki project, I downloaded PHPWiki and installed it on a Red Hat Linux ES 5.0 server. This did not go well at all. PHPWiki required some PHP_DBA functions in order to work. Those PHP_DBA functions are not in the out of the box RPM installation of PHP on Red Hat. I searched and searched for the proper RPM packages but could not find it. In order to get those functions up, I would have needed to uninstall PHP via the RPMs and reinstall php by compiling the source code with all of the required flags to make it work. That was just too much work for my feeble mind so I said “Forget It”!!! I have time on my hands, but not that much time.

MediaWiki – After failing now on two Wikis for the Powergui community, I dug up one called Media Wiki. Media Wiki is the wiki software used by Wikipedia. After my frustrations with PHPWiki, this one was a breath of fresh air. Installation was probably the simplest I have ever seen for any out of the box web application installation. This wiki is functionality rich having all the items that JSPWiki did not have. Administration is user freindly. It has good internationization support as well. The Powergui Team thus far has been rather pleased with this choice. I give this application two thumbs up for a wide scale collaborative tool – especially in terms of being an external wiki for documenting a software package. Also, this software package is a free open source application. Nice job!!!

http://mediawiki.org

Confluence – There are certain groups in Quest Software that make use of this Wiki made by Atlassian and I have recently been assigned to take over the administration of this application. It is a very good platform built on Java and is probably the most functionality rich of all Wikis. It includes watch support, tree structure organization, rich permission functionality, and even the ability to integrate with your active directory. It has the best user interface making it simple for anyone to use. It is very expandable and organizable and works well for large organizations with many teams. It also supports a rich scripting which for those who have taken the time to learn gives then far greater power at organizing content. This platform from my perspective is the darling of all wikis. The only weakness is that it does cost. Last time I checked it was about $7,500 for an unlimited use external collaboration license. If that is not a factor to you, you will not go wrong with this one. http://www.atlassian.com/

In the end, I give two thumbs up for both Media Wiki and Confluence.

Hibernate works very well in Swing Applications. This page is intended to help you get started in implementing Hibernate with Swing. This particular example is set up in a database environment using Oracle 10g. However, this setup will work perfectly in other database enviroments by simply modifying the database connection information.

1. Download the latest Version
Hibernate can be found http://www.hibernate.org/6.html. After you download it, make certain you not only place hibernate.jar in you classpath, you may want to include all of the jar files that are found in the lib directory of the extracted files. While many may not be used in your application, some of them are likely to result in runtime errors if not included in the classpath.

2. Create the hibernate.cfg.xml file.
This is the primary configuration file that should be placed at the root of your source code.

<?xml version=“1.0″ encoding=“UTF-8″?>
<!DOCTYPE hibernate-configuration PUBLIC
“-//Hibernate/Hibernate Configuration DTD//EN”
“http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd”>

<hibernate-configuration>
<session-factory>
<property name=“hibernate.connection.driver_class”>oracle.jdbc.driver.OracleDriver </property>
<property name=“hibernate.connection.url”> jdbc:oracle:thin:@servername.domainname.com:1521:dbname</property>
<property name=“hibernate.connection.username”>username</property>
<property name=“hibernate.connection.password”>password</property>
<property name=“hibernate.connection.pool_size”>10</property>
<property name=“show_sql”>true</property>
<property name=“dialect”>org.hibernate.dialect.Oracle10gDialect</property>
<property name=“connection.autocommit”>true</property>
<!– Mapping files –>
<mapping resource=“Entry.hbm.xml”/>
</session-factory>
</hibernate-configuration>

You may need to modify the dialect to match your current version of Oracle. Other available dialects for the Oracle database include OracleDialect (deprecated), Oracle8iDialect, and Oracle9iDialect. It is also important that you set the autocommit property to true if you are not using exlicit transactions in your application. Otherwise, you may get frustrated as you try to look at the database and see that your changes have not been commited to the database.

3. Create a class to match a given database table.
This example called Entry.java matches a database table called Entry.

package com.utilities.data;

public class Entry
{
private int entryID;
private int userID;
private String title = “”;
private long creationDate;

public Entry(){ }

public void setEntryID(int entryID) { this.entryID=entryID; }
public void setUserID(int userID) { this.userID=userID; }
public void setTitle(String title) { this.title=title; }
public void setCreationDate(long creationDate) { this.creationDate = creationDate; }

public int getEntryID() { return this.entryID; }
public int getUserID() { return this.userID; }
public String getTitle() { return this.title; }
public long getCreationDate() { return this.creationDate; }
}

The corresponding table creation and sequence creation commands are given here as well.

CREATE SEQUENCE Entry_seq MINVALUE 1 START WITH 1 INCREMENT BY 1;

CREATE TABLE ENTRY
(
EntryID Number Primary Key,
UserID Number Not Null,
Title Varchar2(255),
CreationDate Number
);

With this example you can will are shown using int, String, and long datatypes in Hibernate. In this particular application, the architects choose to use the Date.getTime() functionality to store date values.

4. Create the Mapping Resource File.

This particular file is called Entry.hbm.xml. It is stored in the root directory right next to the hibernate.cfg.xml file and is used to bridge the java object values to the database. In many applications, it is prefered to place this file right next to Entry.java. However, it appears that in Swing applications, Hibernate has difficulty finding it unless it is in the root directory.

<?xml version=“1.0″ encoding=“UTF-8″?>
<!DOCTYPE hibernate-mapping PUBLIC
“-//Hibernate/Hibernate Mapping DTD 3.0//EN”
“http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd”>

<hibernate-mapping package=“com.utilities.data”>
<class name=“Entry” table=“Entry”>
<id name=“entryID” column=“EntryID” type=“int”>
<generator class=“sequence”>
<param name=“sequence”>Entry_seq</param>
</generator>
</id>
<property name=“userID” type=“int” />
<property name=“title” type=“string” length=“255″ />
<property name=“creationDate” type=“long” />
</class>
</hibernate-mapping>

5. Populate the class called Entry as you would any other java class.

6. Save the data to the database
From within your DAO class make the following calls. Please pay attention to the following line:

configuration = new Configuration().configure(”/hibernate.cfg.xml”);

In some applications, it is enough to simply call configuration = new Configuration()

Unfortuneately, my swing application required the additional configure method to be called in order to find the configuration file.

package com.utilities.data;

import org.hibernate.cfg.Configuration;
import org.hibernate.SessionFactory;
import org.hibernate.Session;

public class ImportToolDAO
{

private Configuration configuration;
private SessionFactory factory;
private static ImportToolDAO importToolDAO;

private ImportToolDAO()
{
configuration
= new Configuration().configure(“/hibernate.cfg.xml”);
factory
= configuration.buildSessionFactory();
}

public static ImportToolDAO getInstance()
{
if(importToolDAO==null)
{
importToolDAO
= new ImportToolDAO();
}
return importToolDAO;
}

public void saveEntry(Entry entry)
{
Session session = factory.openSession();
session
.save(entry);
session
.flush();
session
.close();
}
}

7. Run the Application. If you followed everything step by step, it just might work for you the first time. Go check your database and be prepared for a smile.

Ran across this error while building the Swing application with Hibernate. Originally, the Entry.hbm.xml file was placed deep in the directory structure next to the java class called Entry.java. Several ways of naming the xml file where tried. The only solution that worked in this case was to move the file outside of the classpath structure and place it in the root directory next to the hibernate.cfg.xml file.

Ran across this error while setting up an application using Hibernate. After googling it some, I came across a thread (in Spanish) referencing the need to include the cglib-2.1.3.jar. That may have fixed the problem; nevertheless, the problem had to do with not including all of the hibernate jar files found in the hibernate-3-X-X.ga.zip file. There are more jar files needed than just hibernate.jar. Make certain you include all of jar files that are in the lib folder of the downloaded uncompressed hibernate file. If all of the files are included, you should not run into this error.

Was trying to get setup with Hibernate and ran into the following error and stack trace:

INFO: using JDK 1.4 java.sql.Timestamp handling
Dec 26, 2007 11:40:40 AM org.hibernate.connection.UserSuppliedConnectionProvider configure
WARNING: No connection properties specified - the user must supply JDBC connections
Exception in thread "AWT-EventQueue-0" org.hibernate.HibernateException: Hibernate Dialect 
must be explicitly set        
    at org.hibernate.dialect.DialectFactory.determineDialect(DialectFactory.java:57)        
    at org.hibernate.dialect.DialectFactory.buildDialect(DialectFactory.java:39)        
    at org.hibernate.cfg.SettingsFactory.determineDialect(SettingsFactory.java:426)        
    at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:128)        
    at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2009)        
    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1292)

This error occured as Hibernate was unable to locate the hibernate.cfg.xml file. To fix this, I had to change the way of calling the Hibernate Configuration class. For some reason, in my web based applications, the first example of calling the class worked perfectly. It did not work in my Swing application so I changed to the the second version below:

Version 1:
Configuration configuration = new org.hibernate.cfg.Configuration();

Version 2:
org.hibernate.cfg.Configuration configuration = new org.hibernate.cfg.Configuration().configure(”/hibernate.cfg.xml”);

Some instability on one of the servers I manage has brought up the need to setup automated monitoring that will send email alerts in the event that a website is down. In looking at possible solutions, I was considering several alternatives. Two of them that stood out the strongest are as follows:

1. Use Powershell on a Windows Server.
2. Use a scripting language on one of our externally hosted Linux servers.

Using Powershell did look like a viable alternative. The only problem is that I have never used Powershell before and I decided that the learning curve to implement a solution was not one that I am ready to go through. Maybe later. Nevertheless, Dmitry Sotnikov has a good blog where he describes how he did it for the http://powergui.org website using Powershell.

Monitor Website Availability

What I choose to do instead was use Perl and the Crontab to set up monitoring.

I tested the setup on three different Linux Servers–all three are Red Hat Linux Enterprise Servers version 4.0 or 5.0. Below is the script that I created using Perl:


$mailprogpath='/usr/sbin/sendmail';

use lib '/var/www/cgi-bin/libwww-perl-5.69/lib'; 
use LWP::Simple;

$location = "http://mywebsite.com";

if(get($location))
{
    print "success";
}else
{
    # need to send email
    open (MAIL, "|$mailprogpath -t") or die ("Can't access $mailprogpath\n");
    $recipient_address = "brian.nettles\@domainname.com";
    print MAIL "To: $recipient_address\n";
    print MAIL "From: donotreply\@domainname.com\n";
    print MAIL "Subject:  $location Down\n\n";
    print MAIL "$location request timed out.  Website may be down.\n";
    close (MAIL);
}

So on the Linux server, I went into the directory where I store my crontab’d files and created a file called monitorwebsites.pland populated the file with the above script. I then tested the script by calling the following:

perl monitorwebsites.pl

It works well.

On one of the servers, I had an issue with use LWP::Simple;. The perl script would not run on that particular server as the LWP module was not loaded. I found some good instructions on how to load that module at the following url:

http://forums.dixiesys.com/index.php?showtopic=2588

The next thing I needed was to schedule the Perl script in the Crontab. If you don’t know what the Crontab is, that is a scheduling device built into Linux/Unix systems to run automated tasks. I found some great instructions on how to setup the Crontab on Linux machines at the following URL:

http://kevin.vanzonneveld.net/techblog/article/schedule_tasks_on_linux_using_crontab/

The first command here opens up the crontab so that you can add an entry. The second line below is the entry that calls on the script every fifteen minutes.

sudo crontab -e
*/15 * * * * perl /directoryforscripts/monitorwebsites.pl

This was pretty simple. Took me about 4 hours total to research, write, and implement this.

The first question is whether you should use Tomcat or Resin as your application server. Here are some quick pros and cons with each.

  • Pro for Tomcat – Third party software is more likely to run on Tomcat than Resin
  • Pro for Tomcat – Sessions don’t get lost on server restarts
  • Pro for Tomcat – Tomcat is built on open source standards and has more documentation
  • Pro for Tomcat – Tomcat is free
  • Pro for Resin – Resin is a lot easier to integrate with IIS than Tomcat

I have now set up Tomcat to work behind IIS more than once. I know the challenges that go along with it. If you miss one small item on the list that needs to be configured, your installation will fail. And the logs don’t always point you in the right direction. It truely is a challenge to make Tomcat and IIS work together, but once it does, you will be glad you did it.

1. Install Tomcat as a Windows Service
The simplest place to start is with tomcat. Make certain you download the version using the Windows installer and go ahead and install it as a service. Make certain you remove all spaces that are in your installation. After Tomcat is installed, point your browser to it at http://localhost:8080/. You should then get your Tomcat home page. Now lets get IIS to work with it prior to adding your own application to tomcat.

2. Add the Configuration and Connector Files
Create a directory in the Tomcat Home directory calle connectors. In the connectors directory, add a subdirectory for the name of your application such as “root”. Now in this connectors/root directory, add two files.

1. isapi_redirect-1.2.26.dll (or whatever the latest version is)
2. isapi_redirect-1.2.26.properties

You will need to download this isapi_redirect-1.2.xx.dll file from apache.org. Currently the url is http://tomcat.apache.org/download-connectors.cgi.

A sample of the isapi_redirect-1.2.26.properties files contains the following:

# Configuration file for the Jakarta ISAPI Redirector

# The path to the ISAPI Redirector Extension, relative to the website
# This must be in a virtual directory with execute privileges
extension_uri=/jakarta/isapi_redirect-1.2.26.dll

# Full path to the log file for the ISAPI Redirector
log_file=C:\Tomcat-5.5.25\logs\isapi_redirect.log

# Log level (debug, info, warn, error or trace)
log_level=debug

# Full path to the workers.properties file
worker_file=C:\Tomcat-5.5.25\conf\workers.properties

# Full path to the uriworkermap.properties file
worker_mount_file=C:\Tomcat-5.5.25\conf\uriworkermap.properties

Now we have two more configuration files to add. These two you should place in the conf directory:

1. workers.properties
2. uriworkermap.properties

A sample of the workers.properties is given below:

# Define 1 real worker using ajp13
worker.list=worker1

# Set properties for worker1 (ajp13)
worker.worker1.type=ajp13
worker.worker1.host=localhost
worker.worker1.port=8009

A sample of the uriworkermap.properties is given below:

/*=worker1
!/images/*=worker1
!*.jpg=worker1
!*.xmls=worker1
!*.gif=worker1
!*.bmp=worker1

For more information on these two files, search the following two urls:
http://tomcat.apache.org/connectors-doc/reference/workers.html
http://tomcat.apache.org/connectors-doc/reference/uriworkermap.html

3. Make the Registry Entries
Follow the example on this image by going into clicking start -> run -> regedit and the entries just like on this image. Click on the image to get a larger view of it.

IIS-Tomcat-Registries

4. Configure IIS
Before you do anything with IIS, make certain you can see your web pages without interference from tomcat. Start by turning Tomcat and create a website and point it to the ROOT directory in the webapps directory of Tomcat. See if you can see the images when referencing them direct by url. ex. http://localhost/tomcat.gif. If you see the image, then you know IIS is working.

a. Add a new application pool that is copied from the default application pool and name is something you recognize – mysitenamePool.

b. Add a webservice extension and point it to the connectors.

web-service-extensions

c. Add a jakarta virtual directory

virtualdirectory

d. Make certain that every reference in this website to the application pool all point to the same newly created application pool.

pool

e. Setup the isapi filter by calling it jakarta and point it to the isapi_redirect-1.2.26.dll file. After doing so, restart IIS and make certain you have a green arrow in place for the filter.

jakarta

Now try the url http://localhost without the reference to port 8080. If you see the default Tomcat application, you are in business.

5. Add your own application
Turn off Tomcat and rename the ROOT directory ROOT_ORIGINAL. Now recreate the ROOT folder and add your application into the ROOT directory. Now you can restart Tomcat, Restart IIS and check to see if your application shows up at http://localhost

If it doesn’t work, carefully check all of your settings.

6. Heap Size
Sometimes, your newly established application ends up running out of memory and therefore you need to adjust the heap size. This is done in the registries. Take a look at the image here. You may need to add a couple of entries to the registries as displayed here.

heap

Ran into this issue where the section on the main page called Recently Updated was not updating.

The solution was to go into Administration -> Content Indexing and Rebuild the Index.

The official instructions for Confluence is that if that does not work, then remove the <confluence-home>/index directory, restart the application server and then rebuild the index.

http://confluence.atlassian.com/display/CONF27/Rebuild+index+from+scratch