java 使用 CXF 捕获 Web 服务异常:NoClassDefFoundError: SOAPFaultBuilder
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1494738/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Catching webservice exception with CXF: NoClassDefFoundError: SOAPFaultBuilder
提问by Tim
I've been using Apache CXF wsdl2java generated code to call methods from a webservice for some time now, which so far has been working fine.. The problem I'm having is that when the webservice (implemented just down the hall from me) legitimately throws a soap exception, CXF comes up with the following Error message:
一段时间以来,我一直在使用 Apache CXF wsdl2java 生成的代码来调用 Web 服务中的方法,到目前为止,它一直工作正常。合法地抛出一个肥皂异常,CXF 提出以下错误消息:
Could not initialize class com.sun.xml.internal.ws.fault.SOAPFaultBuilder
无法初始化类 com.sun.xml.internal.ws.fault.SOAPFaultBuilder
I'm using Ubuntu 9.04, OpenJDK (IcedTea6 1.4.1) 6b14-1.1.1-0ubuntu11, Maven2 and CXF 2.2.3. I'm currently at a loss about how to resolve this problem, as the code and setup I'm using seems trivially simple.. Anyone able to point me in the right direction here? Let me know if I can post any further details..
我使用的是 Ubuntu 9.04、OpenJDK (IcedTea6 1.4.1) 6b14-1.1.1-0ubuntu11、Maven2 和 CXF 2.2.3。我目前不知道如何解决这个问题,因为我使用的代码和设置似乎非常简单.. 任何人都可以在这里指出正确的方向?如果我可以发布更多详细信息,请告诉我..
This is the full stacktrace returned:
这是返回的完整堆栈跟踪:
java.lang.NoClassDefFoundError: Could not initialize class com.sun.xml.internal.ws.fault.SOAPFaultBuilder
at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:107)
at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:78)
at com.sun.xml.internal.ws.client.sei.SEIStub.invoke(SEIStub.java:107)
at $Proxy36.downloadPDB(Unknown Source)
at path.to.my.code.downloadInvalidFileID(SingleMethodTest.java:64)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
at org.junit.internal.runners.TestMethod.invoke(TestMethod.java:59)
at org.junit.internal.runners.MethodRoadie.runTestMethod(MethodRoadie.java:98)
at org.junit.internal.runners.MethodRoadie.run(MethodRoadie.java:79)
at org.junit.internal.runners.MethodRoadie.runBeforesThenTestThenAfters(MethodRoadie.java:87)
at org.junit.internal.runners.MethodRoadie.runTest(MethodRoadie.java:77)
at org.junit.internal.runners.MethodRoadie.run(MethodRoadie.java:42)
at org.junit.internal.runners.JUnit4ClassRunner.invokeTestMethod(JUnit4ClassRunner.java:88)
at org.junit.internal.runners.JUnit4ClassRunner.runMethods(JUnit4ClassRunner.java:51)
at org.junit.internal.runners.JUnit4ClassRunner.run(JUnit4ClassRunner.java:44)
at org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:27)
at org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:37)
at org.junit.internal.runners.JUnit4ClassRunner.run(JUnit4ClassRunner.java:42)
at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:62)
at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:140)
at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:127)
at org.apache.maven.surefire.Surefire.run(Surefire.java:177)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:338)
at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:997)
采纳答案by Daniel Kulp
There are two interesting things about that stack trace:
该堆栈跟踪有两件有趣的事情:
1) It is having problems finding an SAAJ implementation. Probably adding saaj-impl.jar to the classpath might resolve that.
1) 在寻找 SAAJ 实现时遇到问题。可能将 saaj-impl.jar 添加到类路径可能会解决这个问题。
2) It's not using CXF at all. It's using the Sun JAX-WS reference implementation that's built into the jre. Thus, it looks like the cxf jars aren't being picked up at all.
2)它根本不使用CXF。它使用内置于 jre 中的 Sun JAX-WS 参考实现。因此,看起来 cxf 罐子根本没有被捡起。
回答by ignatalexeyenko
Had similar problem when we're switching from Ant to Maven. We use Sun JDK 1.6u20.
当我们从 Ant 切换到 Maven 时遇到了类似的问题。我们使用 Sun JDK 1.6u20。
We've missed these libraries in maven-assembled war's:
我们在 maven-assembled war 中错过了这些库:
jaxws-api jaxws-rt jaxws-tools
jaxws-api jaxws-rt jaxws-tools
After adding them all works as it had worked before. Hope this will help someone!
添加它们后,所有工作都像以前一样工作。希望这会帮助某人!

