我们有一个旧的Web应用程序(WAR),其中包含常见的内部库。最近我们开始在另一个使用相同内部库的项目中使用CDI,一些内部库得到了META-INF/beans.xml
。
不幸的是,我们在GlassFish 3.1.2.2上部署期间遇到了各种类加载错误。
[#|2014-03-14T14:11:20.302+0100|SEVERE|glassfish3.1.2|javax.enterprise.system.tools.admin.org.glassfish.deployment.admin|_ThreadID=40;_ThreadName=Thread-2;|Exception while loading the app :
com/example/SomethingState
java.lang.NoClassDefFoundError: com/example/SomethingState
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at org.glassfish.web.loader.WebappClassLoader.findClass(WebappClassLoader.java:927)
at org.glassfish.web.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1476)
at org.glassfish.web.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1359)
at java.lang.Class.getEnclosingMethod0(Native Method)
at java.lang.Class.getEnclosingMethodInfo(Class.java:959)
at java.lang.Class.getEnclosingClass(Class.java:1132)
at java.lang.Class.getSimpleBinaryName(Class.java:1277)
at java.lang.Class.isMemberClass(Class.java:1267)
at org.jboss.weld.util.reflection.Reflections.isNonStaticInnerClass(Reflections.java:139)
at org.jboss.weld.bootstrap.BeanDeployer.addClass(BeanDeployer.java:78)
at org.jboss.weld.bootstrap.BeanDeployer.addClasses(BeanDeployer.java:123)
at org.jboss.weld.bootstrap.BeanDeployment.createBeans(BeanDeployment.java:184)
at org.jboss.weld.bootstrap.WeldBootstrap.deployBeans(WeldBootstrap.java:350)
at org.glassfish.weld.WeldDeployer.event(WeldDeployer.java:179)
at org.glassfish.kernel.event.EventsImpl.send(EventsImpl.java:128)
at org.glassfish.internal.data.ApplicationInfo.load(ApplicationInfo.java:277)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:460)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:240)
at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:389)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$1.execute(CommandRunnerImpl.java:353)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:363)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1085)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1200(CommandRunnerImpl.java:95)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1291)
at org.glassfish.deployment.autodeploy.AutoOperation.run(AutoOperation.java:145)
at org.glassfish.deployment.autodeploy.AutoDeployer.deploy(AutoDeployer.java:575)
at org.glassfish.deployment.autodeploy.AutoDeployer.deployAll(AutoDeployer.java:461)
at org.glassfish.deployment.autodeploy.AutoDeployer.run(AutoDeployer.java:389)
at org.glassfish.deployment.autodeploy.AutoDeployer.run(AutoDeployer.java:380)
at org.glassfish.deployment.autodeploy.AutoDeployService$1.run(AutoDeployService.java:220)
at java.util.TimerThread.mainLoop(Timer.java:555)
at java.util.TimerThread.run(Timer.java:505)
Caused by: java.lang.ClassNotFoundException: com.example.SomethingState
at org.glassfish.web.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1509)
at org.glassfish.web.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1359)
... 35 more
|#]
[#|2014-03-14T14:11:20.317+0100|WARNING|glassfish3.1.2|javax.enterprise.system.tools.deployment.org.glassfish.deployment.common|_ThreadID=40;_ThreadName=Thread-2;|[AutoDeploy] Autodeploy failed : /opt/glassfish3/glassfish/domains/domain1/autodeploy/myapp.war.|#]
SomethingState
不在war
文件中(也不在包含的jar
文件中)。它是CDI在扫描类路径时尝试加载的另一个类的超类,但它不被webapp(也不是子类)使用,因此在CDI之前它根本不是问题。如果我从包含的beans.xml
中删除jar
,则该网络工作正常。如果可能的话,我希望避免更改war
以及将遗失的jar
包含在其中。
我们如何禁用该网络应用的CDI?
我尝试将WEB-INF/beans.xml
放入war
,其中包含以下内容:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee" bean-discovery-mode="none">
<scan>
<exclude name="**" />
</scan>
</beans>
它不起作用,仍然无法部署webapp。
另一个想法是从命令行部署以下属性,但它也不起作用:
bin/asadmin deploy --property implicitCdiEnabled=false ~/myapp.war
答案 0 :(得分:0)
这对我有用,在xwiki上
bin / asadmin deploy --property implicitCdiEnabled = false~ / myapp.war
非常感谢