Getting Tomcat to Behave in JBoss 3.2.2

I previously reported an issue with redeployment of my web application (accessing EJB) on JBoss 3.2.2. I was getting ClassCastExceptions trying PortableRemoteObject.narrow() my LocalHome interfaces. It turned out to be a JBoss/Tomcat default configuration issue.

If you want Tomcat to behave as you'd expect any normal web container to behave, switch the UseJBossWebLoader to false in jbossweb's jboss-service.xml. This lets Tomcat use its own classloader, instead of JBoss' unified loader. JBoss' unified loader causes trouble with the client jar packaged with your web app.

When I started J2EE, I found it incredibly cumbersome that a web app didn't automatically find the interfaces to an EJB. It seemed that they should, since they're in the same JVM. So I got into the habit of copying the classes over to the web app and packaging them up in the war as well.

Well, this unified loader actually lets me access them transparently without loading them. It also makes the locally packaged interfaces not reload properly. I could have dropped the client jar, but that would be non-standard to other application servers.

The standard behavior of having separate class loaders, I've come to realize, is useful. It's clean and well-defined for cases where you have different versions of the same application deployed on the same server. The JBoss loader would have to try to figure out the correct classes, and I doubt it could do it, since it had trouble for my simple case of choosing packaged interfaces or the classes from the other side of the server.

This problem doesn't seem to be well-exposed. Maybe I'm doing things differently from others, but if anyone else is doing things the way I do, hopefully this helps.


Filed Under: