Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

servlet error

 
Kostas Anastasiou
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

javax.servlet.ServletException: Error instantiating servlet class MyServlet
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:405)
org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:964)
org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:515)
org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:302)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
java.lang.Thread.run(Thread.java:679)
root cause

java.lang.ClassNotFoundException: MyServlet
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1678)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1523)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:405)
org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:964)
org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:515)
org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:302)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
java.lang.Thread.run(Thread.java:679)
note The full stack trace of the root cause is available in the Apache Tomcat/7.0.22 logs.

can anyone help why browser turns out these errors?
 
German Gonzalez-Morris
Ranch Hand
Posts: 265
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you have a servlet declared in your web.xml called MyServlet ?

Please paste your web.xml to see more details.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65118
89
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Be sure that your servlet is in a package other than the default, and that the class file is placed in the correct folder hierarchy that matches the package under WEB-INF/classes.
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch
 
Kostas Anastasiou
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Seetharaman Venkatasamy wrote:Welcome to JavaRanch

Hi, Seetharaman Venkatasamy,I'm happy to be here!

I've posted MyServlet.class to /usr/local/apache-tomcat-7.0.22/webapps/ROOT/WEB-INF/classes
and this is my web.xml file.


The link I put to my browser is http://localhost/my

Τo tell the truth on my computer that process works, but has done exactly the same and a friend(maybe ) and takes out the above errors. And I don't know what to tell him to look back, The .class and .xml files are exactly the same.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65118
89
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I already answered the question.
 
Kostas Anastasiou
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks, but I've been confused!
which is the default package for my servlet?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65118
89
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Basic Java: The default package is the unnamed package that classes get put into when you don't give it an explicit package. All classes in a web application need to be in an explicit package. Sometimes, a servlet will work when placed in the default package, but most often it will not. Are you a gambling man?
 
German Gonzalez-Morris
Ranch Hand
Posts: 265
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does you Myservlet have a package ?

You need to assure that yo are calling the right web application (with the righ URL), this application must have in the web.xml the mapping plus the servlet and has deployed under WEB-INF/classes the servlet under the correct package. (considering if it is default, as mentioned).

Tomcat brings Servlets deployed as example, maybe you may like to work from there.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic