2016-04-27 116 views
0

我想從我的web應用程序中調用web服務,它可以很好地與Apache Tomcat或JBoss等服務器一起工作,但在Weblogic服務器中會出現以下異常。weblogic服務器中的CXF Webservice問題

任何解決方案?

java.lang.ExceptionInInitializerError 
     at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) 
     at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) 
     at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) 
     at java.lang.reflect.Constructor.newInstance(Constructor.java:526) 
     at java.lang.Class.newInstance(Class.java:379) 
     at org.apache.geronimo.osgi.locator.ProviderLocator.getService(ProviderLocator.java:234) 
     at javax.xml.ws.spi.FactoryFinder$3.run(FactoryFinder.java:176) 
     at javax.xml.ws.spi.FactoryFinder.doPrivileged(FactoryFinder.java:220) 
     at javax.xml.ws.spi.FactoryFinder.find(FactoryFinder.java:160) 
     at javax.xml.ws.spi.Provider.provider(Provider.java:43) 
     at javax.xml.ws.Service.<init>(Service.java:35) 
     at com.my.Tpackage.imageSign.FIUsbWebServiceService.<init>(FIUsbWebServiceService.java:40) 
     at com.my.Tpackage.imageSign.SignatureWebServiceClient.getWebServiceResponse(SignatureWebServiceClient.java:32) 
     at com.my.Tpackage.imageSign.MyAction.getMySignatureImage(MyAction.java:47) 
     at com.my.Tpackage.imageSign.MyAction.execute(MyAction.java:28) 
     at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484) 
     at com.montran.security.SecureRequestProcessor.processActionPerform(SecureRequestProcessor.java:707) 
     at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274) 
     at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482) 
     at com.montran.main.action.InheritanceActionServet.process(InheritanceActionServet.java:332) 
     at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525) 
     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:56) 
     at com.my.security.ActivityLoggingFilter.doFilter(ActivityLoggingFilter.java:88) 
     at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56) 
     at com.my.security.AuthenticationFilter.doFilter(AuthenticationFilter.java:179) 
     at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56) 
     at com.my.security.InjectionFilter.filter(InjectionFilter.java:453) 
     at com.my.security.InjectionFilter.doFilter(InjectionFilter.java:360) 
     at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56) 
     at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3730) 
     at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3696) 
     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:2273) 
     at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2179) 
     at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1490) 
     at weblogic.work.ExecuteThread.execute(ExecuteThread.java:256) 
     at weblogic.work.ExecuteThread.run(ExecuteThread.java:221) 
Caused by: javax.xml.ws.WebServiceException: Error creating JAXBContext for W3CEndpointReference. 
     at com.sun.xml.ws.spi.ProviderImpl$2.run(ProviderImpl.java:237) 
     at com.sun.xml.ws.spi.ProviderImpl$2.run(ProviderImpl.java:232) 
     at java.security.AccessController.doPrivileged(Native Method) 
     at com.sun.xml.ws.spi.ProviderImpl.getEPRJaxbContext(ProviderImpl.java:232) 
     at com.sun.xml.ws.spi.ProviderImpl.<clinit>(ProviderImpl.java:95) 
     ... 44 more 
Caused by: javax.xml.bind.JAXBException 
- with linked exception: 
[com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions 
org.w3c.dom.Element is an interface, and JAXB can't handle interfaces. 
     this problem is related to the following location: 
       at org.w3c.dom.Element 
       at public java.util.List com.sun.xml.ws.developer.MemberSubmissionEndpointReference$Elements.elements 
       at com.sun.xml.ws.developer.MemberSubmissionEndpointReference$Elements 
       at public com.sun.xml.ws.developer.MemberSubmissionEndpointReference$Elements com.sun.xml.ws.developer.MemberSubmissionEndpointReference.referenceProperties 
       at com.sun.xml.ws.developer.MemberSubmissionEndpointReference 
] 
     at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:263) 
     at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:235) 
     at javax.xml.bind.ContextFinder.find(ContextFinder.java:432) 
     at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:637) 
     at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:584) 
     at com.sun.xml.ws.spi.ProviderImpl$2.run(ProviderImpl.java:235) 
     ... 48 more 
Caused by: com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions 
org.w3c.dom.Element is an interface, and JAXB can't handle interfaces. 
     this problem is related to the following location: 
       at org.w3c.dom.Element 
       at public java.util.List com.sun.xml.ws.developer.MemberSubmissionEndpointReference$Elements.elements 
       at com.sun.xml.ws.developer.MemberSubmissionEndpointReference$Elements 
       at public com.sun.xml.ws.developer.MemberSubmissionEndpointReference$Elements com.sun.xml.ws.developer.MemberSubmissionEndpointReference.referenceProperties 
       at com.sun.xml.ws.developer.MemberSubmissionEndpointReference 

     at com.sun.xml.bind.v2.runtime.IllegalAnnotationsException$Builder.check(IllegalAnnotationsException.java:106) 
     at com.sun.xml.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(JAXBContextImpl.java:466) 
     at com.sun.xml.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:298) 
     at com.sun.xml.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:141) 
     at com.sun.xml.bind.v2.runtime.JAXBContextImpl$JAXBContextBuilder.build(JAXBContextImpl.java:1163) 
     at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:145) 
     at sun.reflect.GeneratedMethodAccessor122.invoke(Unknown Source) 
     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
     at java.lang.reflect.Method.invoke(Method.java:606) 
     at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:248) 
     ... 53 more 
+0

的可能的複製[的WebLogic的clientgen無法從WebLogic配合工作] (http://stackoverflow.com/questions/11283489/weblogic-clientgen-doesnt-work-from-weblogic) – Frank

+0

右弗蘭克,這是類似的問題。什麼依賴清理是必需的,我仍然沒有得到解決方案。 –

回答

1

在你的weblogic-application.xml中,你必須定義JAXB提供者是從CXF的一個沒有太陽的參考實現(了com.sun.xml ...)。

添加以下所提到的文件

<prefer-web-inf-classes>true</prefer-web-inf-classes> 

這導致倒車類加載過程的。因此,您在戰爭中提供的類會在來自weblogic的類之前加載。

編輯:

的提供程序的文檔說:

用於定位提供商子類使用該算法包含 以下步驟:

  • 如果資源用META-INF/services/javax.xml.ws.spi.Provider這個名字存在,那麼它的第一行
    一行,如果存在,則用作實現類的UTF-8編碼名稱。
  • 如果$ java.home/LIB/jaxws.properties文件存在,並且它是可讀的由java.util.Properties.load(InputStream的)方法,它
    包含其鍵是javax.xml.ws一個條目。 spi.Provider,那麼該條目的值將被用作實現類的名稱。
  • 如果定義了名稱爲javax.xml.ws.spi.Provider的系統屬性,則其值將用作類的實現名稱
    類。
  • 最後,使用默認實現類名稱。

所以,如果改變了類加載不夠添加以下

<prefer-application-resources> 
    <resource-name>META-INF/services/javax.xml.ws.spi.Provider</resource-name> 
</prefer-application-resources> 

到Weblogic-application.xml中

+0

已經存在這個。 –

+0

用Provider-API-doc的提示更新了我的答案 – Frank

+0

它不起作用 –