Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Exception while getting transaction

 
Max Vaha
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please, show how your datasource is configured in the hibernate.cfg.xml file.
 
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper
Posts: 4968
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 18164
53
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you need to show how your datasource is configured in Tomcat.
 
Max Vaha
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks! Finally it is done!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic