【问题标题】:Axis2 error when generating wsdl生成 wsdl 时出现 Axis2 错误
【发布时间】:2012-06-26 10:59:29
【问题描述】:

我正在尝试使用 JAX-WS 和 JAXB 注释开发新的 Web 服务。 当我在axis2中部署.jar并打开浏览器以检索生成的.wsdl时,出现以下错误:

[ERROR] Error occurred generating WSDL file for Web service implementation class {foo.bar.myServiceImpl}
java.lang.NoClassDefFoundError: com/sun/xml/ws/api/server/Container
        at java.lang.Class.getDeclaredMethods0(Native Method)
        at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
        at java.lang.Class.getMethod0(Unknown Source)
        at java.lang.Class.getMethod(Unknown Source)
        at org.apache.axis2.jaxws.description.builder.JAXWSRIWSDLGenerator.generateWsdl(JAXWSRIWSDLGenerator.java:179)
        at org.apache.axis2.jaxws.description.builder.JAXWSRIWSDLGenerator.initialize(JAXWSRIWSDLGenerator.java:390)
        at org.apache.axis2.jaxws.description.builder.JAXWSRIWSDLGenerator.getWSDL(JAXWSRIWSDLGenerator.java:383)
        at org.apache.axis2.description.AxisService.printWSDL(AxisService.java:1394)
        at org.apache.axis2.transport.http.HTTPWorker.service(HTTPWorker.java:154)
        at org.apache.axis2.transport.http.server.AxisHttpService.doService(AxisHttpService.java:281)
        at org.apache.axis2.transport.http.server.AxisHttpService.handleRequest(AxisHttpService.java:187)
        at org.apache.axis2.transport.http.server.HttpServiceProcessor.run(HttpServiceProcessor.java:82)
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
        at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: com.sun.xml.ws.api.server.Container
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        ... 15 more

挖掘源代码,我注意到 com.sun.xml.ws.api.server.Container 是 jaxws-rt 实现的一部分,它不是 Axis2 发行版的一部分(在 / lib/ 文件夹)。为什么是这样?我在这里漏掉了一点吗?

【问题讨论】:

    标签: wsdl jax-ws axis2


    【解决方案1】:

    我遇到了同样的问题。我需要向 jaxws-maven-plugin 添加依赖项。没有这些依赖,它会抛出同样的错误

            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>jaxws-maven-plugin</artifactId>
                <configuration>
                    <wsdlDirectory>src/main/resources/wsdl/</wsdlDirectory>
                    <keep>true</keep>
                    <sourceDestDir>${project.build.directory}/generated-sources/wsimport</sourceDestDir>
                    <sei></sei>
                </configuration>
                <dependencies>
                    <dependency>
                        <groupId>com.sun.xml.ws</groupId>
                        <artifactId>jaxws-rt</artifactId>
                        <version>2.1.4</version>
                    </dependency>
                    <dependency>
                        <groupId>com.sun.xml.ws</groupId>
                        <artifactId>jaxws-tools</artifactId> 
                        <version>2.1.4</version>
                    </dependency>
                </dependencies>
                <executions>
                    <execution>
                        <id>generate-from-wsdl</id>
                        <goals>
                            <goal>wsimport</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
    

    【讨论】:

      【解决方案2】:

      好的,知道了。 我会发布答案以避免其他人将他(或她)的头撞到墙上。

      我的系统上设置了旧的 JAVA_HOME 环境变量。这指向安装程序 JRE,但它需要指向已安装的 JDK。就是这样。

      【讨论】:

      • 您能否将此标记为已接受的答案,这样它就不会继续显示为未回答的问题?
      • 我很乐意,但我需要根据 stackoverflow 再等 21 小时。
      • @Bjarne77 我有同样的错误,但我不知道这如何解决我的问题,因为在我的 java home 中我有 java 13 jdk。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-12-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-11-06
      相关资源
      最近更新 更多