users@glassfish.java.net

JAX-WS and Servlet2.4 web.xml

From: <glassfish_at_javadesktop.org>
Date: Tue, 22 Jan 2008 07:23:53 PST

Hi everybody,
I am trying to fine a way to create a JAX-WS package which is portable over JavaEE container. I have created a simple webservice starting from java source below.

package news;
import javax.jws.WebService;
 
@WebService
public class NewsFeed {
   public String[] getLatestHeadline(int numHeadline){
     return new String[]{"Headline1", "Headline2"};
   }
}

I used wsgen(in JDK6)to generate all ws artifacts and my final war package looks like this
WEB-INF/
WEB-INF/classes/
WEB-INF/classes/news/
WEB-INF/classes/news/jaxws/
WEB-INF/classes/news/jaxws/GetLatestHeadline.class
WEB-INF/classes/news/jaxws/GetLatestHeadlineResponse.class
WEB-INF/classes/news/NewsFeed.class
WEB-INF/lib/
wsdl/
wsdl/NewsFeedService_schema1.xsd
wsdl/NewsFeedService.wsdl

There was no web.xml, no webservices.xml or any server specific deployment descriptor. It should be auto-generated from the annotation in NewsFeed class

I deployed the package just like a normal java web application and Sun Java System Application Server 9.1 nicely detected the annotation and report that I had a NewsFeed web application and NewsFeed webservices in my system (It presented on web console).

My problem is that when I add a web.xml to the package and deployed it.

<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">

</web-app>

SJSAS9.1 couldn't detect the annotation; I got only the NewsFeed web application but no web services. I can resolved it by changing the web.xml to use servlet2.5 declaration.

My guess is that servlet annotation(e.g injecting resource to servlet) has been introduced in servlet2.5 so when the container found a web.xml with servlet2.4 declaration somehow it didn't bother to scan for any annotated class. The side effect is that the @WebService hasn't been detected.

I have tried the package with servlet2.4 web.xml with websphere and it worked just fine so I am not sure this is the implementation problem in Sun application server or not.

Are there any part in JAX-WS, JSR181, JSR109 specification or any document state something about how a Java EE container should discover the webservices annotation?

Thanks very much

Chatchai Chailuecha
www.devguli.com
[Message sent by forum member 'chailuecha' (chailuecha)]

http://forums.java.net/jive/thread.jspa?messageID=255161