Tuesday 23 June 2009

Daisy CMS - connecting a JMS listener to the repository

The following information may be useful for anyone wanting to write an application that connects to the Daisy repository using a JMS connection. The port is tcp://[your_name_or_ip]:61616 and the username and password can be found in $DAISY_HOME/daisydata/conf/myconfig.xml

Look for this:

And the username and password are listed as attributes in the credentials element

Daisy CMS - customising the footer of the editor pages.

Brief note:

$DAISY_HOME/daisywiki/webapp/daisy/resources/xml/documenteditor.xml contains all the formatting logic for the footer of the editor page(s).

Search for: (about 2/3 down the file)

Monday 22 June 2009

Daisy CMS - allowing attributes in the SimpleDocument Editor

We had noticed that when using the SimpleDocument Editor in Daisy, although attributes can be added freehand (using the html view), there was a process that seemed to be running after save that removed many attributes.

I have since discovered that editing $DAISY_HOME/dasiywiki/webapp/daisy/resources/conf/htmlcleaner.xml will allow for modifications to be made to these "cleaning" rules. For example: we wanted to be able to write out 'a' tags with class attributes within the editor. This change was made possible by editing htmlcleaner and making the following adjustments (for example):

JSF - ensuring your [xhtml] pages load with a text/html contentType

We were having a problem with Safari and Chrome rendering our JSF pages; all the content was available, but for some reason they refused to load any of the external links to stylesheets, javascript etc. They also refused to render any markup; in fact, all they would show was all the page "content" in the default text.

Further investigation (using fiddler) made it apparent that the pages were being served with the "application/xhtml+xml" when our page templates all had an html 4.01 strict doctype. This caused the WebKit browsers to ignore any links to external assets while Firefox and IE seemed to render the page as expected.

We discovered that creating templates that looked like (where the contentType is specified inside the f:view tag as early as possible) seemed to solve the issue:

Sunday 21 June 2009

Eclipse Galileo (3.5): Creating and running a JSF Project

These notes follow on from my previous posting regarding getting Eclipse Galileo and glassfish v3 configured on OSX

In this post, I'm going to quickly outline the necessary steps for getting a very simple JSF project running within Galileo.

First, you'll need to download Mojarra and unpack it somewhere.

Go to the Java EE perspective and create a new project to get the "New Project" wizard to appear. Expand out "Web" and select "Dynamic Web Project". Give the project a name.

The "Target Runtime" should be GlassFish v3 Prelude, The Dynamic web module version should be 2.5 and select JavaServer Faces v1.2 Project as your configuration option.

Choose "Next" for the Source folders option and "Next" for the Web Module settings.

