Link to home
Start Free TrialLog in
Avatar of kalyankondurie
kalyankondurie

asked on

servlet mapping in web.xml in tomcat 5.5.7

Hi all, I am new to Tomcat 5.5.7. I have a small web application which will have JSPs, HTMLs, Servlets.

I have created a directory structure in webapps for my application as Webapps /IMS(IMS is the name of my application)--here i put jsps and html files of my application -->/WEB-INF-- here i put web.xml and two folders -->/Classes-- here i put classes(servlets) for my application which will have some connection to mysql -->/lib--iput jar file for mysql connectivity

The issue now is when i tried to connect to server using http://localhost:8080/IMS, the default home page is appeared but after i tried to post the data from index.html to the servlet ValidateUser...it is throwing an error



type Exception report

message description The server encountered an internal error () that prevented it from fulfilling this request.

exception javax.servlet.ServletException: Wrapper cannot find servlet class ValidateUser or a class it depends on org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105) org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148) org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:825) org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:738) org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:526) org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80) org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684) java.lang.Thread.run(Thread.java:595)


root cause java.lang.ClassNotFoundException: ValidateUser org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1332) org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1181) org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105) org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148) org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:825) org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:738) org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:526) org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80) org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684) java.lang.Thread.run(Thread.java:595)

I have put the servlet mapping even in web.xml. Can any one help me out in this? I didnt change any of the other files on the server.

Thanks in Advance
Kalyan.
Avatar of arun99907
arun99907

Two ways:

1. One is using invoker servlet. Which maps to any general servlets.

Add the following as it is and rest all goes fine with all the servlets :

      <servlet>
        <servlet-name>invoker</servlet-name>
        <servlet-class>
          org.apache.catalina.servlets.InvokerServlet
        </servlet-class>
        <init-param>
            <param-name>debug</param-name>
            <param-value>0</param-value>
        </init-param>
        <load-on-startup>2</load-on-startup>
      </servlet>
      <servlet-mapping id="ServletMapping_1">
        <servlet-name>invoker</servlet-name>
        <url-pattern>/servlet/*</url-pattern>
      </servlet-mapping>  

here

http://localhost:8080/AppName/servlet/servlet1_name


2. Add servlet mapping for Each servlet.

      <servlet id="S4">
         <servlet-name>Servlet1</servlet-name>
         <servlet-class>servlet1_name</servlet-class>    /// ->> note if you are compiling servlets directly into classes folder.
       </servlet>                                                         /// remove these comments. If you are putting them in another  
                                                                              /// folder /classes/folder put it as folder.servlet1_name
      <servlet-mapping id="SM4">
         <servlet-name>servlet1</servlet-name>
         <url-pattern>/servlet/*</url-pattern>
      </servlet-mapping>

If you keep the mapping like this then call your servlet like this:

http://localhost:8080/AppName/servlet/servlet1_name



Avatar of kalyankondurie

ASKER

Hi,

Thanx for your reply. I tried with Invoker method first...but things are pretty same...
the second one..already I made a mapping but no result.....

I couldnot sort it out..it's giving the same error.........
even i tried with

<servlet>
      <servlet-name>ValidateUser</servlet-name>
      <servlet-class> org.apache.catalina.servlets.ValidateUser</servlet-class>
</servlet>

<servlet-mapping>
        <servlet-name>ValidateUser</servlet-name>
        <url-pattern>/servlet/ValidateUser</url-pattern>
</servlet-mapping>

<welcome-file-list>
      <welcome-file>index.html</welcome-file>
</welcome-file-list>

in web.xml but no result....

further help is requested.. :-)

Kalyan.
ASKER CERTIFIED SOLUTION
Avatar of arun99907
arun99907

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial