0

I see this error very common in the blogs and SO but I could not somehow resolve it..

Error:

exception

javax.servlet.ServletException: Error instantiating servlet class DemoServlet org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501) org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103) org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950) org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408) org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1070) org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:611) org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:314) java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1146) java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) java.lang.Thread.run(Thread.java:701) root cause java.lang.ClassNotFoundException: DemoServlet org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1720) org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1571) org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501) org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103) org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950) org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408) org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1070) org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:611) org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:314) java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1146) java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) java.lang.Thread.run(Thread.java:701) 

Project folder structure..

[m1980@web449 sampleproject]$ tree . . ├── pom.xml ├── src │   └── main │   ├── java │   │   └── com │   │   └── prem │   │   └── controller │   │   └── DemoServlet.java │   ├── resources │   └── webapp │   ├── index.jsp │   └── WEB-INF │   └── web.xml └── target ├── classes │   └── com │   └── prem │   └── controller │   └── DemoServlet.class ├── maven-archiver │   └── pom.properties └── sampleproject ├── index.jsp ├── META-INF └── WEB-INF ├── classes │   └── com │   └── prem │   └── controller │   └── DemoServlet.class └── web.xml 22 directories, 9 files 

Im able to start apache and it runs without any problem...when I try http://localhost/sampleproject it displays the index page(Hello World!)..but when I try /welcome I get the above error...

web.xml

<web-app> <display-name>Archetype Created Web Application</display-name> <servlet> <servlet-name>test</servlet-name> <servlet-class>DemoServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>test</servlet-name> <url-pattern>/welcome</url-pattern> </servlet-mapping> </web-app> 

1 Answer 1

4

Tomcat is looking for a package private class called DemoServlet. You need to use the fully qualified class

<servlet-class>com.prem.controller.DemoServlet</servlet-class> 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.