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

error in servlet

 
Geeta Ravikanti
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
this is my program


when i am running this program this is the exeption raising





HTTP Status 500 -

--------------------------------------------------------------------------------

type Exception report

message

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

exception

javax.servlet.ServletException: Wrapper cannot find servlet class Retreive or a class it depends on
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:793)
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:702)
org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:571)
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:644)
java.lang.Thread.run(Thread.java:595)


root cause

java.lang.ClassNotFoundException: Retreive
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1340)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1189)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:793)
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:702)
org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:571)
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:644)
java.lang.Thread.run(Thread.java:595)


}
}



previously i executed the same program properly and retrived the data from the table correctly
when i inserted the new rows in the table and run the above program its throwing that exeption
I added related jar file correctly,i set the classpath correctly
but why my program is not working
i am unable to find where i did the mistake
if any body find plese tell me where did i dont mistake

tahQ
geeta
[ April 02, 2008: Message edited by: David O'Meara ]
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should always package servlets
 
ramesh turlapati
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
jar files missing...
 
suri jagadish
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi David,

I think you need to check back on what you have said about the servlets.

It is not absolutely necessary for a servlet to be in a package.

It can exist independently without a package and can be called.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65111
89
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by suri jagadish:
It can exist independently without a package and can be called.
Sometimes it can work. Most times, it causes problems. In all cases, it's a poor practice. Why would you condone poor practices?
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
and if the problem were package related, it would look just like that.

Is there any additional code we're missing? Like constructors, instance or static blocks? The problem could also be caused by the class failing to load.

I'd also make sure you don't accidentally have the servlet.jar or servlet classes packaged with your web app (eg in the WEB-INF/lib directory)
 
suri jagadish
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Bear,

Well you are right its not a good practice. I Myself don't code that way.
But i was only trying to establish a fact.
[ April 03, 2008: Message edited by: suri jagadish ]
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by suri jagadish:
... But i was only trying to establish a fact.


There are some cases where unpackaged classes will not be found in a servlet application and some cases where they will. If anyone's interested in the specific reasons for this, see:
http://faq.javaranch.com/search?PackageYourBeans
It contains links to the relavent bug reports on Sun's site.

Rather than get into the nuances of when you can get away with using the default package and when you can't--a confusing thing to have to learn just to get away with ignoring a good practice--we (knowing full well what the facts are) stress that all classes in a Java web application should be packaged, period.

From, an academic standpoint, it might be interesting to learn all the ins and outs of this, and for an intermediate, who has to maintain a large legacy application it might actually be useful to understand when an unpackaged class will or will not be found when debugging a ClassNotFoundException. For someone starting out learning servlets, however, there is never a good case for using the default package in a web application and the smartest thing to do (especially when trying to figure out why one of these early examples isn't working) is to rule out any of these subtle bugs by packaging everything, always. To teach someone otherwise is to do them a disservice.
[ April 03, 2008: Message edited by: Ben Souther ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic