调用 Soap WS,结果出现 "Couldn't get a SAX parser while constructing a envelope" 错误
Call to a Soap WS, results on "Couldn't get a SAX parser while constructing a envelope" error
在调用 Soap WebService 期间,我们遇到了这个错误。背后的原因可能是什么?
我正在使用 JDK 7 更新 U67(64 位),Spring 3.1.1.RELEASE,Spring WS 2.1.0.RELEASE(spring-ws-core-2.1.0.RELEASE.jar),
这是堆栈跟踪日志:
----- ERROR [7-thread-1] xxxxxxxxxxxxxxxxxxx.webservice.WebServiceCallTemplateImpl:45 An error occured when connecting to service.
org.springframework.ws.soap.saaj.SaajSoapEnvelopeException: Could not access envelope: Couldn't get a SAX parser while constructing a envelope; nested exception is com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: Couldn't get a SAX parser while constructing a envelope
at org.springframework.ws.soap.saaj.SaajSoapMessage.getSaajVersion(SaajSoapMessage.java:260)
at org.springframework.ws.soap.saaj.SaajSoapMessage.getImplementation(SaajSoapMessage.java:342)
at org.springframework.ws.soap.saaj.SaajSoapMessage.<init>(SaajSoapMessage.java:117)
at org.springframework.ws.soap.saaj.SaajSoapMessageFactory.createWebServiceMessage(SaajSoapMessageFactory.java:186)
at org.springframework.ws.soap.saaj.SaajSoapMessageFactory.createWebServiceMessage(SaajSoapMessageFactory.java:60)
at org.springframework.ws.transport.AbstractWebServiceConnection.receive(AbstractWebServiceConnection.java:90)
at org.springframework.ws.client.core.WebServiceTemplate.doSendAndReceive(WebServiceTemplate.java:589)
at org.springframework.ws.client.core.WebServiceTemplate.sendAndReceive(WebServiceTemplate.java:537)
at org.springframework.ws.client.core.WebServiceTemplate.marshalSendAndReceive(WebServiceTemplate.java:384)
at org.springframework.ws.client.core.WebServiceTemplate.marshalSendAndReceive(WebServiceTemplate.java:374)
at com.xxxxxxxxxxx.commons.webservice.WebServiceCallTemplateImpl.sendAndReceive(WebServiceCallTemplateImpl.java:38)
at com.xxxxxxxxxxx.commons.webservice.WebServiceCallTemplateImpl.sendAndReceiveNoError(WebServiceCallTemplateImpl.java:73)
at com.xxxxxxxxxxx.commons.webservice.ServerCallTemplate.sendAndReceiveNoError(ServerCallTemplate.java:61)
at com.xxxxxxxxxxxxxxxxxxxxxxxxxxx.xxxxxxxxxxxxxxxxxxxxxxxClient.readDocument(QaDocumentReaderClient.java:39)
at com.xxxxxxxxxxxxxxxxxxxxxxxxxxx.xxxxxxxxxxxxxxxxxxxxxxxService.readDocument(QaDocumentReadService.java:44)
at com.xxxxxxxxxxxxxxxxxxxxxxxxxxx.xxxxxxxxxxxxxxxxxxxxxxxService$$FastClassByCGLIB$e93444.invoke(<generated>)
at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:191)
at org.springframework.aop.framework.Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint(Cglib2AopProxy.java:689)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:622)
at com.xxxxxxxxxxxxxxxxxxxxxxxxxxx.xxxxxxxxxxxxxxxxxxxxxxxService$$EnhancerByCGLIB$b68ed1.readDocument(<generated>)
at com.xxxxxxxxxxxxxxxxxxxxxxxxxxx.xxxxxxxxxxxxxxxxxxxxxxxRunnable.run(QaDocumentReadRunnable.java:38)
at WICKET_com.xxxxxxxxxxxxxxxxxxxxxxxxxxx.QaDocumentReadRunnable$$FastClassByCGLIB$$ab78176e.invoke(<generated>)
at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:191)
at org.apache.wicket.proxy.LazyInitProxyFactory$CGLibInterceptor.intercept(LazyInitProxyFactory.java:333)
at WICKET_com.xxxxxxxxxxxxxxxxxxxxxxxxxxx.xxxxxxxxxxxxxxxxxxxxxxxRunnable$$EnhancerByCGLIB$e7e20f.run(<generated>)
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.util.concurrent.FutureTask.runAndReset(Unknown Source)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access1(Unknown Source)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: Couldn't get a SAX parser while constructing a envelope
at com.sun.xml.internal.messaging.saaj.soap.EnvelopeFactory.createEnvelope(Unknown Source)
at com.sun.xml.internal.messaging.saaj.soap.ver1_1.SOAPPart1_1Impl.createEnvelopeFromSource(Unknown Source)
at com.sun.xml.internal.messaging.saaj.soap.SOAPPartImpl.getEnvelope(Unknown Source)
at org.springframework.ws.soap.saaj.support.SaajUtils.getSaajVersion(SaajUtils.java:155)
at org.springframework.ws.soap.saaj.SaajSoapMessage.getSaajVersion(SaajSoapMessage.java:257)
... 34 more
Caused by: org.xml.sax.SAXException
java.lang.InterruptedException
at com.sun.xml.internal.messaging.saaj.util.ParserPool.get(Unknown Source)
... 39 more
Caused by: java.lang.InterruptedException
at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireInterruptibly(Unknown Source)
at java.util.concurrent.locks.ReentrantLock.lockInterruptibly(Unknown Source)
at java.util.concurrent.ArrayBlockingQueue.take(Unknown Source)
... 40 more
有没有人遇到同样的问题?
提前致谢。
该错误意味着 SOAP 调用所在的线程 运行 已被中断,堆栈跟踪 (com.sun.xml.internal.messaging.saaj.util.ParserPool#get()
) 中显示的特定方法恰好执行了对中断发生后的可中断方法。由于线程属于线程池,所以这可能是调用了ThreadPoolExecutor
.
的shutdownNow()
方法引起的
确实,shutdownNow() 是此问题背后的根本原因。作为解决方案,shutdownNow() 被 shutdown() 取代,原因如下:
- shutdownNow() 告诉执行服务(ScheduledExecutorService)它不能接受新的任务并尝试通过中断抛出的相关线程来取消已经提交的任务 java.lang.InterruptedException,而方法 shutdown()只会告诉执行服务它不能接受新任务,但是已经提交的任务会继续运行直到结束。
我遇到了这个错误,这是由于我在
中的 运行 方法返回的 ConfigurableApplicationContext
上调用关闭引起的
@SpringBootApplication
public class MyApplication {
public static void main(String[] args) {
SpringApplication.run(MyApplication.class, args).close();
}
}
删除 .close()
使中断消失。
在调用 Soap WebService 期间,我们遇到了这个错误。背后的原因可能是什么?
我正在使用 JDK 7 更新 U67(64 位),Spring 3.1.1.RELEASE,Spring WS 2.1.0.RELEASE(spring-ws-core-2.1.0.RELEASE.jar),
这是堆栈跟踪日志:
----- ERROR [7-thread-1] xxxxxxxxxxxxxxxxxxx.webservice.WebServiceCallTemplateImpl:45 An error occured when connecting to service.
org.springframework.ws.soap.saaj.SaajSoapEnvelopeException: Could not access envelope: Couldn't get a SAX parser while constructing a envelope; nested exception is com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: Couldn't get a SAX parser while constructing a envelope
at org.springframework.ws.soap.saaj.SaajSoapMessage.getSaajVersion(SaajSoapMessage.java:260)
at org.springframework.ws.soap.saaj.SaajSoapMessage.getImplementation(SaajSoapMessage.java:342)
at org.springframework.ws.soap.saaj.SaajSoapMessage.<init>(SaajSoapMessage.java:117)
at org.springframework.ws.soap.saaj.SaajSoapMessageFactory.createWebServiceMessage(SaajSoapMessageFactory.java:186)
at org.springframework.ws.soap.saaj.SaajSoapMessageFactory.createWebServiceMessage(SaajSoapMessageFactory.java:60)
at org.springframework.ws.transport.AbstractWebServiceConnection.receive(AbstractWebServiceConnection.java:90)
at org.springframework.ws.client.core.WebServiceTemplate.doSendAndReceive(WebServiceTemplate.java:589)
at org.springframework.ws.client.core.WebServiceTemplate.sendAndReceive(WebServiceTemplate.java:537)
at org.springframework.ws.client.core.WebServiceTemplate.marshalSendAndReceive(WebServiceTemplate.java:384)
at org.springframework.ws.client.core.WebServiceTemplate.marshalSendAndReceive(WebServiceTemplate.java:374)
at com.xxxxxxxxxxx.commons.webservice.WebServiceCallTemplateImpl.sendAndReceive(WebServiceCallTemplateImpl.java:38)
at com.xxxxxxxxxxx.commons.webservice.WebServiceCallTemplateImpl.sendAndReceiveNoError(WebServiceCallTemplateImpl.java:73)
at com.xxxxxxxxxxx.commons.webservice.ServerCallTemplate.sendAndReceiveNoError(ServerCallTemplate.java:61)
at com.xxxxxxxxxxxxxxxxxxxxxxxxxxx.xxxxxxxxxxxxxxxxxxxxxxxClient.readDocument(QaDocumentReaderClient.java:39)
at com.xxxxxxxxxxxxxxxxxxxxxxxxxxx.xxxxxxxxxxxxxxxxxxxxxxxService.readDocument(QaDocumentReadService.java:44)
at com.xxxxxxxxxxxxxxxxxxxxxxxxxxx.xxxxxxxxxxxxxxxxxxxxxxxService$$FastClassByCGLIB$e93444.invoke(<generated>)
at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:191)
at org.springframework.aop.framework.Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint(Cglib2AopProxy.java:689)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:622)
at com.xxxxxxxxxxxxxxxxxxxxxxxxxxx.xxxxxxxxxxxxxxxxxxxxxxxService$$EnhancerByCGLIB$b68ed1.readDocument(<generated>)
at com.xxxxxxxxxxxxxxxxxxxxxxxxxxx.xxxxxxxxxxxxxxxxxxxxxxxRunnable.run(QaDocumentReadRunnable.java:38)
at WICKET_com.xxxxxxxxxxxxxxxxxxxxxxxxxxx.QaDocumentReadRunnable$$FastClassByCGLIB$$ab78176e.invoke(<generated>)
at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:191)
at org.apache.wicket.proxy.LazyInitProxyFactory$CGLibInterceptor.intercept(LazyInitProxyFactory.java:333)
at WICKET_com.xxxxxxxxxxxxxxxxxxxxxxxxxxx.xxxxxxxxxxxxxxxxxxxxxxxRunnable$$EnhancerByCGLIB$e7e20f.run(<generated>)
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.util.concurrent.FutureTask.runAndReset(Unknown Source)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access1(Unknown Source)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: Couldn't get a SAX parser while constructing a envelope
at com.sun.xml.internal.messaging.saaj.soap.EnvelopeFactory.createEnvelope(Unknown Source)
at com.sun.xml.internal.messaging.saaj.soap.ver1_1.SOAPPart1_1Impl.createEnvelopeFromSource(Unknown Source)
at com.sun.xml.internal.messaging.saaj.soap.SOAPPartImpl.getEnvelope(Unknown Source)
at org.springframework.ws.soap.saaj.support.SaajUtils.getSaajVersion(SaajUtils.java:155)
at org.springframework.ws.soap.saaj.SaajSoapMessage.getSaajVersion(SaajSoapMessage.java:257)
... 34 more
Caused by: org.xml.sax.SAXException
java.lang.InterruptedException
at com.sun.xml.internal.messaging.saaj.util.ParserPool.get(Unknown Source)
... 39 more
Caused by: java.lang.InterruptedException
at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireInterruptibly(Unknown Source)
at java.util.concurrent.locks.ReentrantLock.lockInterruptibly(Unknown Source)
at java.util.concurrent.ArrayBlockingQueue.take(Unknown Source)
... 40 more
有没有人遇到同样的问题?
提前致谢。
该错误意味着 SOAP 调用所在的线程 运行 已被中断,堆栈跟踪 (com.sun.xml.internal.messaging.saaj.util.ParserPool#get()
) 中显示的特定方法恰好执行了对中断发生后的可中断方法。由于线程属于线程池,所以这可能是调用了ThreadPoolExecutor
.
shutdownNow()
方法引起的
确实,shutdownNow() 是此问题背后的根本原因。作为解决方案,shutdownNow() 被 shutdown() 取代,原因如下:
- shutdownNow() 告诉执行服务(ScheduledExecutorService)它不能接受新的任务并尝试通过中断抛出的相关线程来取消已经提交的任务 java.lang.InterruptedException,而方法 shutdown()只会告诉执行服务它不能接受新任务,但是已经提交的任务会继续运行直到结束。
我遇到了这个错误,这是由于我在
中的 运行 方法返回的ConfigurableApplicationContext
上调用关闭引起的
@SpringBootApplication
public class MyApplication {
public static void main(String[] args) {
SpringApplication.run(MyApplication.class, args).close();
}
}
删除 .close()
使中断消失。