Eclipse Wiki Weblog

All | General | Java | Eclipse | Groovy | Grails | GWT | Google | MathEclipse | Bliki
20080429 Tuesday April 29, 2008

Developing JAMWiki with Eclipse

A tutorial to get started with the JAMWiki software in an Eclipse development environment. JAMWiki offers many of the features of the MediaWiki (aka Wikipedia) wikis.

Contents
  1. Prerequisite
  2. Setup
  3. Maven package build
  4. Configure the JAMWiki Eclipse project
  5. Run JAMWiki

Prerequisite

Setup

Install Subclipse, the Maven Eclipse and the Tomcat Launcher plugins.

  1. In Eclipse go to Help → Software Updates → Find and Install.
  2. Choose "Search for new features to install"
  3. The required plugin URLs for subclipse and M2Eclipse are:
  1. For the Tomcat Launcher see the above URL for full install instructions.

Once installed, select the "SVN Repository" Eclipse perspective and add

as a repository URL.
You should now be able to click on this repository and open the SVN tree:

http://www.groovy-news.org/e/resources/axelclk/m2eclipselaumch003.png

Right click on the trunk node, select the "Find/Check out as..." menu option. In the following dialog box you can Check out the source code:

http://www.groovy-news.org/e/resources/axelclk/m2eclipselaumch002.png

Maven package build

Now change back to the Java perspective.

In the package explorer view do a right mouse click on the pom.xml file and select the menu Run As → Maven build....
In the appearing dialog box select the Select... button in the Main tab and choose the package goal:

http://www.groovy-news.org/e/resources/axelclk/m2eclipselaumch001.png

I needed to run this twice and increase the default java heap for eclipse to -Xmx1024m, because in the first run I get an OutOfMemoryError exception:

[INFO] Compiling 2 source files to C:\IDE\workspace\jamwiki_svn\javadiff\target\classes
org.apache.maven.plugin.CompilationFailureException: Compilation failure
Failure executing javac, but could not parse the error:

The system is out of resources.
Consult the following stack trace for details.
java.lang.OutOfMemoryError: Java heap space
	at java.util.zip.ZipEntry.initFields(Native Method)
	at java.util.zip.ZipEntry.<init>(ZipEntry.java:96)
	at java.util.zip.ZipFile$2.nextElement(ZipFile.java:329)
	at java.util.zip.ZipFile$2.nextElement(ZipFile.java:299)
	at com.sun.tools.javac.util.DefaultFileManager$ZipArchive.<init>(DefaultFileManager.java:405)
	at com.sun.tools.javac.util.DefaultFileManager$SymbolArchive.<init>(DefaultFileManager.java:460)
	at com.sun.tools.javac.util.DefaultFileManager.openArchive(DefaultFileManager.java:544)
...

...

Configure the JAMWiki Eclipse project

The Maven package build has now generated some additional files and directories.

Copy these generated jflex files:

from

 C:\IDE\workspace\jamwiki_svn\jamwiki-core\target\generated-sources\jflex\org\jamwiki\parser\jflex

to

 C:\IDE\workspace\jamwiki_svn\jamwiki-core\src\main\java\org\jamwiki\parser\jflex

Delete these files from the

 C:\IDE\workspace\jamwiki_svn\jamwiki-war\target\jamwiki-war-0.6.6-SNAPSHOT\WEB-INF\lib 

directory:

and delete this file

 C:\IDE\workspace\jamwiki_svn\jamwiki-war\target\jamwiki-war-0.6.6-SNAPSHOT.war

Select the Eclipse Window → Preferences... menu. In the dialog select the node Java → Build Path → Classpath Variables and:

  1. define an Eclipse "Classpath Variable" called JAMWIKI_WEBAPP which points to
    C:/IDE/workspace/jamwiki_svn/jamwiki-war/target/jamwiki-war-0.6.6-SNAPSHOT
  2. define an Eclipse "Classpath Variable" called TOMCAT_HOME which points to your Tomcat home directory. In my case it points to:
    C:/server/tomcat-6.0.13

After that, select the Tomcat node and define your Tomcat settings. Be sure that the directory C:\server\tomcat-6.0.13\conf\Catalina\localhost exists:

http://www.groovy-news.org/e/resources/axelclk/m2eclipselaumch005.png

Edit the .project file, so that the project is a Java, Maven2 and Tomcat plugin related project:

