Win a copy of Bad Programming Practices 101 (e-book) this week in the Beginning Java forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

The debug process for PersistenceException  RSS feed

 
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.
 
Bartender
Posts: 19548
90
Android Eclipse IDE 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
Bartender
Posts: 19548
90
Android Eclipse IDE 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.
 
The human mind is a dangerous plaything. This tiny ad is pretty safe:
Why should you try IntelliJ IDEA ?
https://coderanch.com/wiki/696337/IntelliJ-IDEA
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!