« Latest Links | Main | Latest Links »

Roller 5 and Glassfish 3

Duke and GlassFishIn my quest to make Roller work on Java EE 6, the first server that I decided to tackle was Glassfish 3. In this blog I'll describe how I approached the problem and what I learned along the way.

Tested with EclipseLink JPA

Roller uses JPA for persistence and specifically the Apache OpenJPA implementation. I knew that GlassFish uses the EclipseLink JPA implementation and I suspected that there would be JPA portability problems, so I decided to run Roller's JUnit tests against EclipseLink JPA. I wanted to find and fix those problems before even touching GlassFish. The tests ran and there were many JPA related failures and errors, most due to differences in the way that EclipseLink handles bi-directional relationships and the use of unmanaged objects.

EclipseLink logoWhere OpenJPA is lenient about bi-directional relationships, EclipseLink requires you to manage both ends. For example, with OpenJPA you can get away with adding a bookmark to a folder with folder.addBookmark(bookmark), but with EclipseLink you'd also have to add bookmark.setFolder(folder).

Where OpenJPA is lenient about use of unmanaged objects, EclipseLink will complain bitterly whenever it finds one in a persisted collection or relationship. This was more of a problem in the tests than in the actual Roller code, which usually deals only with managed objects (i.e. those persisted to / loaded from the database and managed by the JPA implementation).

I was able to fix those problems easily and move onto the next step.

Created a Roller WAR without OpenJPA

I also knew that Roller included some jars needed for Tomcat but that are not needed, or worse, problematic, on true Java EE servers. For example, we include the Apache OpenJPA implementation because Tomcat doesn't have one of its own. I modified the Roller build process to create two builds. One build is for Tomcat and includes OpenJPA and the other build is for Java EE and does not.

Deployed, tested and updated the docs

Next, I figured out how to deploy Roller to GlassFish 3 via the GlassFish web console, which was pleasant to use and familiar to me. I didn't run into any problems along the way and later I documented the whole process in the Roller 5 Install Guide (2MB PDF), with screenshots.

Next up: Roller 5 on JBoss 6


Thanks for the series Dave. Roller 5 looks really good! With GlassFish 3.1 you'll be able to simplify the install process even more with app-scoped resources (jdbc, javamail defined in glassfish-resources.xml, bundled in the WAR, and created on deploy).

Posted by Alexis MP on January 10, 2011 at 09:15 PM EST #

Actually, it wouldn't have been necessary to make Roller work with Eclipselink just for deploying it to Glassfish 3.x. I've used all of OpenJPA, Hibernate and Eclipselink on Glassfish, and OpenJPA turned out to be much closer to the JPA 2.0 spec than the other two. (So much for the JPA certification process...) You can simply include OpenJPA (or Hibernate) and all required libraries in your WAR and explicitly specifiy the persistence provider in your persistence.xml to override the Eclipselink default.

Posted by Harald Wellmann on January 22, 2011 at 07:40 PM EST #

Thanks for the comments!

Harald, I tried including OpenJPA in the Roller WAR at one point and ran into problems that I decided not to solve. I wanted to to get Roller working on "native" JPA implementations. Now that I know you've make it work before, I will give this another try.

Have you also tried OpenJPA, Hibernate and Eclipselink on JBoss and other apps servers?

Cheers, Dave

Posted by Dave Johnson on January 22, 2011 at 07:51 PM EST #

Thank you for this blog Dave. Since I wanted to replace my PHP driven blog by one driven by Java, I like to install roller. And with your description, it seemed to be very simple. But, I can't deploy roller to GlassFish. During deploy it tries to connect to the db, resulting in an error (can't find table roller_properties) even though I tried "install=manual". Deploy failed. Next I unpacked the war to extract the appropriate dbscript and created the tables. Deploy still fails with "Exception while loading the app : java.lang.Exception: java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: java.lang.RuntimeException: java.lang.ClassCastException: org.apache.roller.weblogger.pojos.RuntimeConfigProperty cannot be cast to org.apache.roller.weblogger.pojos.RuntimeConfigProperty ". This is something like "cannot cast X to X" :( Any idea? Best, Michael

Posted by Michael Müller on February 06, 2011 at 07:05 PM EST #

Hi Michael,

I don't do support here on the blog. If you want help then please take your Roller questions to either the Roller User or Developer Mailing Lists here:

Roller Mailing Lists

That's the best way to reach the widest audience of people who might be able to answer your question and benefit others who might have the same questions or problems in the future.

Thanks, Dave

Posted by Dave Johnson on February 08, 2011 at 12:04 PM EST #

Post a Comment:
  • HTML Syntax: NOT allowed

« Latest Links | Main | Latest Links »


This is just one entry in the weblog Blogging Roller. You may want to visit the main page of the weblog

Related entries

Below are the most recent entries in the category Roller, some may be related to this entry.