2

We have a web service that worked on Glassfish 3.0.1 that now does not work anymore when migrated to Glassfish 3.1.2. On deploying to Glassfish 3.1.2 we are getting the following stacktrace :

[#|2015-02-10T20:11:45.203+0200|SEVERE|glassfish3.1.2|javax.enterprise.system.tools.deployment.org.glassfish.deployment.common|_ThreadID=91;_ThreadName=admin-thread-pool-4848(2);|Exception while invoking class com.sun.enterprise.web.WebApplication start method
java.lang.Exception: java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: org.apache.catalina.LifecycleException: java.lang.ClassCastException: com.visionoss.api.webservice.UcFulfillmentWebService cannot be cast to javax.servlet.Servlet
    at com.sun.enterprise.web.WebApplication.start(WebApplication.java:138)
    at org.glassfish.internal.data.EngineRef.start(EngineRef.java:130)
    at org.glassfish.internal.data.ModuleInfo.start(ModuleInfo.java:269)
    at org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:301)
    at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:461)
    at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:240)
    at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:389)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$1.execute(CommandRunnerImpl.java:348)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:363)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1085)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1200(CommandRunnerImpl.java:95)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1291)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1259)
    at com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:461)
    at com.sun.enterprise.v3.admin.AdminAdapter.service(AdminAdapter.java:212)
    at com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:179)
    at com.sun.enterprise.v3.server.HK2Dispatcher.dispath(HK2Dispatcher.java:117)
    at com.sun.enterprise.v3.services.impl.ContainerMapper$Hk2DispatcherCallable.call(ContainerMapper.java:354)
    at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:195)
    at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:849)
    at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:746)
    at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1045)
    at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:228)
    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:745)

The web.xml looks like this

  <servlet>
    <servlet-name>UcFulfillmentWebService</servlet-name>
    <servlet-class>com.visionoss.api.webservice.UcFulfillmentWebService</servlet-class>
    <load-on-startup>1</load-on-startup>
  </servlet>
  <servlet>
    <servlet-name>AsyncNotificationWebService</servlet-name>
    <servlet-class>com.visionoss.api.webservice.AsyncNotificationWebService</servlet-class>
    <load-on-startup>1</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>UcFulfillmentWebService</servlet-name>
    <url-pattern>/ucFulfillment</url-pattern>
  </servlet-mapping>
  <servlet-mapping>
    <servlet-name>AsyncNotificationWebService</servlet-name>
    <url-pattern>/asyncNotification</url-pattern>
  </servlet-mapping>
  <listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  </listener>
  <listener>
    <listener-class>com.sun.xml.ws.transport.http.servlet.WSServletContextListener</listener-class>
  </listener>

The java class definition is as follows

@WebService(serviceName = "ucFulfillment",
            portName = "ucFulfillmentSoapPort",
            endpointInterface = "com.visionoss.api.webservice.v8_1.ucfulfillment.UcFulfillment",
            targetNamespace = "http://webservice.api.visionoss.com/v8_1/ucFulfillment/",
            wsdlLocation = "WEB-INF/wsdl/UcFulfillment/ucFulfillment.wsdl")
@SchemaValidation
public class UcFulfillmentWebService extends SpringBeanAutowiringSupport implements UcFulfillment {

    private static final String SERVICE_NAME = "ucFulfillment";

    @Resource
    private WebServiceContext ctx;

    @Autowired
    private ICustomerService customerService;
    private ICustomerService getCustomerService() {
        return customerService;
    }

It will sincerely be appreciated if anyone can help on this issue.

jako
  • 21
  • 1
  • Is [this](https://stackoverflow.com/questions/23631698/webappinitializer-cannot-be-cast-to-javax-servlet-servletcontainerinitializer) relevant? I realize the error message is not a perfect match, but maybe it will get you somewhere. I see that you're also using Spring. – DavidS Feb 10 '15 at 19:05
  • Thank you for helping. I had a look at that post. The removal of ServletContainerInitializer did not work at all ... the most relevant sentence that I could retrieve was the following : 'So you might have some classpath and dependency conflicts here', but I have still no idea which dependencies, libraries or classpath it will be. – jako Feb 12 '15 at 07:27
  • Hi Jako. I don't actually know enough to help, but I did find this blog post which sounds similar: [java.lang.ClassCastException: (ServletName) cannot be cast to javax.servlet.Servlet](http://wwooddyy.blogspot.ca/2012/08/javalangclasscastexception-servletname.html). The blog post is too terse to be truly useful, but it also points to a library problem. There's also this SO post: [ServletDispatcher cannot be cast to Javax.servlet.Servlet exception in my spring project](http://stackoverflow.com/a/11704118/201891). I suggest you post your pom.xml or dependency list. – DavidS Feb 12 '15 at 21:45
  • Hi David, thanks again. I have seen those two posts (or solutions to the problem), but these web services are almost legacy code and the developers that designed and coded it never made use of Maven or any project management tool that keep a dependency list, hence there is no pom.xml or any other such file. – jako Feb 13 '15 at 06:23

0 Answers0