JBoss Scoped Class Loading

前端 未结 4 1987
不思量自难忘°
不思量自难忘° 2020-12-17 06:08

I want to use the latest hibernate version inside the ear without upgrading the jars on the server. I am following the instructions given here - http://jaitechwriteups.blogs

相关标签:
4条回答
  • 2020-12-17 06:35

    Jerrish,

    You seem to be packaging a jar containing javax.management.* classes within your application packaging. Remove that jar from the application packaging (since it already ships in JBoss AS).

    0 讨论(0)
  • 2020-12-17 06:38

    I had a scan through the instructions on that page, and it mostly follows the same steps that I have. The critical difference seems to be in the contents of his jboss-app.xml file:

    <jboss-app>
     <loader-repository>
       org.myapp:loader=SomeClassloader
       <loader-repository-config>
          java2ParentDelegation=false
       </loader-repository-config>
     </loader-repository> 
    </jboss-app>
    

    My system does not disable parent delegation, it only has the loader name:

    <jboss-app>
     <loader-repository>org.myapp:loader=MyAppName</loader-repository> 
    </jboss-app>
    

    You may (or may not) also need to set the Isolated=true attribute in JBoss's deploy/ear-deployer.xml file:

    And that works nicely. By disabling parent delegation, you cripple your application's ability to interact with the container in any way, which is a bit extreme. If you leave out that option, though, a bit of yak shaving is required

    By leaving out the java2ParentDelegation=false option, you get a situation where any classes in your EAR which have the same name as classes in JBoss will be loaded preferentially from the EAR (which is good). However, any classes not found in the EAR will fall through to JBoss's libs. In the case of jboss-local-jdbc.rar, this is good. However, it can have peculiar side effects.

    For example, when Hibernate creates a session factory, it looks for the Hibernate Search and Hibernate Validator libraries, and tries to start them up also. If these aren't present in your EAR, it will find them in JBoss's libs. The problem is that you often then get a linker error, because the versions of Search and Validator shipped with JBoss may not be compatible with the Hibernate packaged in your EAR.

    The solution to this is to either configure the Hibernate session factory to disable registration of Search and Validator listeners using config properties (hibernate.validator.autoregister_listeners=false and hibernate.search.autoregister_listeners=false), or to package compatible versions of Search and Validator in your EAR also.

    0 讨论(0)
  • 2020-12-17 06:38

    I'm using the jboss-classloading.xml file which is dedicated to classloading. The syntax is more natural than the jboss-app.xml syntax to me. See http://phytodata.wordpress.com/2010/10/21/demystifying-the-jboss5-jboss-classloading-xml-file/ for a comprehensive explanation.

    0 讨论(0)
  • 2020-12-17 06:45

    Why don't you just remove the hibernate jars on the jboss application server?

    0 讨论(0)
提交回复
热议问题