JBoss作用域类加载 [英] JBoss Scoped Class Loading

查看:129
本文介绍了JBoss作用域类加载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在耳内使用最新的hibernate版本,而无需升级服务器上的jar。我遵循这里给出的指示 - http: //jaitechwriteups.blogspot.com/2008/08/how-to-upgrade-hibernate-in-jboss.html



但现在的问题是该应用程序没有将jboss-local-jdbc.rar放在deploy文件夹中。

  2009-07-21 09: 01:50,347 INFO [org.jboss.system.ServiceConfigurator]配置服务的问题jboss.jca:service = DataSourceBinding,name = MockDS 
org.jboss.deployment.DeploymentException:异常设置属性ConnectionManager = jboss.jca:service = LocalTxCM,name = mbean jboss.jca上的MockDS:service = DataSourceBinding,name = MockDS; - 嵌套throwable:(javax.management.InvalidAttributeValueException:设置属性具有从null加载的类属性javax.management.ObjectName,不可分配给属性类class javax.management.ObjectName从org.jboss.mx.loading.UnifiedClassLoader3@1babddb加载{url = file:/ C:/servers/jboss-4.2.2.GA/server/default/tmp/deploy/tmp22267hibernate_upgrade_test.ear,addedOrder = 43})
at org.jboss.system.ServiceConfigurator.setAttribute (ServiceConfigurator.java:707)
在org.jboss.system.ServiceConfigurator.configure(ServiceConfigurator.java:382)
在org.jboss.system.ServiceConfigurator.internalInstall(ServiceConfigurator.java:462)
at org.jboss.system.ServiceConfigurator.install(ServiceConfigurator.java:171)
at org.jboss.system.ServiceController.install(ServiceController.java:226)
at sun.reflect。 GeneratedMethodAccessor23.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccesso rImpl.java:25)

任何想法?

解决方案

我对该页面上的说明进行了扫描,并且大部分都遵循了我所拥有的相同步骤。关键区别似乎出现在他的 jboss-app.xml 文件的内容中:

 <的JBoss应用内> 
< loader-repository>
org.myapp:loader = SomeClassloader
< loader-repository-config>
java2ParentDelegation = false
< / loader-repository-config>
< / loader-repository>
< / jboss-app>

我的系统不会禁用父委托,它只有加载器名称:

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

您可能(也可能不需要)在JBoss的<$ c中设置Isolated = true属性$ c> deploy / ear-deployer.xml file:



这很好。通过禁用父代授权,您会以任何方式瘫痪应用程序与容器交互的能力,这有点极端。如果你忽略了这个选项,那么需要一些牦牛剃须



通过省略 java2ParentDelegation = false 选项,您会发现EAR中与类具有相同名称的任何类在JBoss中将优先从EAR中加载(这很好)。但是,在EAR中找不到的任何类将落入JBoss的库中。在 jboss-local-jdbc.rar 的情况下,这很好。然而,它可能有特殊的副作用。例如,当Hibernate创建会话工厂时,它会查找Hibernate Search和Hibernate Validator库,并尝试启动它们也是。如果这些不在您的EAR中,它会在JBoss的库中找到它们。问题是你经常会得到一个链接器错误,因为JBoss附带的Search和Validator版本可能与你的EAR打包的Hibernate不兼容。



解决方案是将Hibernate会话工厂配置为禁用使用配置属性( hibernate.validator.autoregister_listeners)注册Search and Validator侦听器= false hibernate.search.autoregister_listeners = false ),或者在您的EAR中打包兼容版本的Search and Validator。


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.blogspot.com/2008/08/how-to-upgrade-hibernate-in-jboss.html.

However the problem now is the application is not taking the jboss-local-jdbc.rar sitting in the deploy folder.

2009-07-21 09:01:50,347 INFO  [org.jboss.system.ServiceConfigurator] Problem configuring service jboss.jca:service=DataSourceBinding,name=MockDS
org.jboss.deployment.DeploymentException: Exception setting attribute ConnectionManager = jboss.jca:service=LocalTxCM,name=MockDS on mbean jboss.jca:service=DataSourceBinding,name=MockDS; - nested throwable: (javax.management.InvalidAttributeValueException: Set attribute  has class class javax.management.ObjectName loaded from null that is not assignable to attribute class class javax.management.ObjectName loaded from org.jboss.mx.loading.UnifiedClassLoader3@1babddb{ url=file:/C:/servers/jboss-4.2.2.GA/server/default/tmp/deploy/tmp22267hibernate_upgrade_test.ear ,addedOrder=43})
    at org.jboss.system.ServiceConfigurator.setAttribute(ServiceConfigurator.java:707)
    at org.jboss.system.ServiceConfigurator.configure(ServiceConfigurator.java:382)
    at org.jboss.system.ServiceConfigurator.internalInstall(ServiceConfigurator.java:462)
    at org.jboss.system.ServiceConfigurator.install(ServiceConfigurator.java:171)
    at org.jboss.system.ServiceController.install(ServiceController.java:226)
    at sun.reflect.GeneratedMethodAccessor23.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

Any idea ?

解决方案

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.

这篇关于JBoss作用域类加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