执行规范化时序列化 Timestamp 元素时出错

Error while serializing Timestamp element occured while performing canonicalization

我在 metro 2.1 和 glassfish-server 3.1 中开发了 webservice。 服务器端异常。

[#|2015-01-30T08:00:37.325-

0500|SEVERE|glassfish3.1.1|com.sun.xml.wss.logging.impl.opt|_ThreadID=26;_ThreadName=Thread-2;|WSS1609: Error while serializing Timestamp element|#]

[#|2015-01-30T08:00:37.330-0500|SEVERE|glassfish3.1.1|com.sun.xml.wss.logging.impl.opt.signature|_ThreadID=26;_ThreadName=Thread-2;|WSS1759: Following error com.sun.xml.wss.XWSSecurityException: WSS1609: Error while serializing Timestamp element occured while performing canonicalization com.sun.xml.wss.XWSSecurityException: WSS1609: Error while serializing Timestamp element
javax.xml.crypto.dsig.TransformException: com.sun.xml.wss.XWSSecurityException: WSS1609: Error while serializing Timestamp element
    at com.sun.xml.ws.security.opt.crypto.dsig.Exc14nCanonicalizer.transform(Exc14nCanonicalizer.java:191)
    at com.sun.xml.ws.security.opt.crypto.dsig.Transform.transform(Transform.java:183)
    at com.sun.xml.ws.security.opt.crypto.dsig.Reference.transform(Reference.java:188)
    at com.sun.xml.ws.security.opt.crypto.dsig.Reference.digest(Reference.java:129)
    at com.sun.xml.ws.security.opt.crypto.dsig.Signature.sign(Signature.java:218)
    at com.sun.xml.ws.security.opt.impl.dsig.SignatureProcessor.sign(SignatureProcessor.java:127)
    at com.sun.xml.wss.impl.filter.SignatureFilter.sign(SignatureFilter.java:649)
    at com.sun.xml.wss.impl.filter.SignatureFilter.process(SignatureFilter.java:608)
    at com.sun.xml.wss.impl.HarnessUtil.processWSSPolicy(HarnessUtil.java:99)
    at com.sun.xml.wss.impl.HarnessUtil.processDeep(HarnessUtil.java:278)
    at com.sun.xml.wss.impl.SecurityAnnotator.processMessagePolicy(SecurityAnnotator.java:194)
    at com.sun.xml.wss.impl.SecurityAnnotator.secureMessage(SecurityAnnotator.java:155)
    at com.sun.xml.wss.jaxws.impl.SecurityTubeBase.secureOutboundMessage(SecurityTubeBase.java:386)
    at com.sun.xml.wss.jaxws.impl.SecurityServerTube.processResponse(SecurityServerTube.java:481)
    at com.sun.xml.ws.api.pipe.Fiber.__doRun(Fiber.java:651)
    at com.sun.xml.ws.api.pipe.Fiber._doRun(Fiber.java:600)
    at com.sun.xml.ws.api.pipe.Fiber.doRun(Fiber.java:585)
    at com.sun.xml.ws.api.pipe.Fiber.runSync(Fiber.java:482)
    at com.sun.xml.ws.server.WSEndpointImpl.process(WSEndpointImpl.java:314)
    at com.sun.xml.ws.transport.http.HttpAdapter$HttpToolkit.handle(HttpAdapter.java:608)
    at com.sun.xml.ws.transport.http.HttpAdapter.handle(HttpAdapter.java:259)
    at com.sun.xml.ws.transport.http.servlet.ServletAdapter.invokeAsync(ServletAdapter.java:213)
    at com.sun.xml.ws.transport.http.servlet.WSServletDelegate.doGet(WSServletDelegate.java:159)
    at com.sun.xml.ws.transport.http.servlet.WSServletDelegate.doPost(WSServletDelegate.java:194)
    at com.sun.xml.ws.transport.http.servlet.WSServlet.doPost(WSServlet.java:80)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:754)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
    at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1539)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:343)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217)
    at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:186)
    at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:160)
    at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:343)
    at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:260)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:279)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
    at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
    at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:98)
    at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:91)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:162)
    at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:330)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)
    at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:174)
    at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:828)
    at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:725)
    at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1019)
    at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225)
    at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
    at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
    at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
    at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
    at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
    at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
    at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
    at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
    at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
    at java.lang.Thread.run(Thread.java:662)
