Spring使用未找到的SOAP服务JAXB类

时间:2015-12-10 14:38:29

标签: spring soap jaxb

我正在尝试按照以下指南设置SOAP服务使用者:https://spring.io/guides/gs/consuming-web-service/ 我生成了JAXB类并编写了bean来创建服务:

@Configuration
public class ArchifantConfiguration {
@Bean
public Jaxb2Marshaller marshaller() {
    Jaxb2Marshaller marshaller = new Jaxb2Marshaller();
    marshaller.setContextPath("some.package.path");

    return marshaller;
}

@Bean
public ArchifantCommunicationService archifantClient(Jaxb2Marshaller marshaller) {
    ArchifantCommunicationService client = new ArchifantCommunicationService();
    client.setMarshaller(marshaller);
    client.setUnmarshaller(marshaller);

    return client;
}
}

服务看起来像这样:

public class ArchifantCommunicationService extends WebServiceGatewaySupport{

@Autowired
ArchifantConfigI config;

public ReadDocumentResponse readDocument(long fileID){
    ObjectFactory factory = new ObjectFactory();
    JAXBElement<String> jaxbMandantPasswort = factory.createString(config.getMandantPassword());

    ReadDocument request = new ReadDocument();
    request.setPMandantId(config.getMandantId());
    request.setPMandantPassword(jaxbMandantPasswort);
    request.setPFileId(fileID);

    getWebServiceTemplate().setDefaultUri(config.getUrl());
    getWebServiceTemplate().marshalSendAndReceive(new WebServiceMessageCallback() {
        @Override
        public void doWithMessage(WebServiceMessage message) throws IOException, TransformerException {
            ((SoapMessage)message).setSoapAction("http://.../ReadDocumetn");
        }
    });

    ReadDocumentResponse response = (ReadDocumentResponse)getWebServiceTemplate().marshalSendAndReceive(
        config.getUrl(),
        request);

    return response;
}
}

当我现在尝试接收文档时,它在编组时失败,出现以下异常:

Last cause: Weder class de.arvato.crmit.archifantcom.ArchifantCommunicationService$1 noch eine der zugehörigen Superklassen ist diesem Kontext bekannt.

英文:

class ... neither one of the super classes is known in this context

当我调试时,我可以看到WebServiceTemplate包含我设置的包路径。整个消费者服务位于eclipse的子项目中。这有什么问题? JAXB类看起来很好。

项目设置:

  • 服务项目
    • jaxb package
    • 服务和bean类
  • 主要项目
    • 通过@Autowired
    • 使用

完整筹码:

Root cause:

