• 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

Ch 4 Coreservlets and JSP Submit Insurance Info example problem

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am having a problem with a tutorial I am doing in Coreservlets and JSP Vol.1. It is located in Chapter 4 and is the 4.7 section Automatically Populating java OBjects...I am using Eclipse as my IDE. I believe that I have my servlets and my html pages in the correct location. I can get it to build without any errors. I had to use three jar files, commons-beanutils.jar, commons-collections.jar and commons-logging.jar and used the configure build path in Eclipse to add these jars.
The problem I am getting is this:

type Exception report

message

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

exception

javax.servlet.ServletException: Servlet execution threw an exception


root cause

java.lang.NoClassDefFoundError: org/apache/commons/beanutils/BeanUtils
coreservlets.beans.BeanUtilities.populateBean(BeanUtilities.java:52)
coreservlets.beans.BeanUtilities.populateBean(BeanUtilities.java:40)
coreservlets.SubmitInsuranceInfo.doGet(SubmitInsuranceInfo.java:24)
javax.servlet.http.HttpServlet.service(HttpServlet.java:627)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)


root cause

java.lang.ClassNotFoundException: org.apache.commons.beanutils.BeanUtils
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1386)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1232)
java.lang.ClassLoader.loadClassInternal(Unknown Source)
coreservlets.beans.BeanUtilities.populateBean(BeanUtilities.java:52)
coreservlets.beans.BeanUtilities.populateBean(BeanUtilities.java:40)
coreservlets.SubmitInsuranceInfo.doGet(SubmitInsuranceInfo.java:24)
javax.servlet.http.HttpServlet.service(HttpServlet.java:627)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)


note The full stack trace of the root cause is available in the Apache Tomcat/5.5.27 logs.


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

Apache Tomcat/5.5.27


If anyone has solved this problem I would apreciate knowing what I am not doing right here. Thanks!
 
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Raymond Champion wrote:java.lang.NoClassDefFoundError: org/apache/commons/beanutils/BeanUtils

The mentioned class is missing in the classpath. Have you added it to the webapp´s /WEB-INF/lib folder? That path is covered by the webapp´s classpath by default.
 
Raymond Champion
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
One of my coworkers figured it out. He downloaded the latest commons-beanutils and commons-collections zip files. Then he unzipped them. My problem was I was using the zipped up jar files in my classpath and therefore when it tried to populate the bean, in the BeanUtilities servlet, it failed because it could never find the BeanUtils.populate method.
 
Raymond Champion
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Update to this problem.
When using Eclipse, I had to add the unzipped jar files using Build Path->Configure Build Path. Then I selected J2EE Module Dependencies. Selected Add External JARS button and navigated to the desktop(that's where I unzipped them, but I am sure any absolute path where they are located will work). Do not click Apply, just select OK. Run the app on tomcat server and it works so far.
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Uhm.

You should not extract the JAR files. You just need to place the JAR file in the classpath.

The /WEB-INF/lib folder is covered by the classpath. Place the JAR in there. That's all. No need to configure build path in Eclipse or so. Eclipse itself already know that it should take any JAR files in the /WEB-INF/lib folder in the build path (if you created the project as 'Dynamic Web Project').
 
reply
    Bookmark Topic Watch Topic
  • New Topic