• 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

hibernate exception

 
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey guys,

I am a newbie in java arena, and I am currently working to build a simple app using hibernate, but somehow even after going through samples, i am stuck-up...

I am getting the following error after i run my app...


java.lang.NoClassDefFoundError: org/hibernate/cfg/Configuration
Hibern.doPost(Hibern.java:51)
javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

I am using a HTML form with "submit" button to make a call to a servlet, which intern retrieves data from my oracle DB table.


here's the servlet code,






My config file is as follows,its placed under \src



My mapping file is as follows,




and Bean is my POJO,





Could anyone help me out to pull out of this meager problem...

Thanks in advance,
hemanth ..

 
Bartender
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Moved to Object Relations Mapping & added code tags.
 
Wouter Oet
Bartender
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi and welcome to the JavaRanch.

I'm going to assume that you deployed this to something like tomcat. In that case you probably forgot to add hibernate to the classpath.
 
hemanth acharya
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Wouter,
Thanks for early response..

Well, yea i deployed it to TOMCAT, and i added hibernate jars to my classpath.
The jars were there in my E drive...
But even then the problem exists..
Please let me know the solution to solve this.


Thank you
Hemanth.
 
Bartender
Posts: 4116
72
Mac TypeScript Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

yea i deployed it to TOMCAT, and i added hibernate jars to my classpath.
The jars were there in my E drive...


What "classpath" are you talking about here? Do you have the required jar files in the application lib folder deployed to Tomcat, if not you should add them there.
 
hemanth acharya
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Vijitha,

I set CLASSPATH in the environment variables.
I have the required jars, and i added it to the application using "Add External Jars"..
I hope this is the way,

I know these are quite basic, but i need to get the hang of it..

Thank you,
Hemanth.
 
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Hemanth,

Add external jars (probably you are using eclipse) would allow you to compile your application but because this is a JEE application, you need to add your jars in the lib folder and then deploy the package into the Tomcat.

Just adding jars in the environment classpath variable would not help.

Please check the JEE web application folder structure for more details.

Regards,
Naresh Waswani
 
hemanth acharya
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello guys,

I am getting the following error on my mapping xml.

The file cannot be validated as the XML Schema "http://www.jboss.org/dtd/hibernate/Hibernate-mapping-3.0.dtd" that is specified as describing the syntax of the file cannot be located.

Could anyone help me to solve this..

Thank u.
Hemanth.
 
hemanth acharya
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey guys ,
The above issue is solved..

Now i am getting another...

Could not parse configuration: /hibernate.cfg.xml

this is my full stack..

16 [main] INFO org.hibernate.cfg.Environment - Hibernate 3.3.1.GA 16 [main] INFO org.hibernate.cfg.Environment - hibernate.properties not found 16 [main] INFO org.hibernate.cfg.Environment - Bytecode provider name : javassist 31 [main] INFO org.hibernate.cfg.Environment - using JDK 1.4 java.sql.Timestamp handling 63 [main] INFO org.hibernate.cfg.Configuration - configuring from resource: /hibernate.cfg.xml 63 [main] INFO org.hibernate.cfg.Configuration - Configuration resource: /hibernate.cfg.xml

Please help me out..

Thank you ,
hemanth
 
Ranch Hand
Posts: 317
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can you post the entire stacktrace? It might throw some light on the actual issue. Also check that there are no spaces or carriage returns before the first line.
 
hemanth acharya
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi sridhar..

The following is what I got..


16 [main] INFO org.hibernate.cfg.Environment - Hibernate 3.3.1.GA
16 [main] INFO org.hibernate.cfg.Environment - hibernate.properties not found
16 [main] INFO org.hibernate.cfg.Environment - Bytecode provider name : javassist
31 [main] INFO org.hibernate.cfg.Environment - using JDK 1.4 java.sql.Timestamp handling
63 [main] INFO org.hibernate.cfg.Configuration - configuring from resource: /hibernate.cfg.xml
63 [main] INFO org.hibernate.cfg.Configuration - Configuration resource: /hibernate.cfg.xml
Could not parse configuration: /hibernate.cfg.xml

Thank you
 
hemanth acharya
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sridhar,

There is no space or carriage in the xml, i have made it sure that i haven't left anythin behind...
 
hemanth acharya
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey guys,

Thanks for all the help.. I could able to solve it... The problem was with DTD....

The following is what i used in my conf file..

<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

and there was one more mistake in my hbm file..
<hibernate-mapping>
<class name="com.employee" table="PERSONNEL">

....
....

I had written 'class name' value as "com.employee.java"

Thank you,
Hemanth
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic