0
votes

This is my first frist question in stackoverflow! WOW :)

I'm losing my hairs on this issue :( I have a simple helloworld-Web Service, and build the warfile and deploy it on tomcat (8.0.35) at localhost. To be clear: I just wrote a class, annotated with @WebService; Then I wrote web.xml and sun-jaxws.xml; I did not do anything else! Is that enough for that class to become a Webservice? Do I miss another step?

Problem: The url: localhost:8080/endpointname/url-pattern does not show me the definition of my Webservice as it is meant in the Link I followd to write the service: http://www.mkyong.com/webservices/jax-ws/deploy-jax-ws-web-services-on-tomcat/. I just get a fat 404 Eror. This ist my buildfile:

<?xml version="1.0" encoding="UTF-8"?>
<project name="test_WS" default="deploy" basedir=".">
<property name="project-name" value="${ant.project.name}" />
<property name="war-file-name" value="${project-name}.war" />
<property name="source-directory" value="src" />
<property name="web-directory" value="WebContent" />
<property name="webinf.dir" value="${web-directory}/WEB-INF" />
<property name="web-xml-file" value="${webinf.dir}/web.xml" />
<property name="build-directory" value="build" />
<property name="shared.deploy.dir" value="C:/1_Entwicklung/datarocket/tomcat-webapps" />
<property name="local.deploy.dir" value="C:/1_Entwicklung/apache-tomcat-8.0.35/webapps" />

<tstamp prefix="build-info">
    <format property="current-date" pattern="dd-MM-yyyy" locale="de" />
    <format property="current-time" pattern="hh:mm:ss a z" locale="de" />
</tstamp>

<!-- Classpath -->
<path id="build.classpath">
    <!-- Jax WS related -->
    <fileset dir="${webinf.dir}/lib/" casesensitive="yes">
      <include name="*.jar"/>
    </fileset>  
</path>

<target name="init">
    <mkdir dir="${webinf.dir}/classes" />
    <mkdir dir="${build-directory}/classes" />
</target>

<!-- deploy -->
<target name="deploy" depends="war">
    <copy file="${build-directory}/${war-file-name}" todir="${local.deploy.dir}" />
    <copy file="${build-directory}/${war-file-name}" todir="${shared.deploy.dir}" />
</target>

<!-- war  -->
<target name="war" depends="build">
    <war warfile="${build-directory}/${war-file-name}" webxml="${web-xml-file}">
        <classes dir="${build-directory}/classes" />
        <fileset dir="${web-directory}">
            <!-- exclude webxml as it is attribute of the war tag -->
            <exclude name="WEB-INF/web.xml" />
        </fileset>
        <manifest>
            <attribute name="Built-On" value="${build-info.current-date}" />
            <attribute name="Built-At" value="${build-info.current-time}" />
        </manifest>
    </war>
</target>   

<target name="build" depends="clean">
    <javac includeantruntime="false" srcdir="${source-directory}" destdir="${build-directory}/classes">
    </javac>
</target>


<!-- clean --> 
 <target name="clean" description="Prepare for clean build">
    <delete dir="${webinf.dir}/classes" />
    <delete dir="${build-directory}" />
    <mkdir dir="${build-directory}" />
    <mkdir dir="${build-directory}/classes" />
</target>
</project>

This is my 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="HalloAPI"
        implementation="saab.javabeans.Hallo"
        url-pattern="/sayhello" >
    </endpoint>
</endpoints>

And this is the API:

@WebService
public interface HalloAPI {
     String sayHello(String name);
}

Why does tomcat say: "HTTP Status 404 - /HalloAPI/sayhello" ? Something wrong or missing concerning publishing? I mean, if I use glassfish-server, it deploys and show me the tester- and wsdl. But with deploying on tomcat... I get 404.

Here is my web.xml:

<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
                    http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<display-name>test_WS</display-name>
<listener>
<listener-class>com.sun.xml.ws.transport.http.servlet.WSServletContextListener</listener-class>
</listener>
<servlet>
<servlet-name>webservicesServlet</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>webservicesServlet</servlet-name>
<url-pattern>/sayhello</url-pattern>
</servlet-mapping>
<session-config>
 <session-timeout>20</session-timeout>
</session-config>
</web-app>

Happy I: I moved the required jaxws jars into web-inf/lib. Now Tomcat does not throw errors on deploy time. But the service vial url still not available. What I know: jaxws-jars in tomcat/lib are confusing the classloader. So I packed them into war. Here is now the deploying protocoll:

07-Jun-2016 15:34:54.149 INFO [localhost-startStop-2] org.apache.catalina.startup.HostConfig.deployWAR Deploying web application archive C:\1_Entwicklung\apache-tomcat-8.0.35\webapps\test_WS.war
07-Jun-2016 15:34:55.371 INFO [localhost-startStop-2] com.sun.xml.ws.transport.http.servlet.WSServletDelegate.<init> WSSERVLET14: Initialisierung von JAX-WS-Servlet
07-Jun-2016 15:34:55.372 INFO [localhost-startStop-2] com.sun.xml.ws.transport.http.servlet.WSServletContextListener.contextInitialized WSSERVLET12: Initialisierung von JAX-WS-Kontext-Listener
07-Jun-2016 15:34:55.373 INFO [localhost-startStop-2] com.sun.xml.ws.transport.http.servlet.WSServletContextListener.contextInitialized WSSERVLET12: Initialisierung von JAX-WS-Kontext-Listener
07-Jun-2016 15:34:55.385 INFO [localhost-startStop-2] org.apache.catalina.startup.HostConfig.deployWAR Deployment of web application archive C:\1_Entwicklung\apache-tomcat-8.0.35\webapps\test_WS.war has finished in 1,236 ms

Problem remains: service not available; status: 404 Thanks in advance for any help.

1
do you see anything in the logs ? and can you also add your web.xml file ? try this link localhost:8080/test_as_WS/sayHellos7vr
But... sayHello is the methodname not the url-pattern.Why shall I try that?saab
I mean lower case localhost:8080/test_as_WS/sayhellos7vr
I get allways the same error. I think there is a step that I dont go through. But I don't know which. How can I ask tomcat to list all webservices registerd?saab
did you server come up ? did you miss copying sun-jaxws xml over ?s7vr

1 Answers

1
votes

Change your com.sun.xml.ws.transport.http.Servlet.WSServlet to com.sun.xml.ws.transport.http.servlet.WSServlet in your web.xml