Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Servlet : SEVERE: Allocate exception for servlet

The following stacktrace is what I get when i try to access a servlet, which seems running fine from Tomcat manager.

11 Sep, 2012 11:50:12 AM org.apache.catalina.core.ApplicationContext log
INFO: Marking servlet LoginServlet as unavailable
11 Sep, 2012 11:50:12 AM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Allocate exception for servlet LoginServlet
java.lang.Error: Unresolved compilation problems: 
    The import javax.servlet cannot be resolved
    The import javax.servlet cannot be resolved
    The import javax.servlet cannot be resolved
    The import javax.servlet cannot be resolved
    The import javax.servlet cannot be resolved
    The import javax.servlet cannot be resolved
    HttpServlet cannot be resolved to a type
    ServletConfig cannot be resolved to a type
    ServletException cannot be resolved to a type
    HttpServlet cannot be resolved to a type
    ServletContext cannot be resolved to a type
    ServletException cannot be resolved to a type
    HttpServletRequest cannot be resolved to a type
    HttpServletResponse cannot be resolved to a type
    ServletException cannot be resolved to a type
    request cannot be resolved
    The method getLoggedin() from the type LoginHandler refers to the missing type ServletException
    The method destroy() of type LoginManager must override or implement a supertype method
    HttpServlet cannot be resolved to a type

    at com.login.servlets.LoginManager.<init>(LoginManager.java:5)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at java.lang.Class.newInstance0(Unknown Source)
    at java.lang.Class.newInstance(Unknown Source)
    at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1149)
    at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:827)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:129)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
    at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:877)
    at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:594)
    at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1675)
    at java.lang.Thread.run(Unknown Source)
11 Sep, 2012 12:05:12 PM org.apache.catalina.core.ApplicationContext log
INFO: Marking servlet Log4JInitServlet as unavailable
11 Sep, 2012 12:05:12 PM org.apache.catalina.core.StandardContext loadOnStartup
SEVERE: Servlet /logintest threw load() exception
java.lang.Error: Unresolved compilation problems: 
    The import javax.servlet cannot be resolved
    The import javax.servlet cannot be resolved
    The import javax.servlet cannot be resolved
    The import javax.servlet cannot be resolved
    The import org.apache cannot be resolved
    The import org.apache cannot be resolved
    HttpServlet cannot be resolved to a type
    ServletConfig cannot be resolved to a type
    ServletException cannot be resolved to a type
    ServletContext cannot be resolved to a type
    BasicConfigurator cannot be resolved
    PropertyConfigurator cannot be resolved
    BasicConfigurator cannot be resolved

    at com.logger.WebLogger.<init>(WebLogger.java:5)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at java.lang.Class.newInstance0(Unknown Source)
    at java.lang.Class.newInstance(Unknown Source)
    at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1149)
    at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1026)
    at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4421)
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:4734)
    at org.apache.catalina.core.StandardContext.reload(StandardContext.java:3461)
    at org.apache.catalina.manager.ManagerServlet.reload(ManagerServlet.java:943)
    at org.apache.catalina.manager.HTMLManagerServlet.reload(HTMLManagerServlet.java:557)
    at org.apache.catalina.manager.HTMLManagerServlet.doGet(HTMLManagerServlet.java:121)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.filters.CsrfPreventionFilter.doFilter(CsrfPreventionFilter.java:186)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:563)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
    at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:877)
    at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:594)
    at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1675)
    at java.lang.Thread.run(Unknown Source)

All the jars which was used inside eclipse classpath is avaiable in Tomcat lib folder. The webapp is getting deployed with out any error logs, but when i try to access one servlet, this exception occurs, and i get it logged in the tomcat logs. Can any one help with this?

The package names are proper inside 'classes', also, the web.xml is proper. 

I dont know then why this happens. There are certain other webapps, which almost uses the same libs running fine. Expecting some one can help me with this..

Thanks

like image 269
Kris Avatar asked Sep 11 '12 09:09

Kris


2 Answers

Finally , got my mistake. This was a problem caused by the eclipse build. Since the build was not proper, the class files where corrupted. I cleaned up the whole project, took a fresh build, now its working fine. Thanks for your replies.

like image 84
Kris Avatar answered Oct 02 '22 09:10

Kris


Somehow you are missing the servlet-api.jar. It should be located in the tomcat\lib folder.

like image 37
Tarlog Avatar answered Oct 02 '22 09:10

Tarlog