中使用Moxy,因此我們無法使用Glassfish作爲應用服務器。不過我想用Moxy。所以我試圖讓新的Metro版本(https://blogs.oracle.com/mgrebac/entry/metro_2_2_jaxb_2)與tomcat 7一起工作。我使用Spring來管理它,以引導Moxy,就像它在地鐵文檔(http://metro.java.net/guide/user-guide.html#springa)中所描述的那樣,但我沒有管理它以使它達到與Moxy合作。由於公司要求,在Tomcat
我已經嘗試了地鐵文檔(http://metro.java.net/2.2/guide/ch17.html)中提到的解決方案和此處提到的解決方案(Use Moxy as default JAXB Implementation)。
但我可以把它弄出來的最多的是以下情況除外:
com.sun.xml.ws.spi.db.DatabindingException: Unknown JAXBContext implementation: class org.eclipse.persistence.jaxb.JAXBContext
at com.sun.xml.ws.spi.db.BindingContextFactory.getJAXBFactory(BindingContextFactory.java:207)
at com.sun.xml.ws.spi.db.BindingContextFactory.create(BindingContextFactory.java:149)
at com.sun.xml.ws.message.jaxb.JAXBMessage.create(JAXBMessage.java:160)
at com.sun.xml.ws.fault.SOAPFaultBuilder.createSOAP11Fault(SOAPFaultBuilder.java:423)
at com.sun.xml.ws.fault.SOAPFaultBuilder.createSOAPFaultMessage(SOAPFaultBuilder.java:200)
at com.sun.xml.ws.fault.SOAPFaultBuilder.createSOAPFaultMessage(SOAPFaultBuilder.java:188)
at com.sun.xml.ws.server.WSEndpointImpl$2.process(WSEndpointImpl.java:391)
at com.sun.xml.ws.transport.http.HttpAdapter$HttpToolkit.handle(HttpAdapter.java:640)
at com.sun.xml.ws.transport.http.HttpAdapter.handle(HttpAdapter.java:263)
at com.sun.xml.ws.transport.http.servlet.ServletAdapter.invokeAsync(ServletAdapter.java:218)
at com.sun.xml.ws.transport.http.servlet.WSServletDelegate.doGet(WSServletDelegate.java:159)
at com.sun.xml.ws.transport.http.servlet.WSServletDelegate.doPost(WSServletDelegate.java:194)
at com.sun.xml.ws.transport.http.servlet.WSSpringServlet.doPost(WSSpringServlet.java:52)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:405)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:964)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:515)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:302)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
我的測試web服務是:
@WebService
public class TestService {
public String sayHello() throws JAXBException {
System.out.println(org.eclipse.persistence.Version.getVersion());
JAXBContext c = JAXBContext.newInstance(TestPojo.class);
return "Hello";
}
}
而且是在該MOXY罐子(org.eclipse.persistence。 moxy-2.4.0.jar,org.eclipse.persistence.core-2.4.0.jar,org.eclipse.persistence.asm-3.3.1.v201206041142.jar)位於類路徑中。
THX的幫助
JayBee
得到了同樣的問題,你有沒有找到解決的辦法? – JavaDev 2016-06-28 14:24:42