wood burning stoves 2.0*
The moose likes Servlets and the fly likes tomcat returns strange error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "tomcat returns strange error" Watch "tomcat returns strange error" New topic
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: 11404
    
  81

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: 11404
    
  81

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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: tomcat returns strange error
 
Similar Threads
Tomcat throws java.lang.UnsupportedClassVersionError
exception error:noclassfound
Error in java sip api
ServletExceptionerror
sending email using JavaMail