我正在部署一个Web服务(使用METRO 2.0
库并将其包含在war
文件中),并在tomcat
上使用security manager
启用了
-Djava.security.manager
-Djava.security.policy=C:apache-tomcat-8.5.6confcatalina.policy
我得到以下异常
SEVERE [localhost-startStop-1]
com.sun.xml.ws.transport.http.servlet.WSServletContextListener.contextInitialized
WSSERVLET11: failed to parse runtime descriptor: java.lang.LinkageError: loader
constraint violation: loader (instance of
org/apache/catalina/loader/ParallelWebappClassLoader) previously initiated loading for a
different type with name "javax/xml/bind/annotation/XmlNsForm"
java.lang.LinkageError: loader constraint violation: loader (instance of
org/apache/catalina/loader/ParallelWebappClassLoader) previously initiated loading for a
different type with name "javax/xml/bind/annotation/XmlNsForm"
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at org.apache.catalina.loader.WebappClassLoaderBase.findClassInternal
(WebappClassLoaderBase.java:2268)
at org.apache.catalina.loader.WebappClassLoaderBase
$PrivilegedFindClassByName.run(WebappClassLoaderBase.java:155)
at org.apache.catalina.loader.WebappClassLoaderBase
$PrivilegedFindClassByName.run(WebappClassLoaderBase.java:144)
at java.security.AccessController.doPrivileged(Native Method)
at org.apache.catalina.loader.WebappClassLoaderBase.findClass
(WebappClassLoaderBase.java:809)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass
(WebappClassLoaderBase.java:1254)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass
(WebappClassLoaderBase.java:1119)
at com.sun.xml.bind.v2.model.impl.PropertyInfoImpl$1.<clinit>
(PropertyInfoImpl.java:365)
at com.sun.xml.bind.v2.model.impl.PropertyInfoImpl.calcXmlName
(PropertyInfoImpl.java:365)
at com.sun.xml.bind.v2.model.impl.PropertyInfoImpl.calcXmlName
(PropertyInfoImpl.java:340)
at com.sun.xml.bind.v2.model.impl.ElementPropertyInfoImpl.getTypes
(ElementPropertyInfoImpl.java:136)
at com.sun.xml.bind.v2.model.impl.RuntimeElementPropertyInfoImpl.getTypes
(RuntimeElementPropertyInfoImpl.java:86)
at com.sun.xml.bind.v2.model.impl.ElementPropertyInfoImpl$1.size
(ElementPropertyInfoImpl.java:78)
at java.util.AbstractList$Itr.hasNext(AbstractList.java:351)
at com.sun.xml.bind.v2.model.impl.ModelBuilder.getClassInfo
(ModelBuilder.java:255)
at com.sun.xml.bind.v2.model.impl.RuntimeModelBuilder.getClassInfo
(RuntimeModelBuilder.java:100)
at com.sun.xml.bind.v2.model.impl.RuntimeModelBuilder.getClassInfo
(RuntimeModelBuilder.java:81)
at com.sun.xml.bind.v2.model.impl.ModelBuilder.getClassInfo
(ModelBuilder.java:209)
at com.sun.xml.bind.v2.model.impl.RuntimeModelBuilder.getClassInfo
(RuntimeModelBuilder.java:95)
at com.sun.xml.bind.v2.model.impl.RuntimeModelBuilder.getClassInfo
(RuntimeModelBuilder.java:81)
at com.sun.xml.bind.v2.model.impl.ModelBuilder.getTypeInfo
(ModelBuilder.java:315)
at com.sun.xml.bind.v2.model.impl.TypeRefImpl.calcRef(TypeRefImpl.java:92)
at com.sun.xml.bind.v2.model.impl.TypeRefImpl.getTarget(TypeRefImpl.java:69)
at com.sun.xml.bind.v2.model.impl.RuntimeTypeRefImpl.getTarget
(RuntimeTypeRefImpl.java:58)
at com.sun.xml.bind.v2.model.impl.RuntimeTypeRefImpl.getTarget
(RuntimeTypeRefImpl.java:51)
at com.sun.xml.bind.v2.model.impl.ElementPropertyInfoImpl$1.get
(ElementPropertyInfoImpl.java:74)
at com.sun.xml.bind.v2.model.impl.ElementPropertyInfoImpl$1.get
(ElementPropertyInfoImpl.java:77)
at java.util.AbstractList$Itr.next(AbstractList.java:358)
at com.sun.xml.bind.v2.model.impl.ModelBuilder.getClassInfo
(ModelBuilder.java:255)
at com.sun.xml.bind.v2.model.impl.RuntimeModelBuilder.getClassInfo
(RuntimeModelBuilder.java:100)
at com.sun.xml.bind.v2.model.impl.RuntimeModelBuilder.getClassInfo
(RuntimeModelBuilder.java:81)
at com.sun.xml.bind.v2.model.impl.ModelBuilder.getClassInfo
(ModelBuilder.java:209)
at com.sun.xml.bind.v2.model.impl.RuntimeModelBuilder.getClassInfo
(RuntimeModelBuilder.java:95)
at com.sun.xml.bind.v2.model.impl.RuntimeModelBuilder.getClassInfo
(RuntimeModelBuilder.java:81)
at com.sun.xml.bind.v2.model.impl.ModelBuilder.getTypeInfo
(ModelBuilder.java:315)
at com.sun.xml.bind.v2.model.impl.ModelBuilder.getTypeInfo
(ModelBuilder.java:330)
at com.sun.xml.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet
(JAXBContextImpl.java:466)
at com.sun.xml.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:302)
at com.sun.xml.bind.v2.runtime.JAXBContextImpl$JAXBContextBuilder.build
(JAXBContextImpl.java:1140)
at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:154)
at com.sun.xml.bind.api.JAXBRIContext.newInstance(JAXBRIContext.java:106)
at com.sun.xml.ws.developer.JAXBContextFactory$1.createJAXBContext
(JAXBContextFactory.java:109)
at com.sun.xml.ws.model.AbstractSEIModelImpl$1.run
(AbstractSEIModelImpl.java:161)
at com.sun.xml.ws.model.AbstractSEIModelImpl$1.run
(AbstractSEIModelImpl.java:154)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.xml.ws.model.AbstractSEIModelImpl.createJAXBContext
(AbstractSEIModelImpl.java:153)
at com.sun.xml.ws.model.AbstractSEIModelImpl.postProcess
(AbstractSEIModelImpl.java:94)
at com.sun.xml.ws.model.RuntimeModeler.buildRuntimeModel
(RuntimeModeler.java:258)
at com.sun.xml.ws.server.EndpointFactory.createSEIModel
(EndpointFactory.java:338)
at com.sun.xml.ws.server.EndpointFactory.createEndpoint
(EndpointFactory.java:201)
at com.sun.xml.ws.api.server.WSEndpoint.create(WSEndpoint.java:505)
at com.sun.xml.ws.transport.http.DeploymentDescriptorParser.parseAdapters
(DeploymentDescriptorParser.java:253)
at com.sun.xml.ws.transport.http.DeploymentDescriptorParser.parse
(DeploymentDescriptorParser.java:147)
at
com.sun.xml.ws.transport.http.servlet.WSServletContextListener.contextInitialized
(WSServletContextListener.java:124)
at org.apache.catalina.core.StandardContext.listenerStart
(StandardContext.java:4727)
at org.apache.catalina.core.StandardContext.startInternal
(StandardContext.java:5189)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal
(ContainerBase.java:724)
at org.apache.catalina.core.ContainerBase.access$000(ContainerBase.java:129)
at org.apache.catalina.core.ContainerBase$PrivilegedAddChild.run
(ContainerBase.java:150)
at org.apache.catalina.core.ContainerBase$PrivilegedAddChild.run
(ContainerBase.java:140)
at java.security.AccessController.doPrivileged(Native Method)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:698)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:734)
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:596)
at org.apache.catalina.startup.HostConfig$DeployDescriptor.run
(HostConfig.java:1805)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker
(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run
(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
另一方面,没有security manager
-一切都很好。
搜索后,我开始了解问题是javax/xml/bind/annotation/XmlNsForm
均在tomcat
库中和METRO 2.0
中找到。
所以我有2个问题:
1. catalina.policy
中是否有某种属性可以避免此问题。
2.还有其他方法可以解决这一冲突,而无需从war
删除Metro 2.0
。
预先感谢。
因此,解决方案不使用Metro 2.0
的整个捆绑包 - 只有捆绑包的某些库(添加为 jars
不像netbeans
中的整个捆绑包)