javax.xml.bind.JAXBException: Weder class de.arvato.crmit.archifantcom.ArchifantCommunicationService$1 noch eine der zugehörigen Superklassen ist diesem Kontext bekannt.
 at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.getBeanInfo(Unknown Source)
 at com.sun.xml.internal.bind.v2.runtime.XMLSerializer.childAsRoot(Unknown Source)
 at com.sun.xml.internal.bind.v2.runtime.MarshallerImpl.write(Unknown Source)
 at com.sun.xml.internal.bind.v2.runtime.MarshallerImpl.marshal(Unknown Source)
 at org.springframework.oxm.jaxb.Jaxb2Marshaller.marshal(Jaxb2Marshaller.java:662)
 at org.springframework.ws.support.MarshallingUtils.marshal(MarshallingUtils.java:81)
 at org.springframework.ws.client.core.WebServiceTemplate$2.doWithMessage(WebServiceTemplate.java:399)
 at org.springframework.ws.client.core.WebServiceTemplate.doSendAndReceive(WebServiceTemplate.java:590)
 at org.springframework.ws.client.core.WebServiceTemplate.sendAndReceive(WebServiceTemplate.java:555)
 at org.springframework.ws.client.core.WebServiceTemplate.marshalSendAndReceive(WebServiceTemplate.java:390)
 at org.springframework.ws.client.core.WebServiceTemplate.marshalSendAndReceive(WebServiceTemplate.java:383)
 at org.springframework.ws.client.core.WebServiceTemplate.marshalSendAndReceive(WebServiceTemplate.java:373)
 at de.arvato.crmit.archifantcom.ArchifantCommunicationService.readDocument(ArchifantCommunicationService.java:53)
 at de.arvato.crmit.zusyadapter.delegate.ZusyDokumentencenterDelegate.dokumentencenterPdfDokumentLesen(ZusyDokumentencenterDelegate.java:69)
 at de.arvato.crmit.zusyadapter.ZusyAdapter.dokumentencenterPdfDokumentLesen(ZusyAdapter.java:81)
 at de.arvato.crmit.rio.pages.dokumentencenter.PDFAnzeigeViewPage.ladeDokument(PDFAnzeigeViewPage.java:52)
 at de.arvato.crmit.rio.pages.dokumentencenter.PDFAnzeigeViewPage.<init>(PDFAnzeigeViewPage.java:36)
 at de.arvato.crmit.rio.pages.dokumentencenter.DokumentencenterDokumentPanel$2.onClick(DokumentencenterDokumentPanel.java:50)
 at org.apache.wicket.markup.html.link.Link.onLinkClicked(Link.java:190)
 at java.lang.reflect.Method.invoke(Unknown Source)
 at org.apache.wicket.RequestListenerInterface.internalInvoke(RequestListenerInterface.java:258)
 at org.apache.wicket.RequestListenerInterface.invoke(RequestListenerInterface.java:216)
 at org.apache.wicket.core.request.handler.ListenerInterfaceRequestHandler.invokeListener(ListenerInterfaceRequestHandler.java:240)
 at org.apache.wicket.core.request.handler.ListenerInterfaceRequestHandler.respond(ListenerInterfaceRequestHandler.java:226)
 at org.apache.wicket.request.cycle.RequestCycle$HandlerExecutor.respond(RequestCycle.java:861)
 at org.apache.wicket.request.RequestHandlerStack.execute(RequestHandlerStack.java:64)
 at org.apache.wicket.request.cycle.RequestCycle.execute(RequestCycle.java:261)
 at org.apache.wicket.request.cycle.RequestCycle.processRequest(RequestCycle.java:218)
 at org.apache.wicket.request.cycle.RequestCycle.processRequestAndDetach(RequestCycle.java:289)
 at org.apache.wicket.protocol.http.WicketFilter.processRequestCycle(WicketFilter.java:259)
 at org.apache.wicket.protocol.http.WicketFilter.processRequest(WicketFilter.java:201)
 at org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:282)
 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
 at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:316)
 at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:126)
 at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:90)
 at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
 at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:114)
 at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
 at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:122)
 at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
 at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111)
 at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
 at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:169)
 at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
 at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:48)
 at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
 at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:120)
 at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
 at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:64)
 at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
 at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
 at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:91)
 at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
 at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:53)
 at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
 at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
 at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:213)
 at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:176)
 at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
 at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:262)
 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
 at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212)
 at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
 at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
 at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141)
 at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
 at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616)
 at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
 at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:518)
 at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1096)
 at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:674)
 at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1500)
 at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1456)
 at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
 at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
 at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
 at java.lang.Thread.run(Unknown Source)

Complete stack:

org.apache.wicket.WicketRuntimeException: Method onLinkClicked of interface org.apache.wicket.markup.html.link.ILinkListener targeted at [Link [Component id = pdfLink]] on component [Link [Component id = pdfLink]] threw an exception
 at org.apache.wicket.RequestListenerInterface.internalInvoke(RequestListenerInterface.java:268)
 at org.apache.wicket.RequestListenerInterface.invoke(RequestListenerInterface.java:216)
 at org.apache.wicket.core.request.handler.ListenerInterfaceRequestHandler.invokeListener(ListenerInterfaceRequestHandler.java:240)
 at org.apache.wicket.core.request.handler.ListenerInterfaceRequestHandler.respond(ListenerInterfaceRequestHandler.java:226)
 at org.apache.wicket.request.cycle.RequestCycle$HandlerExecutor.respond(RequestCycle.java:861)
 at org.apache.wicket.request.RequestHandlerStack.execute(RequestHandlerStack.java:64)
 at org.apache.wicket.request.cycle.RequestCycle.execute(RequestCycle.java:261)
 at org.apache.wicket.request.cycle.RequestCycle.processRequest(RequestCycle.java:218)
 at org.apache.wicket.request.cycle.RequestCycle.processRequestAndDetach(RequestCycle.java:289)
 at org.apache.wicket.protocol.http.WicketFilter.processRequestCycle(WicketFilter.java:259)

java.lang.reflect.InvocationTargetException
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
 at java.lang.reflect.Method.invoke(Unknown Source)
 at org.apache.wicket.RequestListenerInterface.internalInvoke(RequestListenerInterface.java:258)
 at org.apache.wicket.RequestListenerInterface.invoke(RequestListenerInterface.java:216)
 at org.apache.wicket.core.request.handler.ListenerInterfaceRequestHandler.invokeListener(ListenerInterfaceRequestHandler.java:240)
 at org.apache.wicket.core.request.handler.ListenerInterfaceRequestHandler.respond(ListenerInterfaceRequestHandler.java:226)
 at org.apache.wicket.request.cycle.RequestCycle$HandlerExecutor.respond(RequestCycle.java:861)
 at org.apache.wicket.request.RequestHandlerStack.execute(RequestHandlerStack.java:64)
 at org.apache.wicket.request.cycle.RequestCycle.execute(RequestCycle.java:261)
 at org.apache.wicket.request.cycle.RequestCycle.processRequest(RequestCycle.java:218)
 at org.apache.wicket.request.cycle.RequestCycle.processRequestAndDetach(RequestCycle.java:289)
 at org.apache.wicket.protocol.http.WicketFilter.processRequestCycle(WicketFilter.java:259)

