问题
I'm new to webservices. I'm trying to call a service but I'm having the below error. Based on my initial google search seems this is a loader issue that can be caused by duplicate jars, but I cannot locate which one causes this. Any help is very much appreciated.
Caused by: java.lang.LinkageError: loader constraint violation: loader (instance of org/jboss/classloader/spi/base/BaseClassLoader) previously initiated loading for a different type with name "javax/xml/soap/SOAPMessage"
at org.apache.cxf.jaxws.support.JaxWsEndpointImpl.<init>(JaxWsEndpointImpl.java:126)
at org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.createEndpoint(JaxWsServiceFactoryBean.java:208)
at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.createEndpoints(ReflectionServiceFactoryBean.java:366)
at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.create(ReflectionServiceFactoryBean.java:297)
at org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.create(JaxWsServiceFactoryBean.java:178)
at org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpoint(AbstractWSDLBasedEndpointFactory.java:100)
at org.apache.cxf.frontend.ClientFactoryBean.create(ClientFactoryBean.java:51)
at org.apache.cxf.frontend.ClientProxyFactoryBean.create(ClientProxyFactoryBean.java:102)
at org.apache.cxf.jaxws.JaxWsProxyFactoryBean.create(JaxWsProxyFactoryBean.java:115)
at org.apache.cxf.jaxws.ServiceImpl.createPort(ServiceImpl.java:437)
at org.apache.cxf.jaxws.ServiceImpl.getPort(ServiceImpl.java:316)
at org.apache.cxf.jaxws.ServiceImpl.getPort(ServiceImpl.java:303)
at javax.xml.ws.Service.getPort(Service.java:92)
回答1:
What solved my problem is the duplicate saaj.jar in my projects.
回答2:
LinkageError is JBoss is generally caused by your app packaging its own copies of certain libraries that JBoss considers restricted. These are usually things in the java.* and javax.* packages.
Try adding cxf-rt-frontend-jaxws and cxf-bundle-rs as dependencies and mark some exclusions -> jetty-server, gernomino-servlet.
Also check the beans.xml is expected to be under the classpath, instead of WEB-INF.
来源:https://stackoverflow.com/questions/17152274/java-lang-linkageerror-loader-constraint-violation-previously-initiated-loading