• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Tomcat Servlet/Bean 500 Error

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I�m trying to set up my testing environment to practice with Java beans for the first time. I am using Servlets And JavaServer Pages Volume 1: Core Technologies (CH 4) as my guide (specifically the InsuranceForm.html example). I have been able to get the environment up and running with no problems in terms of handling servlets and jsps. The problem has been with the first bean that I have tried. When I submit the form, I receive the error below. Can anyone make any suggestions as to what may be causing this error?:


Apache Tomcat/4.0.6 - HTTP Status 500 - Internal Server Error

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

type Exception report

message Internal Server Error

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

exception

javax.servlet.ServletException: Servlet execution threw an exception
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:243)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:190)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.valves.CertificatesValve.invoke(CertificatesValve.java:246)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2347)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:170)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:468)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:1027)
at org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:1125)
at java.lang.Thread.run(Thread.java:534)


root cause

java.lang.NoClassDefFoundError
at coreservlets.beans.BeanUtilities.populateBean(BeanUtilities.java:52)
at coreservlets.beans.BeanUtilities.populateBean(BeanUtilities.java:40)
at coreservlets.SubmitInsuranceInfo.doGet(SubmitInsuranceInfo.java:24)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:243)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:190)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.valves.CertificatesValve.invoke(CertificatesValve.java:246)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2347)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:170)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:468)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:1027)
at org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:1125)
at java.lang.Thread.run(Thread.java:534)



Because everything else has been working up until this point, I feel that the issue has less to do with the java code and more to do with the setup or calling certain elements in the code.

Here�s my system setup:
Jakarta Tomcat 4.0.6
OS Windows 2000 Professional
Classpath: .;C:\AHServlets;C:\tomcat\jakarta-tomcat-4.0.6\common\lib\servlet.jar;C:\tomcat\jakarta-tomcat-4.0.6\common\lib\commons-beanutils.jar;C:\tomcat\jakarta-tomcat-4.0.6\common\lib\commons-collections.jar;C:\tomcat\jakarta-tomcat-4.0.6\common\lib\commons-logging.jar;

Compile area:
I store my java files in C:\AHServlets\coreservlets\ and the test beans in C:\AHServlets\coreservlets\beans

Bean related jar files:
C:\tomcat\jakarta-tomcat-4.0.6\common\lib\commons-beanutils.jar
C:\tomcat\jakarta-tomcat-4.0.6\common\lib\commons-collections.jar
C:\tomcat\jakarta-tomcat-4.0.6\common\lib\commons-logging.jar

Html form action:
<FORM ACTION="/servlet/coreservlets.SubmitInsuranceInfo">

InsuranceInfo bean head:


SubmitInsuranceInfo head:



Does anyone have any suggetions/advice/tips/websites etc. that I may be able to use to correct this issue?

Thanks so much.
 
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Check in WEB-INF/classes folder whether the bean class file is present or not, where are the class files being stored after compilation?
 
Andrew Hughes
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here's where everything is located. Let me know if this helps.

root - C:\tomcat\jakarta-tomcat-4.0.6\webapps\ROOT

WEB-INF - C:\tomcat\jakarta-tomcat-4.0.6\webapps\ROOT\WEB-INF
within WEB-INF there is an empty "beans" folder and a "classes" folder, and web.xml.

Classes - C:\tomcat\jakarta-tomcat-4.0.6\webapps\ROOT\WEB-INF\classes
withing classes, there is a "coreservlets" folder, where I keep all of my class files, but there is also another "beans" folder.

Beans - C:\tomcat\jakarta-tomcat-4.0.6\webapps\ROOT\WEB-INF\classes\coreservlets\beans
this is where I have been storing my beans based on the package declarations in the sample code.

For example BeanUtilities.java leads with -



and InsuranceInfo.java leads with -


Are my pieces in the correct place? Also, based on my initial description, do the jar files appear to be in the correct location, and referenced correctly in the classpath?

Thanks for the help.
 
Shankar Narayana
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bean related jar files:
C:\tomcat\jakarta-tomcat-4.0.6\common\lib\commons-beanutils.jar
C:\tomcat\jakarta-tomcat-4.0.6\common\lib\commons-collections.jar
C:\tomcat\jakarta-tomcat-4.0.6\common\lib\commons-logging.jar




put all this jar files into WEB-INF/classes folder and try to run. If you put all the other related jar files into classes folder you no need to set the classpath, as by default tomcat searches for jar & classes in this folder.
 
Andrew Hughes
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have been doing a little more research, and I may see what you are getting at.

Are you saying that within C:\tomcat\jakarta-tomcat-4.0.6\webapps\ROOT\WEB-INF\, there should be both a classes and lib directory. Within that lib directory, there should then be the 3 jar files commons-beanutils.jar, commons-collections.jar, and commons-logging.jar? If this is the case, should I take them out of the classpath altogether?

Thanks
 
Shankar Narayana
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes you are right, do it and try!
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Tomcat totally ignores your environment classpath. Read the ClassLoader How-to that is part of the tomcat docs installed with tomcat for the significance of the common/lib server/lib, WEB-INF/lib and WEB-INF/classes
directories.
 
Andrew Hughes
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Shankar and William. I will try both of your recommendations. Unfortunately, I will have to do it this evening as this is part of a project that I am working on during off hours. I'll let you know how it goes.

Thanks again.
 
Andrew Hughes
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I just did it. It worked like a charm! I also took a look in another book that explains the Tomcat directory structure so that I can make some more sense of it.

During my search on the web, I saw that others were having a similar issue, so I decided to post a graphic of my folder structure with pertinant directories opened so that you can see where everything is so that my development environemnt worked.



I hope that this helps.

Thanks again!
 
Why am I so drawn to cherry pie? I can't seem to stop. Save me tiny ad!
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic