Deploying Knappsack Projects

This page contains details relating to the compatability of applications built from Knappsack archetypes with different application servers. These issues may also serve as a start off point for people trying to resolve other issues on Java EE servers.

JBoss AS 6 Milestone 4

Works out of the box, although currently the servlet based project don’t work. If slf4j is enabled in the dependencies then it will break because JBoss comes with slf4j already.
There is a problem when you deploy two applications with the same persistence unit name, but you can get around that by changing the name of one of them. There is also a problem if you install two stateless beans with the same name in two separate applications. JBoss complains about the jndi binder already being registered.

JBoss AS 6 Milestone 3

Works out of the box. M3 can be quirky though, if you get errors about null persistence units, clean the project and re-deploy, or clean and restart the server.
Also had problems with multiple projects on the same server with the same persistence unit name, in which case I just renamed one of the persistence units.

Glassfish v 3.0.1

Appears to be working out of the box, the Weld version is 1.0.1.SP3. Adding the Hibernate JPA provider through the update tool is still recommended as EclipseLink appears to have some problems (in the sandbox, the list of students in a course is not being fetched). Make sure you get hibernate version 3.5.0-0.3 as 0.2 has a couple of problems.
If you get errors about persistence problems make sure you a) renamed the datasource used in persistence.xml and you started the javaDB manually if it is not done automatically. To start it, go to your glassfish bin directory and execute asadmin start-database.

Project Tweaks

Change the datasource name in persistence.xml in the project. Also you can use the 3.0 schema in web.xml since Glassfish supports 3.0.

If you are using the standard configuration out of the box, you may get errors related to slf4j missing. In which case, edit the pom.xml file in your project and uncomment the org.slf4j dependency. Rebuild and re-deploy the project completely and you shouldn’t have problems. Installing the hibernate JPA provider may resolve this since it uses slf4j in which case it will complain about having multiple slf4j bindings on the classpath so remove the one in your project.

The only other sticky trick is getting the database kickstarted up. For whatever reason, EclipseLink seems flaky so you have to ‘wiggle’ the persistence.xml file a bit, copy the persistence provider into the main part of the persistence document and save it just to get it going (don’t forget to start the javaDB). Alternatively, you could just switch to the Hibernate provider and MySQL (or HSQL).

Glassfish v 3.0.0 build 70+

Server Tweaks

Requires updating Weld to 1.0.1.Final which can be done by downloading the Weld bundles for Glassfish, and unzipping the contents into the {glassfish dir}\modules\ directory. This will be necessary until the official Glassfish release uses Weld 1.0.1.Final or greater. May need to include slf4j-jdk14.jar since Glassfish doesn’t come with slf4j installed.

Recommend installing the Hibernate as a JPA provider as it appears to more reliable than the EclipseLink JPA provider. I also think installing Hibernate fixes the slf4j issue.

Upgrading to version 3.0.1 or greater is recommended.

Project Changes

Change the datasource name in persistence.xml in the project. Optionally, you can use the 3.0 schema in web.xml

Notes

Tested with the Glassfish plugins for Eclipse. If using Eclipse, make sure you manually start the JavaDB database ({glassfish_dir}\bin\asadmin start-database)

Sometimes have issues with getting Eclipselink to drop and create the tables. One option is to install the Hibernate JPA provider which you can do from the Glassfish update tool. You’ll also need to uncomment the Hibernate JPA provider in persistence.xml

Leave a Reply

Your email address will not be published. Required fields are marked *

*