Jboss 4.2 Class Loading

你。 提交于 2019-12-21 19:45:33

问题


I have a jar in server/default/lib which contains Foo.class,Bar.class

and the same class is there in my application/WEB-INF/classes which is deployed in server/default/deploy.

and Example.class is using the Foo.class instance and Bar.class instance

Now the situation is that Example.class shoud use the Foo.class in my application and Bar.class in default/lib jar file.

i.e. my application should use the classes in the application clases folder if not found in classes folder then it should use the class in default/lib jar files.

To do i have defined jboss-web.xml file

<jboss-web>
   <class-loading java2ClassLoadingCompliance="true">
   <loader-repository>
         com.example:eagle=web-360.jar
         <loader-repository-config>java2ParentDelegation=true</loader-repository-config>
      </loader-repository> 
   </class-loading>
</jboss-web>

web-360.jar is the jar which will be default/lib. com.eagle:eagle has no significance..


回答1:


Have a look at JBossClassLoadingUseCases. Your situation seems to be Use Case 4 (i.e. the class will be loaded from default/lib in preference to WEB-INF/classes.

What you seem to want is Use Case 3 (i.e. WEB-INF/classes preferred to default/lib), in which case you should omit the java2ParentDelegation=true config option from jboss-web.xml (or set it to false, which is the default).



来源:https://stackoverflow.com/questions/6401929/jboss-4-2-class-loading

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