> ...and that servlet-api.jar from tomcat is in the path.

You wouldn't happen to be messing with the classpath at all would you? That will cause headaches. Best advise is to leave the classpath alone and let tomcat's classloader hierarchy handle finding classes.

Thought 2: Tell me more about this ClassFinder class. It's not a part of Java's API and I'm wondering if it's not running it's own classloader independant of tomcat's classloader mechanism.

--David

John Poley wrote:

Thank you for your comments thus far.
I have been unable to solve my problem as well. I even went so far as to start with a machine with no development tools on it, downloading just the elements I required, and then trying to redeploy. I am fairly certain that there are no extra servlet jars anywhere, and that servlet-api.jar from tomcat is in the path. Still I face the java.lang.NoClassDefFoundError: javax/servlet/ServletContext error. I am using java 1.5.0_06 and and a 5.5 server. Well, trying to anyway! =) I'll place the error information at the very bottom of this email to avoid pushing down the previous responses too far. Any more ideas would be appreciated!

----- Original Message ----- From: "Armand Rock" <[EMAIL PROTECTED]>
To: "Tomcat Users List" <users@tomcat.apache.org>
Sent: Tuesday, December 06, 2005 12:44 PM
Subject: RE: Question concerning java.lang.NoClassDefFoundError: javax/servlet/ServletContext


Hello David,
I included all jar & zip files on my computer, including j2ee.jar and I'm
still having the problem.
I have just noticed a weird behaviour though, if I try to reload the jsp
right after the jsp fails the first
time it seems to run without throwing the exception. If I restart Tomcat
and try again the problem starts
again. I could get this to work in theory by forcing it to run through the
code once on startup
but I shouldn't have to do that and I honestly would prefer getting it to
work as it should.

-----Original Message-----
From: David Smith [mailto:[EMAIL PROTECTED]
Sent: December 6, 2005 11:57 AM
To: Tomcat Users List
Subject: Re: Question concerning java.lang.NoClassDefFoundError:
javax/servlet/ServletContext


I take it you also included j2ee.jar in that search?

--David

Armand Rock wrote:

Hi,
I'm getting the same error. I searched my entire computer for any jar/zip
files containing javax.servlet.ServletContext
and renamed all of them to ".original" so that they wouldn't be read by the
JVM.  I did this to all the files except for the file
common/lib/servlet-api.jar

I'm still getting the problem.

I'm using java version 1.4.2_10

The code i'm using used to work under Orion version 1.4.5 (I'm now using
Tomcat 5.5)
The code that eventually throws the exception is basically:

ClassFinder classFinder = new ClassFinder();
classFinder.addFile("/opt/classes/com/canlink/commands/");
Class usrClass = classFinder.findClass("com.canlink.commands.TestClass");

This line is what throws the exception:
Method setCmdLog = usrClass.getMethod("setCmdLog", new Class[]
{Boolean.class});

The stack trace is:
SEVERE: Servlet.service() for servlet RunCmd threw exception
java.lang.NoClassDefFoundError: javax/servlet/ServletContext
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
at java.lang.Class.getMethod0(Unknown Source)
at java.lang.Class.getMethod0(Unknown Source)
at java.lang.Class.getMethod(Unknown Source)
at com.canlink.commands.RunCmd.service(RunCmd.java:240)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Applicatio

n

FilterChain.java:252)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterC

h

ain.java:173)
at
org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher

.

java:672)
at
org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDi

s

patcher.java:463)
at
org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatc

h

er.java:398)
at
org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatche

r

.java:301)
at org.apache.jsp.web.Login_jsp._jspService(Login_jsp.java:67)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:

3

22)
at

org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)

at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Applicatio

n

FilterChain.java:252)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterC

h

ain.java:173)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.j

a

va:213)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.j

a

va:178)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:12

6

)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:10

5

)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.jav

a

:107)
at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:868)
at
org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.process

C

onnection(Http11BaseProtocol.java:663)
at
org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.ja

v

a:527)
at
org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerW

o

rkerThread.java:80)
at
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.ja

v

a:684)
at java.lang.Thread.run(Unknown Source)