<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
	<name>jamwiki_svn</name>
	<comment></comment>
	<projects>
	</projects>
	<buildSpec>
		<buildCommand>
			<name>org.maven.ide.eclipse.maven2Builder</name>
			<arguments>
			</arguments>
		</buildCommand>
		<buildCommand>
			<name>org.eclipse.jdt.core.javabuilder</name>
			<arguments>
			</arguments>
		</buildCommand>
	</buildSpec>
	<natures>
		<nature>org.eclipse.jdt.core.javanature</nature>
		<nature>org.maven.ide.eclipse.maven2Nature</nature>
		<nature>com.sysdeo.eclipse.tomcat.tomcatnature</nature>
	</natures>
</projectDescription>

Create a new source folder named mysrc.

Change the .classpath file in the following way:

<?xml version="1.0" encoding="UTF-8"?>
<classpath>
	<classpathentry kind="src" path="src"/>
	<classpathentry kind="src" path="my-src"/>
	<classpathentry kind="src" path="addon-src"/>
	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
	<classpathentry combineaccessrules="false" kind="src" path="/info.bliki.wiki.svn"/>
	<classpathentry kind="lib" path="/info.bliki.wiki.svn/lib/core-renderer.jar"/>
	<classpathentry kind="lib" path="/info.bliki.wiki.svn/lib/itext-paulo-155.jar"/>
	<classpathentry kind="lib" path="lib/junit.jar"/>
	<classpathentry kind="lib" path="/info.bliki.wiki.svn/lib/commons-codec-1.3.jar"/>
	<classpathentry kind="lib" path="/info.bliki.wiki.svn/lib/commons-logging.jar"/>
	<classpathentry kind="lib" path="/info.bliki.wiki.svn/lib/commons-validator-1.3.1.jar"/>
	<classpathentry kind="lib" path="/info.bliki.wiki.svn/lib/jakarta-oro.jar"/>
	<classpathentry kind="lib" path="/info.bliki.wiki.svn/lib/commons-fileupload-1.2.jar"/>
	<classpathentry kind="var" path="TOMCAT_HOME/lib/servlet-api.jar"/>
	<classpathentry kind="lib" path="/info.bliki.wiki.svn/lib/commons-httpclient-3.1.jar"/>
	<classpathentry kind="lib" path="lib/mysql-connector-java-3.1.10-bin.jar"/>
	<classpathentry kind="lib" path="/info.bliki.wiki.svn/lib/commons-lang-2.4.jar"/>
	<classpathentry kind="output" path="bin"/>
</classpath>

Do a right mouse click on your project and select menu Properties. In the dialog box select the Tomcat node. In the dialog box define the Application-URI as jam066 and the sub-directory for the webapps root as /jamwiki-war/target/jamwiki-war-0.6.6-SNAPSHOT: http://www.groovy-news.org/e/resources/axelclk/m2eclipselaumch004.png

Run JAMWiki

In the Java perspective's toolbar, where are three buttons to

http://www.groovy-news.org/e/resources/axelclk/m2eclipselaumch006.png

Press the Start Tomcat button and you should see the Tomcat logging in the Eclipse Console view. (If the Console view isn't open, you can open it in the menu Window → Show View → Console)

Now open a browser and run JAMWiki with the following URL:

JAMWiki should automatically switch to the installation setup page:

Create a directory for your JAMWiki cache, search, database and upload files:

  c:\temp\jamwiki

and configure it in the setup page. I've used the following path settings in the setup process:

...
file-dir-full-path=C\:\\IDE\\workspace\\jamwiki_svn\\jamwiki-war\\target\\jamwiki-war-0.6.6-SNAPSHOT\\upload
file-dir-relative-path=/jam066/upload/
...
homeDir=C\:\\temp\\jamwiki

Stop Tomcat now and do a refresh (right mouse click in the Package Explorer view and select menu Refresh F5) of your JAMWiki Eclipse project.

The JAMWiki installation created a new properties file:

 /jamwiki_svn/jamwiki-war/target/jamwiki-war-0.6.6-SNAPSHOT/WEB-INF/classes/jamwiki.properties

Copy this jamwiki.properties file directly under your mysrc folder.

In the jamwiki.properties file you can now directly edit the configuration and restart Tomcat afterwards. For example I configured my Bliki engine as the default Wikipedia syntax parser:

parser=org.jamwiki.parser.bliki.BlikiParser
Posted by axelclk ( Apr 29 2008, 08:52:02 PM CEST ) Permalink Comments [5]

Calendar

Links

Search

del.icio.us Tag Cloud

RSS Feeds

Navigation

Referers