Unit Test JPA with JUnit H2 In Memory Database

You may also like...

Subscribe
Notify of
guest
6 Comments
Oldest
Newest
Inline Feedbacks
View all comments
Rajiv Mothilal
Rajiv Mothilal
June 12, 2017 15:01

Hi Memorynotfound. The persistence.xml requires a provider. which should be used?

Memorynotfound.com
Memorynotfound.com
June 16, 2017 09:56
Reply to  Rajiv Mothilal

Hello Rajiv,

It’s not required, but you can use the following HibernatePersistenceProvider</code.
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>

Kr,
Memorynotfound

Tore Angell Petersen
Tore Angell Petersen
March 19, 2018 10:42

Hi Memorynotfound!
I have a problem with the code, when I use it in my project and try to run a mvn clean package I get a NoClassDefFound error. I have followed your tutorial to the point, so I’m woundering if you got any pointers?
/Tore

Tore Angell Petersen
Tore Angell Petersen
March 19, 2018 13:03
Reply to  MemoryNotFound

I only get this sunfire report:
java.lang.NoClassDefFoundError: javax/transaction/SystemException
Caused by: java.lang.ClassNotFoundException: javax.transaction.SystemException

The weird part is that the test works in Intellij but not when I try to mvn clean package

/Tore

Tore Angell Petersen
Tore Angell Petersen
March 19, 2018 15:24

I found the problem!
I were using Java9 and it was doing some strang things, so it works when I set JAVA_HOME to java1.8

6
0
Would love your thoughts, please comment.x
()
x