0

我正在尝试从我的 web 应用程序调用 web 服务,该应用程序可以与 Apache Tomcat 或 JBoss 等服务器正常工作,但在 Weblogic 服务器中失败并出现以下异常。

有什么解决方案吗?

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
4

1 回答 1

1

在您的 weblogic-application.xml 中,您必须将您的 JAXB 提供者定义为来自 cxf 而不是 sun 参考实现 (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

于 2016-04-27T13:24:03.847 回答