2

I am using JBoss 4.2.2.GA app server in a development environment. I have a WAR file, MyWar.war, and a JAR file ExternalJar.jar. These files are structured in the following way:

Application WAR file:

MyWar.war
|
|--- AppClass1.class
|
|--- AppClass2.class    

External jar file (provided by client):

ExternalJar.jar
|
|--- ExternalClass.class

ExternalClass needs to use AppClass1 and AppClass2 needs to use ExternalClass. When I deploy the WAR in JBoss and put JAR in JBoss' class path, I get a LinkageError on instantiating ExternalClass when I run the app. It seems as though the WAR sees the ExternalClass, but ExternalClass cannot access classes within the WAR.

If I manually put ExternalJar in the WAR file (WEB-INF/lib), it works fine. But we'd rather not modify archive files to maintain consistency with our production deployments.

Is there any configuration or setting in JBoss that allows for a shared library folder that will be included in the class path for the app?

Ryan Emerle
  • 15,461
  • 8
  • 52
  • 69
Ranu Gupta
  • 48
  • 1
  • 4
  • Is there a particular reason why you can't have the jar bundled in you war as part of your war building logic? – Romain Dec 03 '09 at 20:23
  • This jar will come from a client and we will not have it at the time of creation of war. We can give our war to the client and ask him to create his jar.Jboss should be able to pick it at runtime. Both war and jar should be able to see each other as per the above illustration. – Ranu Gupta Dec 03 '09 at 21:22

2 Answers2

1

You can disable WAR file class loader isolation by doing the following:

Open this file %JBOSS_HOME%\server\<serverName>\deploy\jboss-web.deployer\META-INF\jboss-service.xml

Set this attribute to true: <attribute name="UseJBossWebLoader">true</attribute>

You should be able to put your extension JAR file in the deploy/ directory with your WAR file.

This setting could cause issues if you're loading multiple WAR files with the same libraries, so YMMV.

Ryan Emerle
  • 15,461
  • 8
  • 52
  • 69
1

You can deploy a jar file just like you deploy the war. Since JBoss use a shared class loader, your jar will be able to access the classes loaded from the war.