Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » NPE running JPA with Spring 2.5 & Tomcat 5
NPE running JPA with Spring 2.5 & Tomcat 5 [message #381080] Thu, 04 September 2008 08:22 Go to next message
Rama Notowidigdo is currently offline Rama Notowidigdo
Messages: 19
Registered: July 2009
Junior Member
Hi All,

I"m running into the following issue. The same code works fine in the
test but when I deployed to Tomcat. I'm getting the following NPE.

Any hint or clues? All it's doing is trying to execute the simple
findAll.


java.lang.NullPointerException

org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl. addStructConverters(EntityManagerSetupImpl.java:317)
org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl. deploy(EntityManagerSetupImpl.java:247)
org.eclipse.persistence.internal.jpa.EntityManagerFactoryImp l.getServerSession(EntityManagerFactoryImpl.java:69)
org.eclipse.persistence.internal.jpa.EntityManagerFactoryImp l.createEntityManagerImpl(EntityManagerFactoryImpl.java:118)
org.eclipse.persistence.internal.jpa.EntityManagerFactoryImp l.createEntityManagerImpl(EntityManagerFactoryImpl.java:112)
org.eclipse.persistence.internal.jpa.EntityManagerFactoryImp l.createEntityManager(EntityManagerFactoryImpl.java:100)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcce ssorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMe thodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597)
org.springframework.orm.jpa.AbstractEntityManagerFactoryBean $ManagedEntityManagerFactoryInvocationHandler.invoke(Abstrac tEntityManagerFactoryBean.java:434)
$Proxy10.createEntityManager(Unknown Source)
org.springframework.orm.jpa.SharedEntityManagerCreator$Share dEntityManagerInvocationHandler.invoke(SharedEntityManagerCr eator.java:189)
$Proxy22.createQuery(Unknown Source)
com.gomper.persistence.ProfileDAO.findAll(ProfileDAO.java:39 )
com.gomper.service.RegistrationManager.getAllRegistration(Re gistrationManager.java:32)
com.gomper.web.RegistrationController.getAllRegistration(Reg istrationController.java:37)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcce ssorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMe thodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597)
org.springframework.web.bind.annotation.support.HandlerMetho dInvoker.doInvokeMethod(HandlerMethodInvoker.java:409)
org.springframework.web.bind.annotation.support.HandlerMetho dInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:132)
org.springframework.web.servlet.mvc.annotation.AnnotationMet hodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandle rAdapter.java:310)
org.springframework.web.servlet.mvc.annotation.AnnotationMet hodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java :297)
org.springframework.web.servlet.DispatcherServlet.doDispatch (DispatcherServlet.java:875)
org.springframework.web.servlet.DispatcherServlet.doService( DispatcherServlet.java:809)
org.springframework.web.servlet.FrameworkServlet.processRequ est(FrameworkServlet.java:571)
org.springframework.web.servlet.FrameworkServlet.doGet(Frame workServlet.java:501)
javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