-----Original Message-----
From: Tim Funk [mailto:[EMAIL PROTECTED]
Sent: December 6, 2005 6:30 AM
To: Tomcat Users List
Subject: Re: Question concerning java.lang.NoClassDefFoundError:
javax/servlet/ServletContext


See - http://tomcat.apache.org/faq/classnotfound.html

Odds are you have your own servlet-api.jar somewhere in the webapp or

system

classpath and that is conflicting with the one in common/lib (installed by
tomcat)

-Tim

John Poley wrote:


Please forgive my intrusion if this is not the proper place to post a


questoon of this sort. I am new to servlets, and am working on my first deployment- but I am running in to a problem that I can't find a solution to. I have installed Tomcat 5.5 and am using Eclipse (as well as a tomcat plugin) to manage my project. A colleague of mine sent me a war file of out working projected, which I imported to my IDE. I start tomcat, which seems to load properly, and attempt to run the project on the server- where
I am faced with the following:


javax.servlet.ServletException: Servlet.init() for servlet


RequestTranslator threw exception


root cause

java.lang.NoClassDefFoundError: javax/servlet/ServletContext
java.lang.Class.getDeclaredConstructors0(Native Method)
java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
java.lang.Class.getConstructor0(Unknown Source)
java.lang.Class.getConstructor(Unknown Source)



freemarker.template.Configuration.setServletContextForTemplateLoading(Confi

g

uration.java:331)


verkoopen.boundary.UserInterfaceOutput.<init>(UserInterfaceOutput.java:31)


verkoopen.boundary.RequestTranslator.init(RequestTranslator.java:25)



org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:10

5

)


org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)


org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:868)


org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.process

C

onnection(Http11BaseProtocol.java:663)


org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.ja

v

a:527)


org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerW

o

rkerThread.java:80)


org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.ja

v

a:684)


java.lang.Thread.run(Unknown Source)
I am using the most recent J2RE 5 and I am certain that Tomcat's


servlet-api.jar is within my application's class path. I am not sure why
the source cannot be found.  Any helpin locating my problem would be

greatly

appreciated, and I would be happy to prove more information if needed (I'm not entirely sure what would be helpful). And again, I am sorry if this is
not the place for this kind of question!Happy coding!John



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





INFO: Server startup in 1891 ms

Dec 6, 2005 9:59:25 PM org.apache.catalina.core.ApplicationContext log

SEVERE: StandardWrapper.Throwable

java.lang.NoClassDefFoundError: javax/servlet/ServletContext

at java.lang.Class.getDeclaredConstructors0(Native Method)

at java.lang.Class.privateGetDeclaredConstructors(Class.java:2328)

at java.lang.Class.getConstructor0(Class.java:2640)

at java.lang.Class.getConstructor(Class.java:1629)

at freemarker.template.Configuration.setServletContextForTemplateLoading(Configuration.java:331)

at verkoopen.boundary.UserInterfaceOutput.<init>(UserInterfaceOutput.java:31)

at verkoopen.boundary.RequestTranslator.init(RequestTranslator.java:25)

at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1105)

at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:757)

at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:130)

at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)

at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)

at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)

at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)

at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)

at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)

at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:667)

at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)

at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)

at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)

at java.lang.Thread.run(Thread.java:595)



Dec 6, 2005 9:59:25 PM org.apache.catalina.core.StandardWrapperValve invoke

SEVERE: Allocate exception for servlet RequestTranslator

java.lang.NoClassDefFoundError: javax/servlet/ServletContext

at java.lang.Class.getDeclaredConstructors0(Native Method)

at java.lang.Class.privateGetDeclaredConstructors(Class.java:2328)

at java.lang.Class.getConstructor0(Class.java:2640)

at java.lang.Class.getConstructor(Class.java:1629)

at freemarker.template.Configuration.setServletContextForTemplateLoading(Configuration.java:331)

at verkoopen.boundary.UserInterfaceOutput.<init>(UserInterfaceOutput.java:31)

at verkoopen.boundary.RequestTranslator.init(RequestTranslator.java:25)

at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1105)

at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:757)

at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:130)

at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)

at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)

at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)

at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)

at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)

at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)

at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:667)

at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)

at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)

at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)

at java.lang.Thread.run(Thread.java:595)

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to