Glassfish 3.1.1 CDI Classloader委托false

时间:2011-07-28 02:56:31

标签: hibernate glassfish cdi myfaces

我的主要问题是我想使用myfaces jsf实现,因此,我必须在glassfish-web.xml中使用delegate = false。这最终会首先从我的应用程序加载类,然后查看服务器库。

当我使用hibernate时,我遇到了javassist的问题,即与osgi-weld捆绑的版本3.14.0-GA和我在pom.xml中定义的3.14.0-GA是不同的。我还尝试从我的pom.xml中删除条目(排除所有传递依赖关系到javassist),但它不起作用。例外有点奇怪。

SCHWERWIEGEND: Exception while loading the app : org.jboss.weldx.transaction.org$jboss$weld$bean-WEB-INF$lib$seam-international-3$0$0$Final-Built-in-UserTransaction_$$_WeldProxy cannot be cast to javassist.util.proxy.ProxyObject
java.lang.ClassCastException: org.jboss.weldx.transaction.org$jboss$weld$bean-WEB-INF$lib$seam-international-3$0$0$Final-Built-in-UserTransaction_$$_WeldProxy cannot be cast to javassist.util.proxy.ProxyObject
    at org.jboss.weld.bean.proxy.ProxyFactory.create(ProxyFactory.java:222)
    at org.jboss.weld.bean.builtin.ee.AbstractEEBean.<init>(AbstractEEBean.java:46)
    at org.jboss.weld.bean.builtin.ee.UserTransactionBean.<init>(UserTransactionBean.java:60)
    at org.jboss.weld.bootstrap.BeanDeployment.deployBeans(BeanDeployment.java:199)
    at org.jboss.weld.bootstrap.WeldBootstrap.deployBeans(WeldBootstrap.java:370)
    at org.glassfish.weld.WeldDeployer.event(WeldDeployer.java:170)
    at org.glassfish.kernel.event.EventsImpl.send(EventsImpl.java:128)
    at org.glassfish.internal.data.ApplicationInfo.load(ApplicationInfo.java:270)
    at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:461)
    at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:240)
    at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:382)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$1.execute(CommandRunnerImpl.java:355)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:370)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1064)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1200(CommandRunnerImpl.java:96)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1244)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1232)
    at com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:459)
    at com.sun.enterprise.v3.admin.AdminAdapter.service(AdminAdapter.java:209)
    at com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:168)
    at com.sun.enterprise.v3.server.HK2Dispatcher.dispath(HK2Dispatcher.java:117)
    at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:238)
    at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:828)
    at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:725)
    at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1019)
    at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225)
    at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
    at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
    at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
    at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
    at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
    at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
    at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
    at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
    at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
    at java.lang.Thread.run(Thread.java:662)

我该如何解决这个问题?

2 个答案:

答案 0 :(得分:2)

将javassist-3.14.0-GA.jar放入GLASSFISH_HOME \ domains \ domain1 \ lib并且不要将其包含在应用程序类路径中,如果你使用maven标记依赖关系提供

<dependency>
     <groupId>org.javassist</groupId>
     <artifactId>javassist</artifactId>
     <version>3.14.0-GA</version>
     <scope>provided</scope>
</dependency>

答案 1 :(得分:1)

以下故障单描述了问题: https://issues.jboss.org/browse/WELD-570

Javassist Classes存在上面提到的包: 的glassfish /模块/焊接OSGi的bundle.jar

我们的初步解决方案是改变

<class-loader delegate="true" />

在我们的glassfish-web.xml中。

如果您使用javassist进行休眠,本文建议您切换到备用字节代码提供程序CGLIB: http://www.java.net/node/705285

如果你在JPA上使用Hibernate,你可以使用Glassfish的Hibernate进行切换:https://blogs.oracle.com/GlassFishPersistence/entry/using_hibernate_as_jpa_provider