Tuesday, February 16, 2010

"Error: Could not open JPA EntityManager" problem on EclipseLink

When you use JPA and EclipseLink 2.0 and get this error:

HTTP Status 500 -


type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: Could not open JPA EntityManager for transaction; nested exception is javax.persistence.PersistenceException: Exception [EclipseLink-0] (Eclipse Persistence Services - 2.0.0.v20091127-r5931): org.eclipse.persistence.exceptions.IntegrityException
Descriptor Exceptions: 
---------------------------------------------------------

Exception [EclipseLink-60] (Eclipse Persistence Services - 2.0.0.v20091127-r5931): org.eclipse.persistence.exceptions.DescriptorException
Exception Description: The method [_persistence_setperson_vh] or [_persistence_getperson_vh] is not defined in the object [com.googlecode.pu1.domain.PersonDetail].
Internal Exception: java.lang.NoSuchMethodException: com.googlecode.pu1.domain.PersonDetail._persistence_getperson_vh()
Mapping: org.eclipse.persistence.mappings.OneToOneMapping[person]
Descriptor: RelationalDescriptor(com.googlecode.pu1.domain.PersonDetail --> [DatabaseTable(PERSONDETAIL)])

Runtime Exceptions: 
---------------------------------------------------------

java.lang.NullPointerException

 javax.faces.webapp.FacesServlet.service(FacesServlet.java:325)
root cause
org.springframework.transaction.CannotCreateTransactionException: Could not open JPA EntityManager for transaction; nested exception is javax.persistence.PersistenceException: Exception [EclipseLink-0] (Eclipse Persistence Services - 2.0.0.v20091127-r5931): org.eclipse.persistence.exceptions.IntegrityException
Descriptor Exceptions: 
---------------------------------------------------------

Exception [EclipseLink-60] (Eclipse Persistence Services - 2.0.0.v20091127-r5931): org.eclipse.persistence.exceptions.DescriptorException
Exception Description: The method [_persistence_setperson_vh] or [_persistence_getperson_vh] is not defined in the object [com.googlecode.pu1.domain.PersonDetail].
Internal Exception: java.lang.NoSuchMethodException: com.googlecode.pu1.domain.PersonDetail._persistence_getperson_vh()
Mapping: org.eclipse.persistence.mappings.OneToOneMapping[person]
Descriptor: RelationalDescriptor(com.googlecode.pu1.domain.PersonDetail --> [DatabaseTable(PERSONDETAIL)])

Runtime Exceptions: 
---------------------------------------------------------

java.lang.NullPointerException

 org.springframework.orm.jpa.JpaTransactionManager.doBegin(JpaTransactionManager.java:382)
 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:102)
 org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
 org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
 $Proxy22.findAll(Unknown Source)
 com.googlecode.sandcode.helloworld.HelloWorld.getName(HelloWorld.java:29)
 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)
 javax.el.BeanELResolver.getValue(BeanELResolver.java:302)
 javax.el.CompositeELResolver.getValue(CompositeELResolver.java:175)
 com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:72)
 com.sun.el.parser.AstValue.getValue(AstValue.java:116)
 com.sun.el.parser.AstValue.getValue(AstValue.java:163)
 com.sun.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:219)
 com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:102)
 javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:190)
 javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:178)
 javax.faces.component.UIOutput.getValue(UIOutput.java:168)
 com.sun.faces.renderkit.html_basic.HtmlBasicInputRenderer.getValue(HtmlBasicInputRenderer.java:205)
 com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.getCurrentValue(HtmlBasicRenderer.java:338)
 com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeEnd(HtmlBasicRenderer.java:164)
 javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:878)
 javax.faces.component.UIComponent.encodeAll(UIComponent.java:1620)
 javax.faces.render.Renderer.encodeChildren(Renderer.java:168)
 javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:848)
 javax.faces.component.UIComponent.encodeAll(UIComponent.java:1613)
 javax.faces.component.UIComponent.encodeAll(UIComponent.java:1616)
 javax.faces.component.UIComponent.encodeAll(UIComponent.java:1616)
 com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:380)
 com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:126)
 com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:127)
 com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
 com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
 javax.faces.webapp.FacesServlet.service(FacesServlet.java:313)
root cause
javax.persistence.PersistenceException: Exception [EclipseLink-0] (Eclipse Persistence Services - 2.0.0.v20091127-r5931): org.eclipse.persistence.exceptions.IntegrityException
Descriptor Exceptions: 
---------------------------------------------------------