org.springframework.oxm.UncategorizedMappingException: Unknown JAXB exception; nested exception is javax.xml.bind.JAXBException: Weder class de.arvato.crmit.archifantcom.ArchifantCommunicationService$1 noch eine der zugehörigen Superklassen ist diesem Kontext bekannt.
 at org.springframework.oxm.jaxb.Jaxb2Marshaller.convertJaxbException(Jaxb2Marshaller.java:888)
 at org.springframework.oxm.jaxb.Jaxb2Marshaller.marshal(Jaxb2Marshaller.java:666)
 at org.springframework.ws.support.MarshallingUtils.marshal(MarshallingUtils.java:81)
 at org.springframework.ws.client.core.WebServiceTemplate$2.doWithMessage(WebServiceTemplate.java:399)
 at org.springframework.ws.client.core.WebServiceTemplate.doSendAndReceive(WebServiceTemplate.java:590)
 at org.springframework.ws.client.core.WebServiceTemplate.sendAndReceive(WebServiceTemplate.java:555)
 at org.springframework.ws.client.core.WebServiceTemplate.marshalSendAndReceive(WebServiceTemplate.java:390)
 at org.springframework.ws.client.core.WebServiceTemplate.marshalSendAndReceive(WebServiceTemplate.java:383)
 at org.springframework.ws.client.core.WebServiceTemplate.marshalSendAndReceive(WebServiceTemplate.java:373)
 at de.arvato.crmit.archifantcom.ArchifantCommunicationService.readDocument(ArchifantCommunicationService.java:53)
 at de.arvato.crmit.zusyadapter.delegate.ZusyDokumentencenterDelegate.dokumentencenterPdfDokumentLesen(ZusyDokumentencenterDelegate.java:69)
 at de.arvato.crmit.zusyadapter.ZusyAdapter.dokumentencenterPdfDokumentLesen(ZusyAdapter.java:81)
 at de.arvato.crmit.rio.pages.dokumentencenter.PDFAnzeigeViewPage.ladeDokument(PDFAnzeigeViewPage.java:52)
 at de.arvato.crmit.rio.pages.dokumentencenter.PDFAnzeigeViewPage.<init>(PDFAnzeigeViewPage.java:36)
 at de.arvato.crmit.rio.pages.dokumentencenter.DokumentencenterDokumentPanel$2.onClick(DokumentencenterDokumentPanel.java:50)
 at org.apache.wicket.markup.html.link.Link.onLinkClicked(Link.java:190)
 at java.lang.reflect.Method.invoke(Unknown Source)
 at org.apache.wicket.RequestListenerInterface.internalInvoke(RequestListenerInterface.java:258)
 at org.apache.wicket.RequestListenerInterface.invoke(RequestListenerInterface.java:216)
 at org.apache.wicket.core.request.handler.ListenerInterfaceRequestHandler.invokeListener(ListenerInterfaceRequestHandler.java:240)
 at org.apache.wicket.core.request.handler.ListenerInterfaceRequestHandler.respond(ListenerInterfaceRequestHandler.java:226)
 at org.apache.wicket.request.cycle.RequestCycle$HandlerExecutor.respond(RequestCycle.java:861)
 at org.apache.wicket.request.RequestHandlerStack.execute(RequestHandlerStack.java:64)
 at org.apache.wicket.request.cycle.RequestCycle.execute(RequestCycle.java:261)
 at org.apache.wicket.request.cycle.RequestCycle.processRequest(RequestCycle.java:218)
 at org.apache.wicket.request.cycle.RequestCycle.processRequestAndDetach(RequestCycle.java:289)
 at org.apache.wicket.protocol.http.WicketFilter.processRequestCycle(WicketFilter.java:259)

2 个答案:

答案 0 :(得分:1)

通过将生成的文件移动到构建目录来解决它。

答案 1 :(得分:1)

我已经在build目录中拥有了这些类。我需要将setClassesToBeBound显式设置为请求和响应类以使其工作。我试图设置JAXBContext但是把它留在了那里。