2

Tomcat を使用して単純な Java Web サービスを公開しようとしています。以下のスクリーンショットを参照すると、サービス インターフェイスであるHelloWorld.javaとそのHelloWorldImpl.java実装クラスがあります。

また、 web.xmlsun-jaxws.xmlを作成しました。

プロジェクトを右クリックしてRun Asを選択し、次にRun on Serverを選択すると、スクリーンショットの下部に示すように 404 エラー メッセージが表示されます。

内部ブラウ​​ザが到達しようとする URL は、プロジェクト名のhttp://localhost:8081/MySqlConnect/場所です。ポート番号としてMySqlConnect使用していることに注意してください。8081

も試しhttp://localhost:8081/HelloWorld/helloましたが、うまくいきませんでした。

以下のすべてのファイルのコードも提供しました。

どこが間違っているのか理解できませんか?どんな助けでも感謝します。

スクリーンショット


HelloWorldImpl.java

package com.mycompany.service;
import javax.jws.WebService;
@WebService(endpointInterface = "com.mycompany.service.HelloWorld", serviceName = "HelloWorld")
public class HelloWorldImpl implements HelloWorld {

    @Override
    public String sayGreeting(String name) {

        return "Greeting " + name + "!";
    }
}

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, 
Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/j2ee/dtds/web-app_2_3.dtd">

<web-app>
    <listener>
        <listener-class>
            com.sun.xml.ws.transport.http.servlet.WSServletContextListener
        </listener-class>
    </listener>
    <servlet>
        <servlet-name>hello</servlet-name>
        <servlet-class>
            com.sun.xml.ws.transport.http.servlet.WSServlet
        </servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>hello</servlet-name>
        <url-pattern>/hello</url-pattern>
    </servlet-mapping>
    <session-config>
        <session-timeout>120</session-timeout>
    </session-config>
</web-app>

sun-jaxws.xml

<?xml version="1.0" encoding="UTF-8"?>
<endpoints xmlns="http://java.sun.com/xml/ns/jax-ws/ri/runtime"
    version="2.0">
    <endpoint name="HelloWorld" implementation="com.mycompany.service.HelloWorldImpl"
        url-pattern="/hello" />
</endpoints>

編集 1

丸太猫

INFO: Starting Servlet Engine: Apache Tomcat/7.0.33
 com.sun.xml.ws.transport.http.servlet.WSServletContextListener parseAdaptersAndCreateDelegate
SEVERE: WSSERVLET11: failed to parse runtime descriptor: java.lang.NoClassDefFoundError: javax/xml/ws/soap/AddressingFeature$Responses
java.lang.NoClassDefFoundError: javax/xml/ws/soap/AddressingFeature$Responses
Caused by: java.lang.ClassNotFoundException: javax.xml.ws.soap.AddressingFeature$Responses

編集 2

hereで提案されているように、すべてのライブラリをダウンロードして tomcat lib フォルダーに配置しましたが、ログに次のエラーが表示されます。

com.sun.xml.ws.transport.http.servlet.WSServletContextListener parseAdaptersAndCreateDelegate
SEVERE: WSSERVLET11: failed to parse runtime descriptor: java.lang.NoSuchMethodError: com.sun.xml.ws.assembler.TubelineAssemblyController: method <init>()V not found
java.lang.NoSuchMethodError: com.sun.xml.ws.assembler.TubelineAssemblyController: method <init>()V not found

すべてのライブラリをプロジェクトに追加してから実行しようとすると、次のエラーが発生します。

com.sun.xml.ws.transport.http.servlet.WSServletContextListener parseAdaptersAndCreateDelegate
SEVERE: WSSERVLET11: failed to parse runtime descriptor: com.sun.xml.ws.util.ServiceConfigurationError: com.sun.xml.ws.policy.jaxws.spi.PolicyFeatureConfigurator: Provider com.sun.xml.ws.transport.tcp.policy.TCPTransportFeatureConfigurator is specified in jar:file:/C:/Apache-Tomcat-7/lib/webservices-rt-2.1-b16.jar!/META-INF/services/com.sun.xml.ws.policy.jaxws.spi.PolicyFeatureConfiguratorbut could not be instantiated: java.lang.ClassCastException
com.sun.xml.ws.util.ServiceConfigurationError: com.sun.xml.ws.policy.jaxws.spi.PolicyFeatureConfigurator: Provider com.sun.xml.ws.transport.tcp.policy.TCPTransportFeatureConfigurator is specified in jar:file:/C:/Apache-Tomcat-7/lib/webservices-rt-2.1-b16.jar!/META-INF/services/com.sun.xml.ws.policy.jaxws.spi.PolicyFeatureConfiguratorbut could not be instantiated: java.lang.ClassCastException

これに注意してください: com.sun.xml.ws.policy.jaxws.spi.PolicyFeatureConfiguratorbut をインスタンス化できませんでした: java.lang.ClassCastException

4

1 に答える 1