In JBoss can I configure a “shared library” location?

折月煮酒 提交于 2019-12-24 02:07:08

问题


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?


回答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.




回答2:


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.



来源:https://stackoverflow.com/questions/1842635/in-jboss-can-i-configure-a-shared-library-location

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!