How to prevent JBoss inter web application classpath?

橙三吉。 提交于 2020-01-04 11:58:51

问题


I have two web application deployed in JBoss within same server. I have observed classpath is shared between this two web applications.

So how do I prevent classpath saring between applications. I mean whatever classes and jar files available in one application should not be visible in another application in same server in jboss.


回答1:


For most versions of jBoss AS you need to update your jboss-web.xml file:

<jboss-web>
   <class-loading> 
      <loader-repository>com.example:archive=unique-archive-name</loader-repository> 
   </class-loading>
</jboss-web>

See the following reference for more info:

  • jBoss class loading configuration
  • jBoss class loading background & use cases



回答2:


The JBoss wiki states:

In jboss-3.2.3, the jbossweb-tomcat41.sar is configured to use a unified class loader as the web application class loader. This is controlled by the UseJBossWebLoader attribute in the jbossweb-tomcat41.sar/META-INF/jboss-service.xml descriptor. The use of a unified class loader means that the classes available in the war inside of the WEB-INF/classes and WEB-INF/lib are incorporated into the default shared class loader repository. This may not be what you want as its contrary to the default servlet 2.3 class loading model and can result in sharing of classes/resources between web applications. You can disable this by setting this attribute to false.

It goes on to say that this behaviour was changed in 4.0.2, so it is a reasonable assumption that you still need to do this in 4.0.1.



来源:https://stackoverflow.com/questions/4843257/how-to-prevent-jboss-inter-web-application-classpath

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