Exception [EclipseLink-60] (Eclipse Persistence Services - 2.0.0.v20091127-r5931): org.eclipse.persistence.exceptions.DescriptorException
Exception Description: The method [_persistence_setperson_vh] or [_persistence_getperson_vh] is not defined in the object [com.googlecode.pu1.domain.PersonDetail].
Internal Exception: java.lang.NoSuchMethodException: com.googlecode.pu1.domain.PersonDetail._persistence_getperson_vh()
Mapping: org.eclipse.persistence.mappings.OneToOneMapping[person]
Descriptor: RelationalDescriptor(com.googlecode.pu1.domain.PersonDetail --> [DatabaseTable(PERSONDETAIL)])

Runtime Exceptions: 
---------------------------------------------------------

java.lang.NullPointerException

 org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:392)
 org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.getServerSession(EntityManagerFactoryImpl.java:151)
 org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManagerImpl(EntityManagerFactoryImpl.java:207)
 org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:195)
 org.springframework.orm.jpa.JpaTransactionManager.createEntityManagerForTransaction(JpaTransactionManager.java:400)
 org.springframework.orm.jpa.JpaTransactionManager.doBegin(JpaTransactionManager.java:321)
 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:102)
 org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
 org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
 $Proxy22.findAll(Unknown Source)
 com.googlecode.sandcode.helloworld.HelloWorld.getName(HelloWorld.java:29)
 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)
 javax.el.BeanELResolver.getValue(BeanELResolver.java:302)
 javax.el.CompositeELResolver.getValue(CompositeELResolver.java:175)
 com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:72)
 com.sun.el.parser.AstValue.getValue(AstValue.java:116)
 com.sun.el.parser.AstValue.getValue(AstValue.java:163)
 com.sun.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:219)
 com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:102)
 javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:190)
 javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:178)
 javax.faces.component.UIOutput.getValue(UIOutput.java:168)
 com.sun.faces.renderkit.html_basic.HtmlBasicInputRenderer.getValue(HtmlBasicInputRenderer.java:205)
 com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.getCurrentValue(HtmlBasicRenderer.java:338)
 com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeEnd(HtmlBasicRenderer.java:164)
 javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:878)
 javax.faces.component.UIComponent.encodeAll(UIComponent.java:1620)
 javax.faces.render.Renderer.encodeChildren(Renderer.java:168)
 javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:848)
 javax.faces.component.UIComponent.encodeAll(UIComponent.java:1613)
 javax.faces.component.UIComponent.encodeAll(UIComponent.java:1616)
 javax.faces.component.UIComponent.encodeAll(UIComponent.java:1616)
 com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:380)
 com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:126)
 com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:127)
 com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
 com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
 javax.faces.webapp.FacesServlet.service(FacesServlet.java:313)
root cause
Exception [EclipseLink-0] (Eclipse Persistence Services - 2.0.0.v20091127-r5931): org.eclipse.persistence.exceptions.IntegrityException
Descriptor Exceptions: 
---------------------------------------------------------

Exception [EclipseLink-60] (Eclipse Persistence Services - 2.0.0.v20091127-r5931): org.eclipse.persistence.exceptions.DescriptorException
Exception Description: The method [_persistence_setperson_vh] or [_persistence_getperson_vh] is not defined in the object [com.googlecode.pu1.domain.PersonDetail].
Internal Exception: java.lang.NoSuchMethodException: com.googlecode.pu1.domain.PersonDetail._persistence_getperson_vh()
Mapping: org.eclipse.persistence.mappings.OneToOneMapping[person]
Descriptor: RelationalDescriptor(com.googlecode.pu1.domain.PersonDetail --> [DatabaseTable(PERSONDETAIL)])

Runtime Exceptions: 
---------------------------------------------------------