Caused by: com.sun.xml.wss.XWSSecurityException: WSS1609: Error while serializing Timestamp element
    at com.sun.xml.ws.security.opt.impl.crypto.JAXBDataImpl.writeTo(JAXBDataImpl.java:126)
    at com.sun.xml.ws.security.opt.crypto.dsig.Exc14nCanonicalizer.transform(Exc14nCanonicalizer.java:185)
    ... 59 more
Caused by: javax.xml.stream.XMLStreamException: javax.xml.bind.JAXBException: Error occurred while setting security marshaller properties
 - with linked exception:
[javax.xml.bind.PropertyException: property "com.sun.xml.bind.namespacePrefixMapper" must be an instance of type com.sun.xml.bind.marshaller.NamespacePrefixMapper, not com.sun.xml.ws.security.opt.impl.util.WSSNamespacePrefixMapper]
    at com.sun.xml.ws.security.opt.impl.tokens.Timestamp.writeTo(Timestamp.java:216)
    at com.sun.xml.ws.security.opt.impl.crypto.JAXBDataImpl.writeTo(JAXBDataImpl.java:123)
    ... 60 more
Caused by: javax.xml.bind.JAXBException: Error occurred while setting security marshaller properties
 - with linked exception:
[javax.xml.bind.PropertyException: property "com.sun.xml.bind.namespacePrefixMapper" must be an instance of type com.sun.xml.bind.marshaller.NamespacePrefixMapper, not com.sun.xml.ws.security.opt.impl.util.WSSNamespacePrefixMapper]
    at com.sun.xml.ws.security.opt.impl.util.JAXBUtil.createMarshaller(JAXBUtil.java:141)
    at com.sun.xml.ws.security.opt.impl.tokens.Timestamp.getMarshaller(Timestamp.java:221)
    at com.sun.xml.ws.security.opt.impl.tokens.Timestamp.writeTo(Timestamp.java:214)
    ... 61 more

客户端会给我如下所示的异常

Web service failed falling back A required header representing a Message Addressing Property is not present
javax.xml.ws.soap.SOAPFaultException: A required header representing a Message Addressing Property is not present
at com.sun.xml.ws.fault.SOAP11Fault.getProtocolException(SOAP11Fault.java:189)
at com.sun.xml.ws.fault.SOAPFaultBuilder.createException(SOAPFaultBuilder.java:122)
at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:119)
at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:89)
at com.sun.xml.ws.client.sei.SEIStub.invoke(SEIStub.java:140)
at $Proxy80.getAllSecretHavingWebServiceAccess(Unknown Source)
at 

问题生成案例: 当我打电话给服务时,我并不是每次都遇到这个问题。但在某些情况下,比如我已经重新启动 glassfish 服务器 10 次,然后它在 10 次中有 9 次运行良好,但它会失败一次,并在服务器和客户端出现上述错误。

问题与 glassfish 3.1 加载 jar 有关,但我没有找到正确的解决方案。

Glassfish 使用 **/glassfish/modules/*-osgi.jar

关于这方面的任何建议对我都有很大帮助。

Jaxb-impl-2.0.1.jar 的 Jar 与 glassfish *-osgi.jar api 冲突。 我已经删除了 Jaxb-impl-2.0.1.jar 并且一直运行良好。

而不是 jaxb-osgi.jar ,我的应用程序正在加载 Jaxb-impl-2.0.1.jar.