3

运行Weblogic 12c的CXF应用程序存在问题。例外情况如下:

org.apache.jcp.xml.dsig.internal.dom.DOMXMLSignatureFactory cannot be cast to javax.xml.crypto.dsig.XMLSignatureFactory

这里有趣的是DOMXMLSignatureFactory扩展了XMLSignatureFactory。我试过调试,没有找到原因。XMLSec-1.5.3代码在以下行失败: XMLSignatureFactory fac = (XMLSignatureFactory)ps.newInstance(null);

private static XMLSignatureFactory findInstance(String mechanismType,
    Provider provider) {

    if (provider == null) {
        provider = getProvider("XMLSignatureFactory", mechanismType);
    }
    Provider.Service ps = provider.getService("XMLSignatureFactory",
                                              mechanismType);
    if (ps == null) {
        throw new NoSuchMechanismException("Cannot find " + mechanismType +
                                           " mechanism type");
    }
    try {
        XMLSignatureFactory fac = (XMLSignatureFactory)ps.newInstance(null);
        fac.mechanismType = mechanismType;
        fac.provider = provider;
        return fac;
    } catch (NoSuchAlgorithmException nsae) {
        throw new NoSuchMechanismException("Cannot find " + mechanismType +
                                           " mechanism type", nsae);
    }
}

实例化类“ org.apache.jcp.xml.dsig.internal.dom.DOMXMLSignatureFactory ”有声明:

public final class DOMXMLSignatureFactory extends XMLSignatureFactory {
...
}

有任何想法吗?

完整的堆栈跟踪:

  org.apache.cxf.interceptor.Fault: org.apache.jcp.xml.dsig.internal.dom.DOMXMLSignatureFactory cannot be cast to javax.xml.crypto.dsig
.XMLSignatureFactory
        at org.apache.cxf.ws.security.wss4j.policyhandlers.AsymmetricBindingHandler.doSignBeforeEncrypt(AsymmetricBindingHandler.java
:195)
        at org.apache.cxf.ws.security.wss4j.policyhandlers.AsymmetricBindingHandler.handleBinding(AsymmetricBindingHandler.java:98)
        at org.apache.cxf.ws.security.wss4j.PolicyBasedWSS4JOutInterceptor$PolicyBasedWSS4JOutInterceptorInternal.handleMessage(Polic
yBasedWSS4JOutInterceptor.java:165)
        at org.apache.cxf.ws.security.wss4j.PolicyBasedWSS4JOutInterceptor$PolicyBasedWSS4JOutInterceptorInternal.handleMessage(Polic
yBasedWSS4JOutInterceptor.java:89)
        at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:271)
        at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:530)
        at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:463)
        at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:366)
        at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:319)
        at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:96)
        at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:133)
        at $Proxy197.getProcessingEventDetails(Unknown Source)
        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.paradase.top.green.hill.client.MiraclesPosterServlet.doPost(MiraclesPosterServlet.java:666)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:751)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:844)
        at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:242)
        at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:216)
        at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:132)
        at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:338)
        at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:221)
        at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3284)
        at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3254)
        at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
        at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
        at weblogic.servlet.provider.WlsSubjectHandle.run(WlsSubjectHandle.java:57)
        at weblogic.servlet.internal.WebAppServletContext.doSecuredExecute(WebAppServletContext.java:2163)
        at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2089)
        at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2074)
        at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1513)
        at weblogic.servlet.provider.ContainerSupportProviderImpl$WlsRequestExecutor.run(ContainerSupportProviderImpl.java:254)
        at weblogic.work.ExecuteThread.execute(ExecuteThread.java:256)
        at weblogic.work.ExecuteThread.run(ExecuteThread.java:221)
Caused by: java.lang.ClassCastException: org.apache.jcp.xml.dsig.internal.dom.DOMXMLSignatureFactory cannot be cast to javax.xml.cryp
to.dsig.XMLSignatureFactory
        at javax.xml.crypto.dsig.XMLSignatureFactory.findInstance(XMLSignatureFactory.java:202)
        at javax.xml.crypto.dsig.XMLSignatureFactory.getInstance(XMLSignatureFactory.java:292)
        at org.apache.ws.security.message.WSSecSignature.init(WSSecSignature.java:126)
        at org.apache.ws.security.message.WSSecSignature.<init>(WSSecSignature.java:119)
        at org.apache.cxf.ws.security.wss4j.policyhandlers.AbstractBindingBuilder.getSignatureBuilder(AbstractBindingBuilder.java:172
3)
        at org.apache.cxf.ws.security.wss4j.policyhandlers.AsymmetricBindingHandler.doSignature(AsymmetricBindingHandler.java:546)
        at org.apache.cxf.ws.security.wss4j.policyhandlers.AsymmetricBindingHandler.doSignBeforeEncrypt(AsymmetricBindingHandler.java
:147)
        ... 35 more
4

1 回答 1

1

CXF 使用 WSS4J 和 wss4j 版本 1.6.7 有这个 bug。您可以尝试升级到 wss4j 1.6.9 吗?CXF 2.7.3 可能会帮您解决这个问题。此更新解决了我在 ServiceMix 4.5.0 中运行的问题。

于 2013-03-27T16:45:00.967 回答