Thanks.
Re: NPE running JPA with Spring 2.5 & Tomcat 5 [message #381081 is a reply to message #381080] Thu, 04 September 2008 18:22 Go to previous messageGo to next message
Rama Notowidigdo is currently offline Rama Notowidigdo
Messages: 19
Registered: July 2009
Junior Member
I upgraded to Eclipselink 1.0.1 M3. Any shed of light?

Now I'm getting the following exception.

java.lang.IllegalStateException: Attempting to execute an operation on a
closed EntityManager.
org.eclipse.persistence.internal.jpa.EntityManagerImpl.verif yOpen(EntityManagerImpl.java:849)
org.eclipse.persistence.internal.jpa.EJBQueryImpl.getResultL ist(EJBQueryImpl.java:502)
com.gomper.persistence.ProfileDAO.findAll(ProfileDAO.java:39 )
com.gomper.service.RegistrationManager.getAllRegistration(Re gistrationManager.java:32)
com.gomper.web.RegistrationController.getAllRegistration(Reg istrationController.java:37)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcce ssorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMe thodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597)
org.springframework.web.bind.annotation.support.HandlerMetho dInvoker.doInvokeMethod(HandlerMethodInvoker.java:409)
org.springframework.web.bind.annotation.support.HandlerMetho dInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:132)
org.springframework.web.servlet.mvc.annotation.AnnotationMet hodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandle rAdapter.java:310)
org.springframework.web.servlet.mvc.annotation.AnnotationMet hodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java :297)
org.springframework.web.servlet.DispatcherServlet.doDispatch (DispatcherServlet.java:875)
org.springframework.web.servlet.DispatcherServlet.doService( DispatcherServlet.java:809)
org.springframework.web.servlet.FrameworkServlet.processRequ est(FrameworkServlet.java:571)
org.springframework.web.servlet.FrameworkServlet.doGet(Frame workServlet.java:501)
javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
Re: NPE running JPA with Spring 2.5 & Tomcat 5 [message #381267 is a reply to message #381081] Sat, 06 September 2008 00:30 Go to previous messageGo to next message
Rama Notowidigdo is currently offline Rama Notowidigdo
Messages: 19
Registered: July 2009
Junior Member
Hi All,

This is getting down frustrating that the behavior is so flaky.

I have Spring 2.5, Tomcat6 and EclipseLink 1.0M11.

The following is what my method have:

@Transactional (propagation= Propagation.REQUIRED)
public void save(BaseModel anObject) {
anObject.setUpdatedTime(new Date(System.currentTimeMillis()));
this.getEntityManager().merge(anObject);
this.getEntityManager().flush();
}

One time it would work fine and most time it will give the following
exception.
And this is not used concurrently yet. Any help is appreciated. I've
been stuck with this for a week.


org.springframework.web.util.NestedServletException: Request processing
failed; nested exception is
javax.persistence.TransactionRequiredException:
Exception Description: No transaction is currently active
org.springframework.web.servlet.FrameworkServlet.processRequ est(FrameworkServlet.java:583)
org.springframework.web.servlet.FrameworkServlet.doGet(Frame workServlet.java:501)
javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

root cause

javax.persistence.TransactionRequiredException:
Exception Description: No transaction is currently active
org.eclipse.persistence.internal.jpa.transaction.EntityTrans actionWrapper.throwCheckTransactionFailedException(EntityTra nsactionWrapper.java:109)
org.eclipse.persistence.internal.jpa.transaction.EntityTrans actionWrapper.checkForTransaction(EntityTransactionWrapper.j ava:50)
org.eclipse.persistence.internal.jpa.EntityManagerImpl.check ForTransaction(EntityManagerImpl.java:898)
org.eclipse.persistence.internal.jpa.EntityManagerImpl.flush (EntityManagerImpl.java:384)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcce ssorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMe thodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597)
org.springframework.orm.jpa.ExtendedEntityManagerCreator$Ext endedEntityManagerInvocationHandler.invoke(ExtendedEntityMan agerCreator.java:358)
$Proxy22.flush(Unknown Source)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcce ssorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMe thodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597)
org.springframework.orm.jpa.SharedEntityManagerCreator$Share dEntityManagerInvocationHandler.invoke(SharedEntityManagerCr eator.java:197)
$Proxy22.flush(Unknown Source)
com.gomper.persistence.BaseDAO.save(BaseDAO.java:41)
com.gomper.service.RegistrationManager.register(Registration Manager.java:27)
com.gomper.web.RegistrationController.delete(RegistrationCon troller.java:56)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcce ssorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMe thodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597)
org.springframework.web.bind.annotation.support.HandlerMetho dInvoker.doInvokeMethod(HandlerMethodInvoker.java:409)
org.springframework.web.bind.annotation.support.HandlerMetho dInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:132)
org.springframework.web.servlet.mvc.annotation.AnnotationMet hodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandle rAdapter.java:310)
org.springframework.web.servlet.mvc.annotation.AnnotationMet hodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java :297)
org.springframework.web.servlet.DispatcherServlet.doDispatch (DispatcherServlet.java:875)
org.springframework.web.servlet.DispatcherServlet.doService( DispatcherServlet.java:809)
org.springframework.web.servlet.FrameworkServlet.processRequ est(FrameworkServlet.java:571)
org.springframework.web.servlet.FrameworkServlet.doGet(Frame workServlet.java:501)
javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
Re: NPE running JPA with Spring 2.5 & Tomcat 5 [message #381268 is a reply to message #381267] Sat, 06 September 2008 00:31 Go to previous messageGo to next message
Rama Notowidigdo is currently offline Rama Notowidigdo
Messages: 19
Registered: July 2009
Junior Member
BTW, if I attached JPDA it seems to work fine. So it looks like there is
racing condition that's happening internally.
Re: NPE running JPA with Spring 2.5 & Tomcat 5 [message #381269 is a reply to message #381267] Sat, 06 September 2008 00:57 Go to previous message
Rama Notowidigdo is currently offline Rama Notowidigdo
Messages: 19
Registered: July 2009
Junior Member
Problem solved, issue is with AOP.

I need to put the following in my aop.xml:

<?xml version="1.0"?>
<aspectj>
<weaver options="-showWeaveInfo
-XmessageHandlerClass:org.springframework.aop.aspectj.Aspect JWeaverMessageHandler ">
<include within="com.gomper..*"/>
</weaver>
</aspectj>


This is to ensure that it uses the right weaver.
Previous Topic:Join-Fetch with 1--> 0..N Cardinality
Next Topic:Exception [EclipseLink-30005] - Persistence FAILED
Goto Forum:
  


Current Time: Fri Oct 31 10:55:21 GMT 2014

Powered by FUDForum. Page generated in 0.01844 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software