我是Apache CXF的新手,并尝试使用apache-cxf-2.7.8从wsdl创建Webservices Simulator和Webservices Client。
我成功创建了模拟器,并且能够从主方法客户端
中击中模拟器web服务public static void main(String args [])抛出java.lang.Exception {
URL wsdlURL = new URL("http://localhost:7020/sirius_uwi_simulator2/services/RetrieveTelematicsDataPTEndpoint?wsdl");
GetDataService ss = new GetDataService(wsdlURL, SERVICE_NAME);
GetDataPT port = ss.getRetrieveTelematicsDataPTEndpoint();
然而,当我尝试使用下面显示的客户端代码从我的struts应用程序调用相同的模拟器webservice时
public static EnrollmentInformation retrieveTelematicsData(String vin)throws java.lang.Exception {
URL wsdlURL = new URL("http://localhost:7020/sirius_uwi_simulator2/services/RetrieveTelematicsDataPTEndpoint?wsdl");
GetDataService ss = new GetDataService(wsdlURL, SERVICE_NAME);
GetDataPT port = ss.getRetrieveTelematicsDataPTEndpoint();
抛出这个例外:
ERROR com.sirius.uwi.starss.action.ValidateTermsAndConditionsAction.execute_aroundBody0 - Validating Terms And Conditions Failed
javax.xml.ws.WebServiceException: Unable to create JAXBContext
at com.sun.xml.internal.ws.model.AbstractSEIModelImpl.createJAXBContext(AbstractSEIModelImpl.java:153)
at com.sun.xml.internal.ws.model.AbstractSEIModelImpl.postProcess(AbstractSEIModelImpl.java:83)
at com.sun.xml.internal.ws.model.RuntimeModeler.buildRuntimeModel(RuntimeModeler.java:244)
at com.sun.xml.internal.ws.client.WSServiceDelegate.createSEIPortInfo(WSServiceDelegate.java:687)
at com.sun.xml.internal.ws.client.WSServiceDelegate.addSEI(WSServiceDelegate.java:675)
at com.sun.xml.internal.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:330)
at com.sun.xml.internal.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:313)
at com.sun.xml.internal.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:295)
at javax.xml.ws.Service.getPort(Service.java:92)
at com.sirius.ws.gettelematicsdata.generated.service.vehicleTelematicsPreferences.retrieveTelematicsData.GetDataService.getRetrieveTelematicsDataPTEndpoint_aroundBody0(GetDataService.java:58)
at com.sirius.ws.gettelematicsdata.generated.service.vehicleTelematicsPreferences.retrieveTelematicsData.GetDataService$AjcClosure1.run(GetDataService.java:1)
at org.aspectj.runtime.reflect.JoinPointImpl.proceed(JoinPointImpl.java:149)
at com.sirius.uwi.utils.logging.aspect.LogAspect.logTimeMethod(LogAspect.java:104)
at com.sirius.ws.gettelematicsdata.generated.service.vehicleTelematicsPreferences.retrieveTelematicsData.GetDataService.getRetrieveTelematicsDataPTEndpoint(GetDataService.java:58)
at com.sirius.uwi.starss.wsclient.GetTelematicsData.retrieveTelematicsData_aroundBody0(GetTelematicsData.java:27)
at com.sirius.uwi.starss.wsclient.GetTelematicsData$AjcClosure1.run(GetTelematicsData.java:1)
at org.aspectj.runtime.reflect.JoinPointImpl.proceed(JoinPointImpl.java:149)
at com.sirius.uwi.utils.logging.aspect.LogAspect.invoke(LogAspect.java:170)
at com.sirius.uwi.utils.logging.aspect.LogAspect.ajc$inlineAccessMethod$com_sirius_uwi_utils_logging_aspect_LogAspect$com_sirius_uwi_utils_logging_aspect_LogAspect$invoke(LogAspect.java:1)
at com.sirius.uwi.utils.logging.aspect.LogAspect.logTimeMethod(LogAspect.java:114)
at com.sirius.uwi.starss.wsclient.GetTelematicsData.retrieveTelematicsData(GetTelematicsData.java:25)
at com.sirius.uwi.starss.action.ValidateTermsAndConditionsAction.simulateTermsAndConditionsValidation(ValidateTermsAndConditionsAction.java:71)
at com.sirius.uwi.starss.action.ValidateTermsAndConditionsAction.execute_aroundBody0(ValidateTermsAndConditionsAction.java:35)
at com.sirius.uwi.starss.action.ValidateTermsAndConditionsAction$AjcClosure1.run(ValidateTermsAndConditionsAction.java:1)
at org.aspectj.runtime.reflect.JoinPointImpl.proceed(JoinPointImpl.java:149)
at com.sirius.uwi.utils.logging.aspect.LogAspect.invoke(LogAspect.java:170)
at com.sirius.uwi.utils.logging.aspect.LogAspect.ajc$inlineAccessMethod$com_sirius_uwi_utils_logging_aspect_LogAspect$com_sirius_uwi_utils_logging_aspect_LogAspect$invoke(LogAspect.java:1)
at com.sirius.uwi.utils.logging.aspect.LogAspect.logTimeMethod(LogAspect.java:114)
at com.sirius.uwi.starss.action.ValidateTermsAndConditionsAction.execute(ValidateTermsAndConditionsAction.java:26)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:450)
at com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:289)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:252)
at com.opensymphony.xwork2.interceptor.TimerInterceptor.invokeUnderTiming(TimerInterceptor.java:135)
at com.opensymphony.xwork2.interceptor.TimerInterceptor.intercept(TimerInterceptor.java:122)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.sirius.uwi.starss.interceptors.CSRAccessInterceptor.intercept_aroundBody4(CSRAccessInterceptor.java:140)
at com.sirius.uwi.starss.interceptors.CSRAccessInterceptor$AjcClosure5.run(CSRAccessInterceptor.java:1)
at org.aspectj.runtime.reflect.JoinPointImpl.proceed(JoinPointImpl.java:149)
at com.sirius.uwi.utils.logging.aspect.LogAspect.invoke(LogAspect.java:170)
at com.sirius.uwi.utils.logging.aspect.LogAspect.ajc$inlineAccessMethod$com_sirius_uwi_utils_logging_aspect_LogAspect$com_sirius_uwi_utils_logging_aspect_LogAspect$invoke(LogAspect.java:1)
at com.sirius.uwi.utils.logging.aspect.LogAspect.logTimeMethod(LogAspect.java:114)
at com.sirius.uwi.starss.interceptors.CSRAccessInterceptor.intercept(CSRAccessInterceptor.java:77)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:167)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:265)
at org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.sirius.uwi.starss.interceptors.RemoveAccountFromSessionInterceptor.intercept_aroundBody2(RemoveAccountFromSessionInterceptor.java:52)
at com.sirius.uwi.starss.interceptors.RemoveAccountFromSessionInterceptor$AjcClosure3.run(RemoveAccountFromSessionInterceptor.java:1)
at org.aspectj.runtime.reflect.JoinPointImpl.proceed(JoinPointImpl.java:149)
at com.sirius.uwi.utils.logging.aspect.LogAspect.invoke(LogAspect.java:170)
at com.sirius.uwi.utils.logging.aspect.LogAspect.ajc$inlineAccessMethod$com_sirius_uwi_utils_logging_aspect_LogAspect$com_sirius_uwi_utils_logging_aspect_LogAspect$invoke(LogAspect.java:1)
at com.sirius.uwi.utils.logging.aspect.LogAspect.logTimeMethod(LogAspect.java:114)
at com.sirius.uwi.starss.interceptors.RemoveAccountFromSessionInterceptor.intercept(RemoveAccountFromSessionInterceptor.java:42)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.sirius.uwi.starss.interceptors.MaintenanceModeInterceptor.intercept_aroundBody2(MaintenanceModeInterceptor.java:49)
at com.sirius.uwi.starss.interceptors.MaintenanceModeInterceptor$AjcClosure3.run(MaintenanceModeInterceptor.java:1)
at org.aspectj.runtime.reflect.JoinPointImpl.proceed(JoinPointImpl.java:149)
at com.sirius.uwi.utils.logging.aspect.LogAspect.invoke(LogAspect.java:170)
at com.sirius.uwi.utils.logging.aspect.LogAspect.ajc$inlineAccessMethod$com_sirius_uwi_utils_logging_aspect_LogAspect$com_sirius_uwi_utils_logging_aspect_LogAspect$invoke(LogAspect.java:1)
at com.sirius.uwi.utils.logging.aspect.LogAspect.logTimeMethod(LogAspect.java:114)
at com.sirius.uwi.starss.interceptors.MaintenanceModeInterceptor.intercept(MaintenanceModeInterceptor.java:44)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.sirius.uwi.starss.interceptors.NavigationInterceptor.intercept_aroundBody2(NavigationInterceptor.java:126)
at com.sirius.uwi.starss.interceptors.NavigationInterceptor$AjcClosure3.run(NavigationInterceptor.java:1)
at org.aspectj.runtime.reflect.JoinPointImpl.proceed(JoinPointImpl.java:149)
at com.sirius.uwi.utils.logging.aspect.LogAspect.invoke(LogAspect.java:170)
at com.sirius.uwi.utils.logging.aspect.LogAspect.ajc$inlineAccessMethod$com_sirius_uwi_utils_logging_aspect_LogAspect$com_sirius_uwi_utils_logging_aspect_LogAspect$invoke(LogAspect.java:1)
at com.sirius.uwi.utils.logging.aspect.LogAspect.logTimeMethod(LogAspect.java:114)
at com.sirius.uwi.starss.interceptors.NavigationInterceptor.intercept(NavigationInterceptor.java:48)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:138)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:239)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:191)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:91)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:100)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:141)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at org.apache.struts2.interceptor.ProfilingActivationInterceptor.intercept(ProfilingActivationInterceptor.java:104)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:256)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:145)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:161)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:171)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:189)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.sirius.uwi.commons.web.struts.interceptors.TrimParametersInterceptor.intercept_aroundBody2(TrimParametersInterceptor.java:30)
at com.sirius.uwi.commons.web.struts.interceptors.TrimParametersInterceptor$AjcClosure3.run(TrimParametersInterceptor.java:1)
at org.aspectj.runtime.reflect.JoinPointImpl.proceed(JoinPointImpl.java:149)
at com.sirius.uwi.utils.logging.aspect.LogAspect.logTimeMethod(LogAspect.java:104)
at com.sirius.uwi.commons.web.struts.interceptors.TrimParametersInterceptor.intercept(TrimParametersInterceptor.java:20)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:54)
at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:563)
at org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:99)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:83)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at com.sirius.uwi.commons.web.filter.LoggingRequestFilter.doFilter_aroundBody4(LoggingRequestFilter.java:57)
at com.sirius.uwi.commons.web.filter.LoggingRequestFilter$AjcClosure5.run(LoggingRequestFilter.java:1)
at org.aspectj.runtime.reflect.JoinPointImpl.proceed(JoinPointImpl.java:149)
at com.sirius.uwi.utils.logging.aspect.LogAspect.logTimeMethod(LogAspect.java:104)
at com.sirius.uwi.commons.web.filter.LoggingRequestFilter.doFilter(LoggingRequestFilter.java:45)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Thread.java:662)
Caused by: java.security.PrivilegedActionException: com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions
javax.xml.bind.JAXBElement does not have a no-arg default constructor.
this problem is related to the following location:
at javax.xml.bind.JAXBElement
at static final javax.xml.bind.JAXBElement com.sirius.ws.gettelematicsdata.generated.schemas.telematics.common.mobileWebHeader.ObjectFactory.createCDIID_aroundBody8(com.sirius.ws.gettelematicsdata.generated.schemas.telematics.common.mobileWebHeader.ObjectFactory,java.lang.String,org.aspectj.lang.JoinPoint)
at com.sirius.ws.gettelematicsdata.generated.schemas.telematics.common.mobileWebHeader.ObjectFactory
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.xml.internal.ws.model.AbstractSEIModelImpl.createJAXBContext(AbstractSEIModelImpl.java:140)
... 138 more
Caused by: com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions
javax.xml.bind.JAXBElement does not have a no-arg default constructor.
this problem is related to the following location:
at javax.xml.bind.JAXBElement
at static final javax.xml.bind.JAXBElement com.sirius.ws.gettelematicsdata.generated.schemas.telematics.common.mobileWebHeader.ObjectFactory.createCDIID_aroundBody8(com.sirius.ws.gettelematicsdata.generated.schemas.telematics.common.mobileWebHeader.ObjectFactory,java.lang.String,org.aspectj.lang.JoinPoint)
at com.sirius.ws.gettelematicsdata.generated.schemas.telematics.common.mobileWebHeader.ObjectFactory
at com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException$Builder.check(IllegalAnnotationsException.java:91)
at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(JAXBContextImpl.java:436)
at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:277)
at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl$JAXBContextBuilder.build(JAXBContextImpl.java:1100)
at com.sun.xml.internal.bind.v2.ContextFactory.createContext(ContextFactory.java:143)
at com.sun.xml.internal.bind.api.JAXBRIContext.newInstance(JAXBRIContext.java:95)
at com.sun.xml.internal.ws.developer.JAXBContextFactory$1.createJAXBContext(JAXBContextFactory.java:97)
at com.sun.xml.internal.ws.model.AbstractSEIModelImpl$1.run(AbstractSEIModelImpl.java:148)
at com.sun.xml.internal.ws.model.AbstractSEIModelImpl$1.run(AbstractSEIModelImpl.java:140)
... 140 more
有谁知道为什么会这样?为什么从客户端的main方法调用它而不是从基于struts的web应用程序调用它。我猜它必须与罐子有关。
答案 0 :(得分:1)
根本没有拿起CXF罐子。它使用的是内置JAX-WS实现的JDK。绝对检查类路径等。