无法将.war应用程序部署到GlassFish 3.1.2 [英] Unable to deploy .war application to GlassFish 3.1.2
问题描述
我有一个.war应用程序模块,可以成功部署,无需任何异常更改和服务器调整。但是,我无法将此应用程序部署到GF 3.1.2:服务器抛出以下异常:
java.lang.Exception:java。 lang.IllegalStateException:ContainerBase.addChild:start:org.apache.catalina.LifecycleException:org.apache.catalina.LifecycleException:java.lang.NoSuchFieldError:theInstance
我做错了什么?有人建议我什么吗?有没有额外的设置,我应该执行部署.war模块成功?
提前感谢很多。
UPD
更精确的日志条目:
javax.xml.bind.JAXBException:Provider com.sun.xml.bind.ContextFactory_1_0_1无法实例化:javax.xml.bind.JAXBException
- 链接异常:
[java.lang。 NoSuchFieldError:theInstance]
- 链接异常:
[javax.xml.bind.JAXBException
- 链接异常:
[java.lang.NoSuchFieldError:theInstance] ]
你需要你的WEB-INF / lib JAXB jar在GlassFish JAXB jar之前使用。
或更改您的应用程序以使用GlassFish 3.1.2捆绑的版本。
Servlet规范说,Web应用程序应该在委派之前使用本地类加载器父母。我认为默认情况下,GlassFish将代理到Web应用程序的父类加载器。在web.xml或glassfish-web.xml中使用< class-loader delegate =false/>
。
注意,如果这不起作用,可能还有其他方法修改GlassFish中的类加载器。
这种类型的问题在部署到许多应用程序服务器时很常见。
我在过去5年里每天都使用GlassFish,经常看到这一点。
最近在CloudBees上部署到JBoss时遇到了类似的问题,并相应地修改了部署描述符。
Googlingglassfish喜欢web-inf / lib jars。 p> 响应下面的psed评论 I have a .war application module, that can be successfully deployed without any exotic changes and server tuning. However, i was unable to deploy this app to GF 3.1.2: server throws following exception: java.lang.Exception: java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: org.apache.catalina.LifecycleException: java.lang.NoSuchFieldError: theInstance What i am doing wrong? Has anyone suggest me something? Is there any additional settings that i should perform to deploy .war module successfully? Thanks a lot in advance. UPD More precise log entry: javax.xml.bind.JAXBException: Provider com.sun.xml.bind.ContextFactory_1_0_1 could not be instantiated: javax.xml.bind.JAXBException
- with linked exception:
[java.lang.NoSuchFieldError: theInstance]
Sounds like a class loader issue. You need your WEB-INF/lib JAXB jars used ahead of the GlassFish JAXB jars.
Or change your app to use the versions GlassFish 3.1.2 is bundled with. Servlet spec says that web applications should use the local class loader before delegating to the parent. I think GlassFish delegates to the the parent class loader for web applications by default. Use Note there may be other ways to modify the class loader in GlassFish if this does not work. This type of issue is common during deployment to many application servers.
I've used GlassFish daily for the last 5+ years and see this every so often.
Recently saw a similar issue when deploying to JBoss on CloudBees, and modified a deployment descriptor accordingly. Googling "glassfish prefer web-inf/lib jars". Response To psed comment below
EJB interfaces must reside in the class path hierarchy shared by the Web module and EJB module. If you have an EJB interface jar in WEB-INF/lib and another copy of the EJB interface jar on the EJB module classpath, you would get a ClassCastException when injecting/locating the EJB in your web application. I assume WebServices have the same issue. Sharing the EJB interface jar though an EAR should resolve this issue though. Note there may be other issues I am unaware of 这篇关于无法将.war应用程序部署到GlassFish 3.1.2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
EJB接口必须驻留在Web模块和EJB模块共享的类路径层次中。如果您在WEB-INF / lib中有一个EJB接口jar,并且在EJB模块类路径上有EJB接口jar的另一个副本,那么在Web应用程序中注入/定位EJB时,会收到ClassCastException。我假设WebServices有同样的问题。通过EAR共享EJB接口jar应该可以解决这个问题。注意可能还有其他问题我不知道
- with linked exception:
[javax.xml.bind.JAXBException
- with linked exception:
[java.lang.NoSuchFieldError: theInstance]]<class-loader delegate="false"/>
in web.xml or glassfish-web.xml.