使用 CXF 捕获 Web 服务异常:NoClassDefFoundError:SOAPFaultBuilder

发布于 2024-08-06 08:03:35 字数 3073 浏览 8 评论 0原文

我已经使用 Apache CXF wsdl2java 生成的代码来调用 Web 服务的方法有一段时间了,到目前为止一直工作正常。我遇到的问题是,当 Web 服务(在我的大厅下实现)时合法地抛出一个soap异常,CXF会出现以下错误消息:

无法初始化类 com.sun.xml.internal.ws.fault.SOAPFaultBuilder

我正在使用 Ubuntu 9.04、OpenJDK (IcedTea6 1.4.1) 6b14-1.1.1-0ubuntu11、Maven2 和 CXF 2.2.3。我目前不知道如何解决这个问题,因为我使用的代码和设置似乎非常简单。任何人都能够在这里指出正确的方向吗?如果我可以发布任何进一步的详细信息,请告诉我。

这是返回的完整堆栈跟踪:

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$2.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$1.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)

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:

Could not initialize class 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..

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$2.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$1.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)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

新一帅帅 2024-08-13 08:03:35

当我们从 Ant 切换到 Maven 时遇到了类似的问题。我们使用Sun JDK 1.6u20。

我们在 maven 组装的战争中错过了这些库:

jaxws-api
jaxws-rt
jaxws-tools

添加它们后,一切都像以前一样工作。希望这会对某人有所帮助!

Had similar problem when we're switching from Ant to Maven. We use Sun JDK 1.6u20.

We've missed these libraries in maven-assembled war's:

jaxws-api
jaxws-rt
jaxws-tools

After adding them all works as it had worked before. Hope this will help someone!

为你拒绝所有暧昧 2024-08-13 08:03:35

该堆栈跟踪有两件有趣的事情:

1) 查找 SAAJ 实现时遇到问题。也许将 saaj-impl.jar 添加到类路径中可能会解决这个问题。

2)它根本不使用CXF。它使用内置于 jre 中的 Sun JAX-WS 参考实现。因此,看起来 cxf jar 根本没有被拾取。

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.

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文