I am running spring inside JBoss 4.2.3 and I am trying to update Hibernate to the latest version. I am using jboss class loader isolation to accomplish this (this is the only way to update hibernate in jboss). I also have my entity beans in a jar file at the ear level. My spring stuff is in a war that lives in the ear.
If I deploy just the ear hibernate is updated and all my entities are processed by hibernate and all looks great.
The problem happens when I introduce my war (which is using spring) into the ear. My spring classes cannot find my entity classes. I.E. I get a NoClassDefFound exception.
I am not sure, but I imagine this is because my entities were deployed in a specific class loader by JBoss and Spring is not going to that class loader to look for classes.
Has anyone ever run into this before? Please Help!
Billy Newman wrote: I also have my entity beans in a jar file at the ear level.
I guess you mean Hibernate entities? Or are those EJB2.x entity beans? Moving the entities jar file to .ear/lib folder will make it available to all components, including the war in the ear. However, depending on what kind of "entity beans" those are, you might have to do a few more changes. But first try the .ear/lib approach.
Please post the entire exception stacktrace. That might provide a clue. With the jars in the .ear/lib, the classes in those jars will be available to all components in the .ear. It probably is a case of some class being loaded from the .war classloader as well as the top level .ear classloader. JBoss AS-4.2.x (and later) by default enable a separate classloader for the .war component. You can however disable this in JBOSS_HOME/server/< servername>/deploy/jboss-web.deployer/META-INF/jboss-service.xml, set the UseJBossWebLoader to true:
That probably will solve (or rather workaround) the issue.
Since Jboss 4.2.3 is only EE 1,4 I think this is right but maybe not.
Doesn't matter much since it's only used for xml validation and metadata conversion.
I can post the stack trace in a while but I am sure that will not solve my problem. The class in question that spring cannot find is my class. com.test.MyEntity. This class lives in a jar file. That jar file lives in the .ear/lib directory. That jar is not placed in the war. So the class is not getting loaded twice. I assume that spring is not looking in the right place for my class.
I'm not really sure how spring creates and instantiates the beans. Not sure if it uses the right classloader.
Nothing informative in the logs, so that leaves us with only one other way to figure out what's going on. Edit the run.bat (or run.sh for *nix OS) to pass
as part of the JAVA_OPTS section. This will print out the jar names from which the classes are being loaded. Before starting the server, remember to redirect the output to some file, because the output is going to be too verbose. After the exception occurs, copy that file and "attach" (do not post the contents since it's going to be too much) that to this thread.