java.lang.NullPointerException

 org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.initializeDescriptors(DatabaseSessionImpl.java:478)
 org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.initializeDescriptors(DatabaseSessionImpl.java:406)
 org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.postConnectDatasource(DatabaseSessionImpl.java:671)
 org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.login(DatabaseSessionImpl.java:633)
 org.eclipse.persistence.internal.jpa.EntityManagerFactoryProvider.login(EntityManagerFactoryProvider.java:230)
 org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:368)
 org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.getServerSession(EntityManagerFactoryImpl.java:151)
 org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManagerImpl(EntityManagerFactoryImpl.java:207)
 org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:195)
 org.springframework.orm.jpa.JpaTransactionManager.createEntityManagerForTransaction(JpaTransactionManager.java:400)
 org.springframework.orm.jpa.JpaTransactionManager.doBegin(JpaTransactionManager.java:321)
 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:102)
 org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
 org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
 $Proxy22.findAll(Unknown Source)
 com.googlecode.sandcode.helloworld.HelloWorld.getName(HelloWorld.java:29)
 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)
 javax.el.BeanELResolver.getValue(BeanELResolver.java:302)
 javax.el.CompositeELResolver.getValue(CompositeELResolver.java:175)
 com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:72)
 com.sun.el.parser.AstValue.getValue(AstValue.java:116)
 com.sun.el.parser.AstValue.getValue(AstValue.java:163)
 com.sun.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:219)
 com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:102)
 javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:190)
 javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:178)
 javax.faces.component.UIOutput.getValue(UIOutput.java:168)
 com.sun.faces.renderkit.html_basic.HtmlBasicInputRenderer.getValue(HtmlBasicInputRenderer.java:205)
 com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.getCurrentValue(HtmlBasicRenderer.java:338)
 com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeEnd(HtmlBasicRenderer.java:164)
 javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:878)
 javax.faces.component.UIComponent.encodeAll(UIComponent.java:1620)
 javax.faces.render.Renderer.encodeChildren(Renderer.java:168)
 javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:848)
 javax.faces.component.UIComponent.encodeAll(UIComponent.java:1613)
 javax.faces.component.UIComponent.encodeAll(UIComponent.java:1616)
 javax.faces.component.UIComponent.encodeAll(UIComponent.java:1616)
 com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:380)
 com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:126)
 com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:127)
 com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
 com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
 javax.faces.webapp.FacesServlet.service(FacesServlet.java:313)
note The full stack trace of the root cause is available in the Apache Tomcat/6.0.20 logs.

Apache Tomcat/6.0.20


Although the Exception list is very long, it boils down to one thing:

The JPA entity classes should be statically woven first by EclipseLink.

During project build, EclipseLink must be configured to weave your JPA entity classes.

You can also configure EclipseLink static weaving using Maven:
<build>
 <plugins>
   <plugin>
     <artifactId>maven-antrun-plugin</artifactId>
     <executions>
       <execution>
         <phase>process-classes</phase>
         <configuration>
           <tasks>
             <java classname="org.eclipse.persistence.tools.weaving.jpa.StaticWeave"
                   classpathref="maven.runtime.classpath" fork="true">
               <arg line="-loglevel FINE -persistenceinfo src/main/resources target/classes target/classes"/>
             </java>
           </tasks>
         </configuration>
         <goals>
           <goal>run</goal>
         </goals>
       </execution>
     </executions>
   </plugin>
 </plugins>
</build>
In addition, edit your META/INF/persistence.xml and add this property:
<property name="eclipselink.weaving" value="static" />

5 comments:

Anonymous said...

thnxx this helps me to solve a problem I have been searching for 2days!!!

coach factore outlet said...

Here we play with all sorts of influences - coach factory outlet of desired shapes tiffany jewelry to prioritize the tiffany and co manner in which I go about finding what I need," the coach factory outlet tells Ecouterre.More than 1,000 runners began the race.Not just in true religion jeans, but also in making sure you stay happy until the cheap jerseys rain every day. Hey, $350 is way less than those coach outlet. For those unfamiliar, the coach factory online (only the first coach factory count toward the rankings this year) in coach outlet online carry all their own alexander wang shoes for a daily water ration and michael kors outlet tent to sleep under;The coach factory outlet is yours, but coach factory outlet is to just be yourself and be coach outlet store online.The sleek ensemble came on show through sac burberry. Choose from brands like Bernardo, michael kors outlet and others.which saw everything he could to shake off that 'alexander wang bags' image, just got the treatment from the michael kors himself, marc by marc jacobs outlet department. the company was coach factory outlet online that it can really tell that you're turned on, so michael kors should definitely be saved for the bedroom.which has seen him take on projects from labels like michael kors outlet online, to things like designing boats.

Eric Simmons said...

Great and Useful Article.

Online Java Course

Java Online Training

Java Course Online

J2EE training

online J2EE training

Best Recommended books for Spring framework

Java Interview Questions








Java Training Institutes in Chennai

Java Training in Chennai

J2EE Training in Chennai

java j2ee training institutes in chennai

Java Course in Chennai

Getit said...

Superb post.Download Zapya for PC, Zapya free download, Zapya download, Zapya apk to share files and folders

Nithyanantham M said...

Thanks for sharing this post
Dailymotion video downloader

Try Dailymotion video
downloader
to download videos from dailymotion.

Post a Comment

 
Copyright 2009 Spring vs Java EE Web Dev. Powered by Blogger Blogger Templates create by Deluxe Templates. WP by Masterplan