users@glassfish.java.net

Re: web.xml for restful jax-ws web service (using HTTPBinding)

From: Bhakti Mehta <Bhakti.Mehta_at_Sun.COM>
Date: Wed, 13 Feb 2008 11:55:03 -0800

We have a similar test and that works for us. Attaching our entry for
web.xml for your reference. Please can you check this web.xml and see if
there is something you are doing different

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

        <description>WebTier for the Restful Service</description>
        <display-name>HelloWAR</display-name>

        <servlet>
                <servlet-name>endpoint.AddNumbersImpl</servlet-name>
                <servlet-class>endpoint.AddNumbersImpl</servlet-class>
                <load-on-startup>0</load-on-startup>
        </servlet>

        <servlet-mapping>
                <servlet-name>endpoint.AddNumbersImpl</servlet-name>
                <url-pattern>/webservice/AddNumbersService</url-pattern>
        </servlet-mapping>
</web-app>

Regards,
Bhakti

Coarr, Matt wrote:
> Hi,
>
> I'm having some trouble with getting a jax-ws RESTful web service up
> and running on glassfish.
>
> My problem is that I created my webservice class and then declare it in
> a "servlet" element via the "servlet-class" element. I then go on to
> create a servlet-mapping. But my problem is that glassfish complains
> that it cannot cast my class to javax.servlet.Servlet.
>
> My code right now is based on the code from this article:
>
> http://weblogs.java.net/blog/kohlert/archive/2006/01/publishing_a_re.ht
> ml
>
> Here' the stack trace:
>
> [#|2008-02-13T11:02:11.869-0500|INFO|sun-appserver9.1|javax.enterprise.
> system.container.web|_ThreadID=17;_ThreadName=httpSSLWorkerThread-8080-
> 1;|PWC1412: WebModule[/alert] ServletContext.log():PWC1409: Marking
> servlet incoming as unavailable|#]
>
> [#|2008-02-13T11:02:11.869-0500|SEVERE|sun-appserver9.1|javax.enterpris
> e.system.container.web|_ThreadID=17;_ThreadName=httpSSLWorkerThread-808
> 0-1;_RequestID=c04894a9-80d6-43a7-bb6e-17aa261e9457;|StandardWrapperVal
> ve[incoming]: PWC1382: Allocate exception for servlet incoming
> java.lang.ClassCastException:
> org.mitre.hotspotting.live.web.SimpleRestService cannot be cast to
> javax.servlet.Servlet
> at
> org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.ja
> va:1132)
> at
> org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:
> 832)
> at
> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperVal
> ve.java:197)
> at
> org.apache.catalina.core.StandardContextValve.invokeInternal(StandardCo
> ntextValve.java:271)
> at
> org.apache.catalina.core.StandardContextValve.invoke(StandardContextVal
> ve.java:202)
> at
> org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.jav
> a:632)
> at
> org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.jav
> a:577)
> at
> com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:94)
> at
> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.jav
> a:206)
> at
> org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.jav
> a:632)
> at
> org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.jav
> a:577)
> at
> org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:
> 571)
> at
> org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1080)
> at
> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve
> .java:150)
> at
> org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.jav
> a:632)
> at
> org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.jav
> a:577)
> at
> org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:
> 571)
> at
> org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1080)
> at
> org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:272)
> at
> com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.invokeAda
> pter(DefaultProcessorTask.java:637)
> at
> com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.doProcess
> (DefaultProcessorTask.java:568)
> at
> com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.process(D
> efaultProcessorTask.java:813)
> at
> com.sun.enterprise.web.connector.grizzly.DefaultReadTask.executeProcess
> orTask(DefaultReadTask.java:341)
> at
> com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(Default
> ReadTask.java:263)
> at
> com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(Default
> ReadTask.java:214)
> at
> com.sun.enterprise.web.portunif.PortUnificationPipeline$PUTask.doTask(P
> ortUnificationPipeline.java:380)
> at
> com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:265
> )
> at
> com.sun.enterprise.web.connector.grizzly.ssl.SSLWorkerThread.run(SSLWor
> kerThread.java:106)
> |#]
>
>
>