title: extending SpringBeanAutowiringSupport with GlassFish 3.1
body: <p>I'm trying to expose my web service by extending SpringBeanAutowiringSupport.  I'm using GlassFish 3.1 and Spring 3.0.5.RELEASE.</p>
  
  <p>I'm following the tutorial <a href="http://www.javacodegeeks.com/2010/11/jaxws-with-spring-and-maven-tutorial.html" rel="nofollow">here</a>.</p>
  
  <p>However, <strong>when I go to the URL of my web service I get a ClassCastException.</strong></p>
  
  <p>Any ideas on what I'm missing or doing wrong?</p>
  
  <pre><code>WARNING: StandardWrapperValve[GreetingService]: PWC1382: Allocate exception for servlet GreetingService
  java.lang.ClassCastException: com.service.GreetingServiceEndpoint cannot be cast to javax.servlet.Servlet
      at com.sun.enterprise.web.WebContainer.createServletInstance(WebContainer.java:702)
      at com.sun.enterprise.web.WebModule.createServletInstance(WebModule.java:1958)
      at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1263)
      at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:1070)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:189)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
      at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
      at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
      at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:98)
      at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:91)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:162)
      at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:326)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:227)
      at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:170)
      at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:822)
      at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:719)
      at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1013)
      at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225)
      at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
      at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
      at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
      at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
      at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
      at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
      at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
      at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
      at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
      at java.lang.Thread.run(Thread.java:680)
  </code></pre>
  
  <h2>Endpoint</h2>
  
  <pre><code>@WebService (serviceName="GreetingService")
  public class GreetingServiceEndpoint extends SpringBeanAutowiringSupport {
      @Autowired
      private GreetingService greetingService;
  
      @WebMethod
      public String sayHello () {
          return greetingService.sayHello();
      }
  }
  </code></pre>
  
  <h2>Service</h2>
  
  <pre><code>@Service ("greetingService")
  public class GreetingService {
      public String sayHello () {
          return "Hello from Greeting Service";
      }
  }
  </code></pre>
  
  <h2>web.xml</h2>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
      xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
      id="WebApp_ID" version="3.0" metadata-complete="true"&gt;  
  
      &lt;display-name&gt;Archetype Created Web Application&lt;/display-name&gt;
    &lt;listener&gt;
      &lt;listener-class&gt;org.springframework.web.context.ContextLoaderListener&lt;/listener-class&gt;
    &lt;/listener&gt;
  
    &lt;welcome-file-list&gt;
      &lt;welcome-file&gt;index.jsp&lt;/welcome-file&gt;
    &lt;/welcome-file-list&gt;
  
    &lt;servlet&gt;
      &lt;servlet-name&gt;GreetingService&lt;/servlet-name&gt;
      &lt;servlet-class&gt;com.service.GreetingServiceEndpoint&lt;/servlet-class&gt;
    &lt;/servlet&gt;
    &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;GreetingService&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/GreetingService&lt;/url-pattern&gt;
    &lt;/servlet-mapping&gt;
  &lt;/web-app&gt;
  </code></pre>