For the JSF Implementation Library settings, click on the "Manage Libraries" link (it's the icon on the right, just below the "Type" dropdown list), Select "New", create a name (e.g. "Mojarra") and check the System Library checkbox. Select OK and then highlight the library you just created and select "Add JARs". Navigate to the folder where you unpacked Mojarra and go to its lib folder. Select both jsf-impl.jar and jsf-api.jar and then select "Open".

Both JARs should be visible under the library you created. Select "OK" and now check the library you just created and select "Finish". You should now be ready to start coding.

To create a simple JSF example project:

1. Right-click on your Java Resources:src folder and select New > Other. Expand out "General" and select "File" and select "Next". If it asks you to select a "parent folder", just select the src folder for the project you just created. The file should be called messages.properties. In that file, add a line: greeting=JSF is working and save the file.

2. in WebContent/WEB-INF/web.xml, find the <servlet-mapping> and make sure it looks like this:

3. Right-click on WebContent and select "New" and "JSP". Name it "index.jsp". You should have a basic html template page.

In the body of the template, paste in:

4. Create a folder called "faces" under "WebContent"

5. Create a New JSP file inside the "faces" folder. Call it greeting.jsp (note the file extension is jsp, *not* jsf)

Below the doctype of greeting.jsp, paste in:

And in between the body tags, paste in:

Right-click on the project and select Run As > Run on Server. Ensure you're running it on GlassFish Prelude v3 (if you are working from my previous post). You should now be able to go to localhost:8080/%the_name_of_your_project% and you should see the message from the config file: "JSF is working".

The project can be found here: http://jsf-examples.googlecode.com/files/jsf-greeting.zip if anyone wants to check out the folder structure

Saturday 20 June 2009

Using Eclipse Galileo to develop JSF applications on Glassfish (OS X)

These are rough notes for getting Eclipse Galileo (3.5) and GlassFish 3 Prelude to work together for deploying and developing JSF applications. I've encountered a few issues still with both of these things but am pleased to say that once you're up and running, you can be very productive, so it's worth taking the steps to get the environment set up.

If you're happy using a build of Ganymede (3.4), I'd recommend installing the Glassfish bundle instead: http://download.java.net/glassfish/eclipse/

I'm working on the premise that the user has the JDK1.6 already installed in OSX - to confirm this, you can check for the presence of this folder: /System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home

I'm also writing these notes before Galileo is released (should be released 4 days from time of writing)

Here are the steps required:

1. Go to http://www.eclipse.org/downloads/ and select the "Development Builds" tab. Download the Eclipse IDE for Java EE Developers (188 MB) and I'd recommend getting the one for Mac OS X (Cocoa).

2. Download Glassfish Prelude from here: http://download.java.net/glassfish/v3-preview/release/glassfish-v3-web-preview-unix.sh. You'll probably need to run it from the command line (chmod a+x glassfish-v3-web-preview-unix.sh followed by ./glassfish-v3-web-preview-unix.sh)

3. Once the glassfish installer has completed, start Eclipse and confirm that you have a Java 1.6 JDK registered. To do this, go to Eclipse > Preferences > Java > Installed JREs. If you can't see anything that says something like "JVM 1.6.0" select "Add..." and choose MacOS X VM then Next.

The JRE Home should be /System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home

And the choice of name is up to you.

4. Next you will need to install the GlassFish adapter. Go to Help > Install new Software. Select "Add" and add this location: https://ajax.dev.java.net/eclipse. Once that's done, you should see an option for "Glassfish Java EE5 and Java EE6 support". Select that and Next or Finish. Eclipse will require a restart.

5. To add the GlassFish server, first ensure you're in the Java EE perspective and locate the tab marked "Servers", right click, select New > Server. Open out the GlassFish options and select GlassFish v3 Prelude.

For the JRE, make sure you're choosing the 1.6.0 JVM and your application directory should be something like: /Users/%yourusername%/glassfishv3/glassfish. I had to select Install Server too.

6. Once that's completed, you can highlight the listed server and hit the green start button. A brief visit to localhost:8080 should confirm this.

I've posted up a simple jsf example project here: http://jsf-examples.googlecode.com/files/simple-jsf-example.zip if you'd like to test your GlassFish installation, import it into eclipse and right-click and Run as > Run on Server and select your recently created instance of GlassFish v3 Prelude

Wednesday 17 June 2009

SVN Web view - looking at older revisions

Quick comment here:

Adding something like this:


Into your browser in between the repository name and location will allow you to view older revisions of project code (e.g. this should show revision 123)


Tuesday 16 June 2009

Notes on setting up mod_proxy on apache 2.2 for proxying a servlet container (like glassfish)

Just wanted to make these notes before I forget - the aim here was to create a vhost (or potentially several vhosts) which map to different projects hosted on (some kind) of servlet container like glassfish:

1. Install or upgrade to the latest version of Apache http server (Apache 2.2)
2. edit your hosts file (C:\WINDOWS\system32\drivers\etc) to add the name for whatever you need to proxy (as per usual vhost settings):

3. edit httpd.conf (For Windows, it should be in C:\Program Files\Apache Software Foundation\Apache2.2\conf\httpd.conf):

ensure both

Are uncommented in order for proxying to work correctly.

Also ensure the httpd-vhosts.conf include is being "Included" by uncommenting:

4. edit C:\Program Files\Apache Software Foundation\Apache2.2\conf\extra\httpd-vhosts.conf

Delete (or uncomment) any of the default install stuff in there... If you're using a different folder, you'll have to configure the permissions (OSX):

# This block sets the permissions for apache (n.b. these differ from the OS file permissions)

# setting localhost's "starting point"; in this case, it's my workspace folder, so I can see all my projects

#setting the rewrite / proxy rules for your hostname

Restart apache and mod_proxy should be working.

Tuesday 9 June 2009

Addressing stability issues when running Eclipse 3.5 on JDK1.6 in OSX

Since running Eclipse Galileo (3.5), I've had problems with Eclipse frequently quitting out - this was happening so regularly it was almost unusable.

There was an issue with DataTreeNode in the error report; if this sounds familiar to you, try adding this to eclipse.ini:

The workaround has been outlined in this bug posting:


Friday 5 June 2009

Forcing glassfish 2.1 to start-up with JDK1.6 (OSX)

We were having a problem where we were trying to deploy a webapp on glassfish 2.1; the app itself was compiled with Java 1.6 and glassfish was being launched with Java 1.5. It should be noted that in this case we were trying to launch glassfish from within IntelliJ IDEA.

If you're having the same problem, go into your {glassfish home}/config/asenv.conf and check to see whether this value is pointing to an earlier version of the JDK. It should be:

Hope this helps someone

Blog Archive