Prinu Philip
Prinu Philip

Reputation: 189

Error in spring mvc deploying in IBM websphere.Error 404: SRVE0201E: Servlet [org.springframework.web.servlet.DispatcherServlet]: not a servlet class

<?xml version="1.0" encoding="UTF-8"?>
<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">

  <servlet>
  <servlet-name>spring</servlet-name>
  <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
  </servlet>
  <servlet-mapping>
  <servlet-name>spring</servlet-name>
  <url-pattern>/</url-pattern>
  </servlet-mapping>

</web-app>

Above code is my web.xml.After deploying, I am getting

Error 404: SRVE0201E: Servlet[org.springframework.web.servlet.DispatcherServlet]: not a servlet class.

Is there any extra code needed in web.xml? How to fix this issue?

Upvotes: 1

Views: 595

Answers (1)

Jarid
Jarid

Reputation: 2018

This often represents a packaging issue - the "not a servlet class" can indicate a cast failure (you might have an FFDC log with a ClassCastException), and in many cases, it can be caused by packaging the Servlet API in your application and running with "parent last" class loading. When that happens, your servlet links to its own copy of the API, but WebSphere links to its own version, and the JVM can't cast two copies of a class loaded by separate class loaders (even if they're identical).

If you have the Servlet API in your app, remove it, because there's no way to "bring your own" for that API. You may also want to consider whether you actually NEED to be running with "parent last" - if you're not trying to bring, say, your own web services provider or JSF implementation, you probably don't need it.

Upvotes: 2

Related Questions