Meaningless Drivel is fun!*
The moose likes Object Relational Mapping and the fly likes where is the error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "where is the error" Watch "where is the error" New topic
Author

where is the error

Samanthi perera
Ranch Hand

Joined: Jan 08, 2010
Posts: 510
this is my file structure


this is my config.xml





this is my main class


in this main class line AnnotationConfiguration().configure().buildSessionFactory(); gives this error



Devaka Cooray
ExamLab Creator
Saloon Keeper

Joined: Jul 29, 2008
Posts: 3060
    
  38

Samanthi perera wrote:AnnotationConfiguration().configure().buildSessionFactory()

AnnotationConfiguration is a class. How do you create a new object from a class?


Author of ExamLab ExamLab - a free SCJP / OCPJP exam simulator
What would SCJP exam questions look like? -- Home -- Twitter -- How to Ask a Question
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Please post only the code relevant to the question. This is a compilation error--no configuration file is involved.
Samanthi perera
Ranch Hand

Joined: Jan 08, 2010
Posts: 510
i am using this exaple
http://www.vaannila.com/hibernate/hibernate-example/hibernate-annotations-1.html
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Okay. See the difference? You were already told what the problem was, and the code in the link is not the same as yours where the problem is.
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10067
    
163



Did you recheck the code with the example that you took it from? Clearly it's not the same. And Devaka already told you what the problem is with that piece of code.


[My Blog] [JavaRanch Journal]
Samanthi perera
Ranch Hand

Joined: Jan 08, 2010
Posts: 510
ok.I have added new keyword to main class.

anyway when i run the example it gives this error.


I think it is not creating sessionfactory ?
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Hard to say, since you don't post the rest of the stack trace. Do you have the annotated class?
Samanthi perera
Ranch Hand

Joined: Jan 08, 2010
Posts: 510
I debug the code

java.lang.ClassNotFoundException
org/hibernate/cfg/AnnotationConfiguration
null

David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

And the libraries you're deploying are...?

Come on: we've been over this stuff many times: TellTheDetails.
Samanthi perera
Ranch Hand

Joined: Jan 08, 2010
Posts: 510
mysql-connector-java-5.0.8-bin
hibernate-annotations
hibernate-commons-annotations
hibernate3
ejb3-persistence
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

I'm skeptical, because the error *clearly* indicates which class isn't found.
Samanthi perera
Ranch Hand

Joined: Jan 08, 2010
Posts: 510
now it is change the error


anyway my Configuration.cfx.xml file in the project folderr
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

It should be on the classpath. I don't understand why you have to make this so difficult, over and over.
Samanthi perera
Ranch Hand

Joined: Jan 08, 2010
Posts: 510
I am using Eclips IDE.
I creatred the config file using
File -> New->Other ->Hibernate -> Hibernate Configuration File
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

So what? It needs to be on the classpath.
Samanthi perera
Ranch Hand

Joined: Jan 08, 2010
Posts: 510
How to add it to classpath?
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Put it in your source directory?
Samanthi perera
Ranch Hand

Joined: Jan 08, 2010
Posts: 510
i have added.
Still have errors.


i add a debug line in
session=new AnnotationConfiguration().configure().buildSessionFactory();
after debug pointer come to this line i press F5.
then this error comes.
Samanthi perera
Ranch Hand

Joined: Jan 08, 2010
Posts: 510
i have added 3306 to the url in config.xml

<property name="hibernate.connection.url">jdbc:mysql://localhost:3306/school</property>

the error is still there
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Do you see the error? There's a class missing.
Samanthi perera
Ranch Hand

Joined: Jan 08, 2010
Posts: 510
Which jar shuold i add?
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617



I think if you don't know how to figure that out you should take a step back before trying to deal with an ORM, because if you can't figure out how to fix the *simple* things when something goes wrong fixing the *complicated* stuff that can happen in Hibernate is going to be a pretty tall order.

- What class is missing?
- What jar is it in (and how do you know)?
- If you *think* you're deploying that jar, how can you find out if you're right?
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17250
    
    6

The answer must be 42

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Samanthi perera
Ranch Hand

Joined: Jan 08, 2010
Posts: 510
what do you mean 42?
Devaka Cooray
ExamLab Creator
Saloon Keeper

Joined: Jul 29, 2008
Posts: 3060
    
  38

Mark Spritzler wrote:The answer must be 42

Exactly
Samanthi perera
Ranch Hand

Joined: Jan 08, 2010
Posts: 510
i don't understand what is mean by 42.
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30361
    
150

Samanthi perera wrote:i don't understand what is mean by 42.

42 is the answer to the ultimate question (life the universe and everything) in the Hitchhikers Guide to the Galaxy. It is used as a joke.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Shashank Acharya
Greenhorn

Joined: Mar 20, 2010
Posts: 21



I tried this in Netbeans 6.8 & I hope it will work in Eclipse.

Another thing please create one HibernateUtil.java in Project as shown at Vaannilla Tutorial.
Don't try to create SessionFactory at main class.Use HibernateUtil class getSessionFactory() Method.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: where is the error