Blogging Roller
Dave Johnson on open web technologies, social software and Java
Dave Johnson on open web technologies, social software and Java
In my quest to make Roller work on Java EE 6, the next server that I tackled was JBoss 6. In this blog I'll describe how I approached the problem what I learned along the way.
Roller uses JPA for database storage and specifically the Apache OpenJPA implementation. I knew that JBoss uses the Hibernate JPA implementation and I suspected that there would be JPA portability problems, so I decided to run Roller's JUnit tests against Hibernate JPA. There were many test failures and fortunately, the failures were easy to fix.
Where OpenJPA is lenient, Hibernate JPA is strict about declaring transients fields as transient. So, wherever Hibernate complained, I added the appropriate transient declaration and soon all tests were passing. There were a lot of changes, but they were all trivially easy. Since I first "ported" Roller to ElipseLink JPA, its possible that some of the changes I made for EclipseLink helped with the port to Hibernate JPA.
Those of you who are familiar with Roller's history might remember that this is the second time I worked to make Roller work with Hibernate. Early versions of Roller ran on Hibernate until Roller 4, when we ripped it out because Apache policy does not allow LGPL. With Java EE 6, Roller can run on Hibernate and we don't have to ship the Hibernate jars to do so.
Since JBoss 6 is a Java EE 6 server, just like Glassfish, I figured I could use the same WAR that I created for Glassfish. That didn't really work out, as you will see below. When I attempted to deploy the Roller WAR to JBoss I ran into two problems:
When I tried to deploy the Roller WAR to JBoss, I ran into class-cast exceptions that indicated that the version the the Xerces XML parser included with Roller conflicts with the one that is included in JBoss. I encountered a similar problem for the JavAssist jars, which are also part of Roller. This was quite surprising to me. Apparently, JBoss uses Xerces and JavAssist internally and for some reason the JBoss internals bleed through and interfere with applications; seems like a bug to me. So, we have to have a special Roller WAR for JBoss without the Xerces and JavaAssist jars in the Roller WAR.
The next problem that I encountered was the datasource name. Roller uses the JNDI naming API to lookup its JDBC datasource. In all of the other app servers, we tell people to setup a datasource with the JNDI name 'jdbc/rollerdb' but that name did not work for JBoss. For JBoss, I could only get names of names of the format "java:/name" to work. Unfortunately, with JPA the datasource name must be embedded in the persistence.xml file which is embedded in a JAR file which is embedded in the Roller WAR file. It's in there deep, so we have to produce a special Roller WAR for JBoss with a JBoss-friendly datasource name.
*Please* correct me if I'm wrong. I would love to be wrong about either of these two problems.
Due to those two problems, I modified the Roller build process to create a special Roller WAR for JBoss without the OpenJPA, Xerces and JavAssist JARs and with the JBoss friendly JNDI name java:/RollerDS inside all included persistence.xml files.
Once I worked around those two problems, installing Roller on JBoss was easy. I did the whole thing via the JBoss web console, which was not familiar to me but was pretty easy to understand and use. I documented the whole process in the Roller 5 Install Guide (2MB PDF), with screenshots.
Next up: Roller 5 on WebSphere 8 (beta)
See also: Roller 5 and Java EE 6 and Roller 5 on Glassfish 3.
(can you push the post to our JBossAS forum, and just link it here)
As I quickly hacked a simple .war, which uses bundled Javassist, and I have no issues:
Inside my servlet code:
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { response.setContentType( "text/html" ); try { ClassPool pool = new ClassPool(); pool.appendClassPath(new LoaderClassPath(getClass().getClassLoader())); CtClass ctCass = pool.getCtClass(getClass().getName()); System.out.println("ctCass = " + ctCass); System.out.println("Javassist used in this .war=" + ctCass.getClass().getProtectionDomain().getCodeSource().getLocation()); } catch (NotFoundException e) { throw new IOException(e); }with the output:Posted by Ales Justin on January 20, 2011 at 06:25 PM EST #
Posted by Jaikiran Pai on January 20, 2011 at 10:01 PM EST #
Posted by Jaikiran Pai on January 20, 2011 at 10:02 PM EST #
Posted by Dave Johnson on January 21, 2011 at 02:42 PM EST #
Posted by kk on January 23, 2011 at 05:20 AM EST #
kk, thanks for the tip but it does not fix this problem.
When I change the name of the datasource in JBoss to "jdbc/rollerdb" and set the Use Java Context to true, I get this error message:
"javax.naming.NameNotFoundException: jdbc not bound Deployment "jdbc/rollerdb" is in error due to the following reason(s): ** NOT FOUND Depends on 'jdbc/rollerdb'
Posted by Dave Johnson on January 23, 2011 at 04:11 PM EST #
Posted by kk on January 30, 2011 at 12:57 PM EST #
Posted by Dave Johnson on January 30, 2011 at 08:15 PM EST #
Posted by Susanne on February 07, 2011 at 05:25 AM EST #
Hi Suzanne,
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, DavePosted by Dave Johnson on February 08, 2011 at 05:59 AM EST #
Hi Dave,
I am trying to deploy Roller 5 on JBoss 6 and I am getting the classcast exceptions you are talking about. Unfortunately there seems to be no specific roller war-file for JBoss.
Do you know where I can find that specific JBoss roller war-file.
The datasource connection is working fine.
Thanks, Peter
Posted by Peter on August 11, 2011 at 04:28 PM EDT #
Peter,
We didn't get enough feedback about Roller 5.0 on JBoss 6, so we did not include JBoss 6 in the official release.
Despite that, you can get the Roller 5 for JBoss files here:
http://people.apache.org/~snoopdave/apache-roller-5.0-experimental/
Thanks,
Dave
Posted by Dave Johnson on August 21, 2011 at 05:45 PM EDT #
What happened to the install guide you wrote? I can't seem to get roller running on JBoss 6.0.0 or 6.1.0.
Posted by Brian Lavender on August 26, 2012 at 10:43 PM EDT #