【问题标题】:Error when trying to use a hello word webservice : ClassNotFoundException: org.apache.axis2.databinding.ADBException尝试使用 hello word webservice 时出错:ClassNotFoundException: org.apache.axis2.databinding.ADBException
【发布时间】:2020-08-18 05:30:30
【问题描述】:

从现在起 2-3 天后我遇到了一个错误,所以我有一个axis2 项目,我正在尝试在服务器端使用以下网络服务:

HelloService.java

public class HelloService {

public String sayHelloWorldFrom(String from) {
    String result = "Hello, world, from " + from;
    System.out.println(result);
    return result;
    }
}

这是我生成的 wsdl

<?xml version="1.0" encoding="UTF-8"?><wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:ns="http://hello.org" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ns1="http://org.apache.axis2/xsd" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" targetNamespace="http://hello.org">
<wsdl:documentation>HelloService</wsdl:documentation>
<wsdl:types>
    <xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://hello.org">
        <xs:element name="sayHelloWorldFrom">
            <xs:complexType>
                <xs:sequence>
                    <xs:element minOccurs="0" name="from" nillable="true" type="xs:string"/>
                </xs:sequence>
            </xs:complexType>
        </xs:element>
        <xs:element name="sayHelloWorldFromResponse">
            <xs:complexType>
                <xs:sequence>
                    <xs:element minOccurs="0" name="return" nillable="true" type="xs:string"/>
                </xs:sequence>
            </xs:complexType>
        </xs:element>
    </xs:schema>
</wsdl:types>
<wsdl:message name="sayHelloWorldFromRequest">
    <wsdl:part name="parameters" element="ns:sayHelloWorldFrom"/>
</wsdl:message>
<wsdl:message name="sayHelloWorldFromResponse">
    <wsdl:part name="parameters" element="ns:sayHelloWorldFromResponse"/>
</wsdl:message>
<wsdl:portType name="HelloServicePortType">
    <wsdl:operation name="sayHelloWorldFrom">
        <wsdl:input message="ns:sayHelloWorldFromRequest" wsaw:Action="urn:sayHelloWorldFrom"/>
        <wsdl:output message="ns:sayHelloWorldFromResponse" wsaw:Action="urn:sayHelloWorldFromResponse"/>
    </wsdl:operation>
</wsdl:portType>
<wsdl:binding name="HelloServiceSoap11Binding" type="ns:HelloServicePortType">
    <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
    <wsdl:operation name="sayHelloWorldFrom">
        <soap:operation soapAction="urn:sayHelloWorldFrom" style="document"/>
        <wsdl:input>
            <soap:body use="literal"/>
        </wsdl:input>
        <wsdl:output>
            <soap:body use="literal"/>
        </wsdl:output>
    </wsdl:operation>
</wsdl:binding>
<wsdl:binding name="HelloServiceSoap12Binding" type="ns:HelloServicePortType">
    <soap12:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
    <wsdl:operation name="sayHelloWorldFrom">
        <soap12:operation soapAction="urn:sayHelloWorldFrom" style="document"/>
        <wsdl:input>
            <soap12:body use="literal"/>
        </wsdl:input>
        <wsdl:output>
            <soap12:body use="literal"/>
        </wsdl:output>
    </wsdl:operation>
</wsdl:binding>
<wsdl:binding name="HelloServiceHttpBinding" type="ns:HelloServicePortType">
    <http:binding verb="POST"/>
    <wsdl:operation name="sayHelloWorldFrom">
        <http:operation location="sayHelloWorldFrom"/>
        <wsdl:input>
            <mime:content type="application/xml" part="parameters"/>
        </wsdl:input>
        <wsdl:output>
            <mime:content type="application/xml" part="parameters"/>
        </wsdl:output>
    </wsdl:operation>
</wsdl:binding>
<wsdl:service name="HelloService">
    <wsdl:port name="HelloServiceHttpSoap11Endpoint" binding="ns:HelloServiceSoap11Binding">
        <soap:address location="http://localhost:8080/Server_war_exploded/services/HelloService.HelloServiceHttpSoap11Endpoint/"/>
    </wsdl:port>
    <wsdl:port name="HelloServiceHttpSoap12Endpoint" binding="ns:HelloServiceSoap12Binding">
        <soap12:address location="http://localhost:8080/Server_war_exploded/services/HelloService.HelloServiceHttpSoap12Endpoint/"/>
    </wsdl:port>
    <wsdl:port name="HelloServiceHttpEndpoint" binding="ns:HelloServiceHttpBinding">
        <http:address location="http://localhost:8080/Server_war_exploded/services/HelloService.HelloServiceHttpEndpoint/"/>
    </wsdl:port>
</wsdl:service>

但是当我尝试从客户端使用 hello world 服务时,我遇到了以下错误

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/axis2/databinding/ADBException
at org.hello.HelloService.main(HelloService.java:10)
Caused by: java.lang.ClassNotFoundException: org.apache.axis2.databinding.ADBException
at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:355)
at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
... 1 more

Process finished with exit code 1

正如您在 HelloService.java 中看到的那样,我不使用下颚 xs 注释,因为 Tomcat 服务器无法识别注释

感谢您的帮助。

//编辑:05/05/2020 我正在使用 maven,并且模块中已经添加了axis2 jar:

【问题讨论】:

标签: xml tomcat intellij-idea axis2


【解决方案1】:

某些依赖项是使用提供的范围定义的,它不会在运行时自动添加。

解决方案是更改pom.xmlchange the Run/Debug configuration to include the dependencies with the provided scope in runtime 中的依赖关系范围。

【讨论】:

    猜你喜欢
    • 2013-04-20
    • 2016-06-10
    • 1970-01-01
    • 2014-11-28
    • 2022-01-22
    • 2020-07-21
    • 1970-01-01
    • 1970-01-01
    • 2020-04-17
    相关资源
    最近更新 更多