aspose file tools*
The moose likes Object Relational Mapping and the fly likes Exception while getting transaction Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Exception while getting transaction" Watch "Exception while getting transaction" New topic
Author

Exception while getting transaction

Max Vaha
Greenhorn

Joined: Nov 27, 2007
Posts: 29
Hello, ranchers!
I have the following method in a JSF bean

I have tried this code with MySql and Postgres, application server is Tomcat 6.14. This is the exception:


Has anyone any ideas about this?
[ June 09, 2008: Message edited by: Max Vaha ]
Rodrigo Lopes
Ranch Hand

Joined: Feb 29, 2008
Posts: 119
Please, show how your datasource is configured in the hibernate.cfg.xml file.
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper

Joined: Aug 26, 2006
Posts: 4968
    
    1

It does look like a datasource problem, that's for sure.

Perhaps you have a way of testing your datasource apart from Hibernate? Like just write some code that looks it up, opens a db connection, queries the database, and closes the connection? If there's an easy way to do that, it might be worth your time.

Your hibernate.cfg.xml file might have a peculiar setting as well. Post it and maybe there's something in there that stands out.

Database, app server and how the datasource is being managed or created might be great info as well.

-Cameron McKenzie
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16068
    
  21

I think you need to show how your datasource is configured in Tomcat.


Customer surveys are for companies who didn't pay proper attention to begin with.
Max Vaha
Greenhorn

Joined: Nov 27, 2007
Posts: 29
I want to use hibernate as a JPA provider, so do I need hibernate.cfg.xml?
This is persistence.xml

Context.xml in tomcat

I checked connection using my IDE. It's ok.
Rodrigo Lopes
Ranch Hand

Joined: Feb 29, 2008
Posts: 119
I believe that you don't need these lines in your persistence.xml file:



They are already in your tomcat config (context.xml)
When you call em.getTransaction(); you're asking the container for a new connection.
But if you keep these properties in your persistence.xml, then you're saying that hibernate will handle you connections, not the container
[ June 10, 2008: Message edited by: Rodrigo Lopes ]
Max Vaha
Greenhorn

Joined: Nov 27, 2007
Posts: 29
Hmm, thanks, but the same exception is thrown without these properties in persistence.xml. It is thrown even if there is no properties. Has anyone other idea's?
[ June 17, 2008: Message edited by: Max Vaha ]
Max Vaha
Greenhorn

Joined: Nov 27, 2007
Posts: 29
Thanks! Finally it is done!
 
jQuery in Action, 2nd edition
 
subject: Exception while getting transaction