Spring + Maven + persitence.xml

#1

Hi,

I tested ObjectDB embedded and it is really fast! Everything worked out of the box.

Maven:

<dependency>
   <groupId>com.objectdb</groupId>
   <artifactId>objectdb</artifactId>
   <version>2.4.3</version>
  </dependency>

Persistence.xml

<persistence-unit name="TEST" transaction-type="RESOURCE_LOCAL">
  <provider>com.objectdb.jpa.Provider</provider>
  <properties>
   <property name="javax.persistence.jdbc.url" value="$objectdb/db/guests.odb"/>
   <property name="javax.persistence.jdbc.user" value="admin"/>
   <property name="javax.persistence.jdbc.password" value="admin"/>
  </properties>
</persistence-unit>

 

My goal now is to realize same thing using a client version. I started the server on port 6136. Did not figured out how to create an empty db!

Then I updated persistence.xml like: (test.odb doesn't exist)

<persistence-unit name="BikeShop" transaction-type="RESOURCE_LOCAL">
  <provider>com.objectdb.jpa.Provider</provider>
  <properties>
   <!--<property name="javax.persistence.jdbc.url" value="$objectdb/db/guests.odb"/>-->
   <property name="javax.persistence.jdbc.url" value="objectdb://localhost:6136/test.odb"/>
   <property name="javax.persistence.jdbc.user" value="admin"/>
   <property name="javax.persistence.jdbc.password" value="admin"/>
  </properties>
</persistence-unit>

When I run this I have exception on screen. How come I have class not found exception in embeded server but I do have in c/s? (sorry for long post):

 

org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.transaction.CannotCreateTransactionException: Could not open JPA EntityManager for transaction; nested exception is com.objectdb.o.InternalException: Unexpected Server Error
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:894)
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:778)
javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)

root cause

org.springframework.transaction.CannotCreateTransactionException: Could not open JPA EntityManager for transaction; nested exception is com.objectdb.o.InternalException: Unexpected Server Error
org.springframework.orm.jpa.JpaTransactionManager.doBegin(JpaTransactionManager.java:427)
org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:371)
org.springframework.transaction.interceptor.TransactionAspectSupport.createTransactionIfNecessary(TransactionAspectSupport.java:336)
org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:105)
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
$Proxy278.findAllFromCache(Unknown Source)
com.jadebaboon.nucleus.modules.filter.service.FilterService.generateBrandMap(FilterService.java:368)
com.jadebaboon.nucleus.modules.home.controller.HomeController.renderHomePage(HomeController.java:35)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597)
org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:213)
org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:126)
org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:96)
org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:617)
org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:578)
org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:923)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:778)
javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)

root cause

com.objectdb.o.InternalException: Unexpected Server Error
com.objectdb.o.CLS.T(CLS.java:380)
com.objectdb.o.CLS.S(CLS.java:332)
com.objectdb.o.CLS.Q(CLS.java:277)
com.objectdb.o.CST.Z(CST.java:87)
com.objectdb.o.CST.<init>(CST.java:67)
com.objectdb.o.CSF.UJ(CSF.java:87)
com.objectdb.o.OMF.am(OMF.java:750)
com.objectdb.jpa.EMF.am(EMF.java:156)
com.objectdb.o.OMF.al(OMF.java:692)
com.objectdb.jpa.EMF.createEntityManager(EMF.java:173)
org.springframework.orm.jpa.JpaTransactionManager.createEntityManagerForTransaction(JpaTransactionManager.java:445)
org.springframework.orm.jpa.JpaTransactionManager.doBegin(JpaTransactionManager.java:366)
org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:371)
org.springframework.transaction.interceptor.TransactionAspectSupport.createTransactionIfNecessary(TransactionAspectSupport.java:336)
org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:105)
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
$Proxy278.findAllFromCache(Unknown Source)
com.jadebaboon.nucleus.modules.filter.service.FilterService.generateBrandMap(FilterService.java:368)
com.jadebaboon.nucleus.modules.home.controller.HomeController.renderHomePage(HomeController.java:35)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597)
org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:213)
org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:126)
org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:96)
org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:617)
org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:578)
org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:923)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:778)
javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)

root cause

java.lang.NoClassDefFoundError: javax/persistence/spi/PersistenceUnitInfo
com.objectdb.o.MSF.UJ(MSF.java:178)
com.objectdb.o.SHN.Z(SHN.java:305)
com.objectdb.o.SHN.Y(SHN.java:259)
com.objectdb.o.SHN.K(SHN.java:123)
com.objectdb.o.HND.run(HND.java:133)
java.lang.Thread.run(Thread.java:680)

root cause

java.lang.ClassNotFoundException: javax.persistence.spi.PersistenceUnitInfo
java.net.URLClassLoader$1.run(URLClassLoader.java:202)
java.security.AccessController.doPrivileged(Native Method)
java.net.URLClassLoader.findClass(URLClassLoader.java:190)
java.lang.ClassLoader.loadClass(ClassLoader.java:306)
sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
java.lang.ClassLoader.loadClass(ClassLoader.java:247)
com.objectdb.o.MSF.UJ(MSF.java:178)
com.objectdb.o.SHN.Z(SHN.java:305)
com.objectdb.o.SHN.Y(SHN.java:259)
com.objectdb.o.SHN.K(SHN.java:123)
com.objectdb.o.HND.run(HND.java:133)
java.lang.Thread.run(Thread.java:680)
#2

Please provide details on how you run the server.

Maybe you are using objectdb-jee.jar instead of objectdb.jar?

ObjectDB Support
#3

Yep that was it. My mistake.

Thanks!

Reply