cxf 动态创建客户端 异常 Could not compile java files for

发布于 2022-01-02 12:52:44 字数 16144 浏览 906 评论 1

运行环境 Linux  weblogic 10.3 JDK1.6.0_45

代码片段

public ClaimResponse getTaWsResponse(String method, ClaimRequest claim) {
        Long time = Calendar.getInstance().getTimeInMillis();
        String response = null;
        ClaimResponse claimResponse = null;
        Long a = System.currentTimeMillis();
        HTTPConduit http = null;
        org.apache.cxf.endpoint.Client client = null;
        try {
            String xml = XStreamUtil.toXML(claim, ClaimRequest.class);
            logger.info(sdf.format(new Date())+":"+xml);
            systemService.addLog(time+":"+StringUtil.replaceBlank(xml), Globals.Log_Type_WS, Globals.Log_Leavel_INFO);
            
            JaxWsDynamicClientFactory dcf = JaxWsDynamicClientFactory
                    .newInstance();
            client = dcf
                    .createClient(ResourceUtil.getConfigByName("ws_path"));
            
            QName opName = new QName(ResourceUtil.getConfigByName("qname_path"), method);
            
            http = (HTTPConduit) client.getConduit();      
            HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy();      
            httpClientPolicy.setConnectionTimeout(10000);  //连接超时    
            httpClientPolicy.setAllowChunking(false);      //取消块编码
            httpClientPolicy.setReceiveTimeout(30000);     //响应超时
            http.setClient(httpClientPolicy);
            
            Object[] objects = client.invoke(opName,xml);
            
            if(objects.length > 0){
                // 输出调用结果
                response = objects[0].toString();
                logger.info(sdf.format(new Date())+":"+response);
            }else{
                systemService.addLog(time+":返回结果为空", Globals.Log_Type_WS, Globals.Log_Leavel_ERROR);
                return null;
            }
            
            claimResponse =  XStreamUtil.fromXML(response, ClaimResponse.class);
            
        } catch (Exception e) {
            Long b = System.currentTimeMillis();
            systemService.addLog("webservice消耗时间:" + (b-a), Globals.Log_Type_WS, Globals.Log_Leavel_INFO);
            e.printStackTrace();
            systemService.addLog(time+":"+e.getLocalizedMessage(), Globals.Log_Type_WS, Globals.Log_Leavel_ERROR);
            return null;
        }finally{
            if(http!=null){
                http.close();
                http = null;
            }
            if(client!=null){
                client.destroy();
                client = null;
            }
        }
        return claimResponse;
    }
}

异常说明 ,weblogic服务节点启动时 CXF代码能正常运行,但是正常运行了一段时间后 不知道什么原因就会报一下异常,重启服务节点CXF客户端又能正常运行:

[org.apache.cxf.endpoint.dynamic.DynamicClientFactory]Could not compile java files for http://claim.tianan-insurance.com/cxfServices/Claim2Delegate?wsdl.
java.lang.IllegalStateException: Unable to create JAXBContext for generated packages: "com.sinosoft.application.interact.webservice.provider.delegate.delegateinterfacade" doesnt contain ObjectFactory.class or jaxb.index
    at org.apache.cxf.endpoint.dynamic.DynamicClientFactory.createClient(DynamicClientFactory.java:397)
    at org.apache.cxf.endpoint.dynamic.DynamicClientFactory.createClient(DynamicClientFactory.java:241)
    at org.apache.cxf.endpoint.dynamic.DynamicClientFactory.createClient(DynamicClientFactory.java:234)
    at org.apache.cxf.endpoint.dynamic.DynamicClientFactory.createClient(DynamicClientFactory.java:189)
    at com.dispatch.service.tianan.impl.TaWsServiceImpl.getTaWsResponse(TaWsServiceImpl.java:48)
    at com.dispatch.service.tianan.impl.TaDispatchServiceImpl.delegateNormalTask(TaDispatchServiceImpl.java:157)
    at com.dispatch.controller.survey.TaCaseInfoController2.submitTasks(TaCaseInfoController2.java:3137)
    at sun.reflect.GeneratedMethodAccessor925.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:176)
    at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:436)
    at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:424)
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:923)
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852)
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
    at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:789)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
    at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
    at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
    at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:301)
    at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:60)
    at com.dispatch.util.InitFilter.doFilter(InitFilter.java:35)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:60)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
    at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:118)
    at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:84)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:103)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:113)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:54)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:45)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:183)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    at com.tapi.tcs.tf.security.authentication.CustomLogoutFilter.doFilter(CustomLogoutFilter.java:95)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    at com.tapi.cas.client.filter.SingleSignOutFilter.doFilter(SingleSignOutFilter.java:110)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    at com.tapi.tcs.tf.security.authentication.CookieSessionContextIntegrationFilter.doFilter(CookieSessionContextIntegrationFilter.java:25)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    at com.tapi.tcs.tf.security.authentication.CustomExceptionTranslationFilter.doFilter(CustomExceptionTranslationFilter.java:41)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:192)
    at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:160)
    at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
    at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:259)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:60)
    at com.alibaba.druid.support.http.WebStatFilter.doFilter(WebStatFilter.java:140)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:60)
    at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:60)
    at org.springframework.orm.hibernate4.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:119)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:60)
    at weblogic.servlet.internal.RequestEventsFilter.doFilter(RequestEventsFilter.java:27)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:60)
    at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3739)
    at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3705)
    at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
    at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
    at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2282)
    at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2181)
    at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1491)
    at weblogic.work.ExecuteThread.execute(ExecuteThread.java:256)
    at weblogic.work.ExecuteThread.run(ExecuteThread.java:221)
Caused by: javax.xml.bind.JAXBException: "com.sinosoft.application.interact.webservice.provider.delegate.delegateinterfacade" doesnt contain ObjectFactory.class or jaxb.index
    at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:233)
    at sun.reflect.GeneratedMethodAccessor678.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:128)
    at javax.xml.bind.ContextFinder.find(ContextFinder.java:277)
    at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:372)
    at org.apache.cxf.endpoint.dynamic.DynamicClientFactory.createClient(DynamicClientFactory.java:394)
    ... 75 more

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

风透绣罗衣 2022-01-05 15:29:35

兄弟找到答案了么?能否分享一下?十分感谢

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文