We help IT Professionals succeed at work.

Servlet not working

mike9483
mike9483 asked
on
Hi I have moved my existing web app from JBoss to Tomcat 6.0. The web app has deployed mostly successfully but I am battling to get a servlet to run on the new web app. I am getting a class not found error. I have checked the web.xml files and I believe configuration is correct. Please help.
 
The stack trace error I am getting is as follows:
Nov 2, 2011 11:54:43 AM org.apache.catalina.core.ApplicationContext log
INFO: Marking servlet FileDownload as unavailable
Nov 2, 2011 11:54:43 AM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Allocate exception for servlet FileDownload
java.lang.ClassNotFoundException: javax.ejb.CreateException
        at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1680)
        at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1526)
        at java.lang.Class.getDeclaredMethods0(Native Method)
        at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
        at java.lang.Class.getDeclaredMethods(Unknown Source)
        at org.apache.catalina.util.DefaultAnnotationProcessor.processAnnotations(DefaultAnnotationProcessor.java:226)
        at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1120)
        at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:809)
        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:298)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
        at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
        at java.lang.Thread.run(Unknown Source)

Extract from web.xml is as follows:

    <servlet>
        <servlet-name>FileDownload</servlet-name>
        <servlet-class>za.co.oneTwoOne.servlets.FileDownload</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>FileDownload</servlet-name>
        <url-pattern>/FileDownload</url-pattern>
    </servlet-mapping>

The FileDownload class is located in /WEB-INF/classes/za.co.oneTwoOne.servlets

Please help.


Comment
Watch Question

put j2ee.jar in classpath.

why ejb exception is coming FileDownload servlet class;

to work servlet only servlet related jars are required.but ur errro states that it requires j2ee-1.4.jar in classpath.
put j2ee-1.4.jar  tomcat/comon/lib folder.

Author

Commented:
Doing that creates a conflict when starting Tomcat:

INFO: Starting Servlet Engine: Apache Tomcat/6.0.32
java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
        at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
Caused by: java.lang.NoSuchMethodError: javax.servlet.ServletContext.getContextPath()Ljava/lang/String;
        at org.apache.catalina.core.StandardHost$MemoryLeakTrackingListener.lifecycleEvent(StandardHost.java:616)
        at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:142)
        at org.apache.catalina.core.StandardContext.start(StandardContext.java:4699)
        at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
        at org.apache.catalina.core.StandardHost.start(StandardHost.java:840)
        at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
        at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)
        at org.apache.catalina.core.StandardService.start(StandardService.java:525)
        at org.apache.catalina.core.StandardServer.start(StandardServer.java:754)
        at org.apache.catalina.startup.Catalina.start(Catalina.java:595)
        ... 6 more

servlet-api.jar is already loaded in the classpath.
why ejb exception is coming in your servlet code?
show ur code
me
 javax.ejb.CreateException
remove j2ee.jar
i belive some where in your code your throwing ejb related exceptions .anywhere in your code you should not import javax.ejb.*;

Explore More ContentExplore courses, solutions, and other research materials related to this topic.