| Author |
tomcat returns strange error
|
Vas Miriyala
Ranch Hand
Joined: Sep 14, 2009
Posts: 114
|
|
here is the error i got when i try to run servlet
Here is my java code for Hello.java
here is web.xml
here is the information about java in my machine
please help me out ...I am struglling a lot
|
 |
Anirvan Majumdar
Ranch Hand
Joined: Feb 22, 2005
Posts: 261
|
|
Can you check and verify whether the servlet API JAR is available in your Tomcat installation. The JAR is typically named servlet-api.jar.
I recall a similar error - could not instantiate servlet class - which arose due to the absence of that JAR file. In a normal Tomcat installation this JAR is always included by default, but still you might want to check on that first.
|
 |
Andrew Monkhouse
author and jackaroo
Marshal Commander
Joined: Mar 28, 2003
Posts: 10892
|
|
The error is stating that you do not have the "public" modifier set on the class - did you try your class one time with default permissions? Have you redeployed since you set public access?
You might want to go to the version of the web application that Tomcat is actually running, and try decompiling the class to see what access Tomcat believes it has. E.g.:
Obviously change paths as needed according to your installation, and ServletTest to whatever you have named your web application.
You should hopefully see some output like this:
Copy and paste that output into this topic.
I suspect you will find that your output will look like this:
Notice the lack of a "public" in the line "class Hello extends javax.servlet.http.HttpServlet"?
|
The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
|
 |
Vas Miriyala
Ranch Hand
Joined: Sep 14, 2009
Posts: 114
|
|
|
thanks for your valuable suggestions ,the strange thing is that once again i have written simple servlet and deployed it in servlet container and working fine still i am not getting that whats went wrong in my earlier code looks same and onething i did is restarted the system,thats it
|
 |
Andrew Monkhouse
author and jackaroo
Marshal Commander
Joined: Mar 28, 2003
Posts: 10892
|
|
As I said - the error message states that you did not have your class defined as public previously. The code you posted shows that it is public, so at some point you may have changed the code without redeploying. Now that you have redeployed with a public class the problem has gone away.
You can prove this yourself by removing the public access modifier from your class on your working application, recompiling and redeploying - you should get the same error you were previously seeing.
|
 |
Vas Miriyala
Ranch Hand
Joined: Sep 14, 2009
Posts: 114
|
|
|
well thanks a lot..tired..got the same error..great nice job thanks a lot
|
 |
 |
|
|
subject: tomcat returns strange error
|
|
|