gpt4 book ai didi

java - weblogic 服务器中的 CXF Web 服务问题

转载 作者:行者123 更新时间:2023-12-01 09:59:58 25 4
gpt4 key购买 nike

我正在尝试从我的 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

最佳答案

在 weblogic-application.xml 中,您必须将 JAXB 提供程序定义为来自 cxf 的提供程序,而不是来自 sun 引用实现 (com.sun.xml...)。

将以下内容添加到提到的文件中

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

这会导致类加载过程发生逆转。因此,您在 war 中提供的类会先于 weblogic 中的类加载。

编辑:

提供商的文档说:

The algorithm used to locate the provider subclass to use consists of the following steps:

  • If a resource with the name of META-INF/services/javax.xml.ws.spi.Provider exists, then its first
    line, if present, is used as the UTF-8 encoded name of the
    implementation class.
  • If the $java.home/lib/jaxws.properties file exists and it is readable by the java.util.Properties.load(InputStream) method and it
    contains an entry whose key is javax.xml.ws.spi.Provider, then the
    value of that entry is used as the name of the implementation class.
  • If a system property with the name javax.xml.ws.spi.Provider is defined, then its value is used as the name of the implementation
    class.
  • Finally, a default implementation class name is used.

因此,如果更改类加载还不够,请添加以下内容

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

到 weblogic-application.xml

关于java - weblogic 服务器中的 CXF Web 服务问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36885960/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com