Win a copy of OCP Oracle Certified Professional Java SE 11 Programmer I Study Guide: Exam 1Z0-815 this week in the Programmer Certification forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Paweł Baczyński
  • Piet Souris
  • Vijitha Kumara

The debug process for PersistenceException

 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Upon attempting to start my web application. I get the exception "javax.persistence.PersistenceException: [PersistenceUnit: persistence_unit] Unable to build Hibernate SessionFactory".
I expect that this exception is caused by some incorrect configuration somewhere in the persistence.xml file and some incorrect configuration in my JPA-annotated code. But, i want to know what exactly is it. The problem however is that the exception message doens't say much.
What should i do if i want to be able to perilously find out what's causing the exception.

Note: I am using Spring REST + JPA (Hibernate implementation) connecting to a mysql database on a tomcat servlet container.
 
Saloon Keeper
Posts: 21268
138
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There should be more information than that in the stack trace.

However, you can also set debug logging options to get a better look at What Hibernate is trying to do.
 
Toni Lane
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's the last cause exception.
The resulting exceptions were about how spring can't create "entityManager" bean.
I am now researching hibernate logging. Any guides on that are appreciated.
 
Tim Holloway
Saloon Keeper
Posts: 21268
138
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Toni Lane wrote:That's the last cause exception.
The resulting exceptions were about how spring can't create "entityManager" bean.
I am now researching hibernate logging. Any guides on that are appreciated.



The reason that no SessionFactory could be built was because the prerequisite EntityManager could not be created.

I know that stack traces are long, dreary and boring, and believe me, we get buried in enough excessive detail on questions that we do appreciate it when people try and keep it short, but in this case, we really do need you to copy and paste the entire stack trace from the log.

Here's the documentation on getting Hibernate to log: http://docs.jboss.org/hibernate/orm/4.3/topical/html/logging/Logging
 
Toni Lane
Ranch Hand
Posts: 30
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry for the delayed response.
I learned Log4j2 and used it to debug the issue.
I was able to find the cause in the logs.
 
Let's get him boys! We'll make him read this tiny ad!
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!