views:

254

answers:

1

Hi All,

I have deployed 2 apps as app1.war and app2.war on jboss. These two apps use a common java package, say, myPackage. Earlier my wars looked like this

========================================================================

app[12].war/
-----web.xml
-----app specific classes (.class files like)
-----appClass1.class
-----appClass2.class etc..
-----WEB-INF/
-----myPackage/ (this was just a folder under the war, not a jar package)
----------classes belonging to the common package like
----------common_class1.class
----------common_class2.class
----------.
----------.

=======================================================================

But this created problems since both set of common classes would have the exact same names etc.. in both war files. So I decided to compile the common package as a jar file and dropped it in WEB-INF/lib in each of the war files and now my war file looks like

============================================================================

app[12].war/
-----web.xml
-----app specific classes (.class files like)
-----appClass1.class
-----appClass2.class etc..
-----WEB-INF/
----------lib/
----------myPackage.jar (this is now a jar package)
----------myPackage/
---------------classes belonging to the common package like
---------------common_class1.class
---------------common_class2.class
---------------.
---------------.

============================================================================

But now my app specific classes which need to access class files withing myPackage.jar throw java.lang.ClassNotFoundException Exception.

I Googled for 3-4 frustrating hours but nothing addressed this particular problem. I'm probably doing something outrageously wrong. Can anybody smart enough please help me out?

PS: I'm deploying my wars in JBOSS 4.2.3

Thanks a ton. ~Manoj

A: 

JBoss has its own version-dependent peculiarities when it comes to classloading. These links might help you:

But if both your WARs require the same version of the common package, you could put the JAR for that package into the relevant server config's lib folder (e.g. server/default/lib) instead of having it in the WAR files.

Andrew Swan