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.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…