Sorry Gordon I think I
was misunderstood. We are switching persistence.xml and spring configuration
for the different usage, see below:
The application runs
in two different modes;
a) “unit testing mode” runs in J2SE with
Eclipselink configured as RESOURCE_LOCAL and Spring configured JpaTransactionManager.
b) “normal mode” runs in J2EE (Weblogic 10.3) Eclipselink
configured as JTA and Spring configured <tx:jta-transaction-manager />. This binds to the JTA Transaction manager of
Weblogic.
In normal mode (b)
the “requires_new” propagation of Spring works – in mode (a) it produces the
closedstatement.
Are you saying that
in mode (a) the REQUIRES_NEW is not supported by Eclipselink?
Regards
Thanos
From:
eclipselink-users-bounces@xxxxxxxxxxx
[mailto:eclipselink-users-bounces@xxxxxxxxxxx] On Behalf Of Gordon Yorke
Sent: Monday, May 11, 2009 10:54 PM
To: EclipseLink User Discussions
Subject: Re: [eclipselink-users] Eclipselink complains about
closedstatementinentityManager.persist()
The issue here is that the Persistence Unit is configured
for RESOURECE_LOCAL transactions but is connected to a JTA managed
datasource. With these settings EclipseLink is not aware that it is
connecting to a JTA datasource and when the new transaction starts EclipseLink
will continue to use the connection from the suspended transaction within the
new transaction. This is a problematic configuration even without the
REQUIRES_NEW setting as EclipseLink will be attempting to manage connection and
the transaction which should be managed by JTA
Also the usage of REQUIRES_NEW is not really supported by Extended Persistence
Contexts in JPA. And by "not really" I mean it will work and your changes
will be written on commit but the changes created in the suspended transaction
(unless flush() was called before beginning the new transaction) would be
written on the first flush() or commit() of the new transaction. I recommend
creating a new EntityManager for the new transaction.
--Gordon
Agelatos Athanasios wrote:
Hi and thanks for
your answer
The application runs
on Oracle Weblogic 10.3 with JTA. On unit tests it is configured with
RESOURCE_LOCAL and a DBCP or c3p0 connection pool. For the unit tests we have
configured the org.springframework.orm.jpa.JpaTransactionManager. On normal
operation (deployed on Weblogic) the configuration uses the
<tx:jta-transaction-manager /> annotation with detects and uses the JTA
transaction manager of Weblogic.
As I mentioned, we
use annotations for transactions – so the method that causes the “closed
statement” is using @Transaction(propagation=Propagation.REQUIRES_NEW) in
Springtalk..
Let me know if you
need further details
Thanks
Have you configured EclipseLink to use the connection pool
as a JTA connection pool? If you are using Application Managed Entity
Manager you will have to ensure you either create a new EntityManager for the
new transaction or use the joinTransaction API when entering the new
transaction and returning to the suspended transaction.
--Gordon
Agelatos Athanasios wrote:
Hi again
In continuation of
the previous post, we did some research and found that the “closed statement”
exception happens only when a method with Propagation.REQUIRES_NEW is used.
Does anyone have seen
this before? Any way we can make this work?
Thanks
Hi
Running Spring 2.5.6 + JUnit 4.3 and
Eclipselink 1.0.1 as JPA provider, I get the following exception as shown
below.
I’ve tried both c3p0 and
apache.commons.dbcp for connection pools, but the result is the same- it seems
that Eclipselink is closing a statement and then tries to reuse it?
Thank you for any help
Local Exception Stack:
Exception [EclipseLink-4002] (Eclipse
Persistence Services - 1.0.2 (Build 20081024)):
org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLException:
org.apache.commons.dbcp.DelegatingPreparedStatement with address:
"oracle.jdbc.driver.OraclePreparedStatementWrapper@30e71" is closed.
Error Code: 0
Call: SELECT SID, DAT_TRAD_REQ_REL,
DIV_PROH, SEALS_AFF_BY_USER_ID, TRANS_OPER_STAT_TYP_ID, DAT_STAT_UPD,
BIND_ITIN, DAT_GOODS_REL, NUMB_OF_SEALS, ARR_NOT_PLAC_LNG, ARR_SIMPL_PROC,
DEP_TRAD_ADDR, NOT_COD, ENQ_AT_DEST, DISP_COUNTRY_ID, SEALS_OK, DAT_ACC,
DEC_VIA, DEP_RISK_ANA, LOCKED, DAT_DISCR_SOLV, DAT_ARR_NOT,
ARR_AGR_GOODS_LOC_LNG, MESS_PHASE, DEST_CUST_OFF_ID, DEST_DIAL_LANG_ID,
OR_DEST_CUST_OFF_ID, ARR_AGR_GOODS_LOC, DAT_WRITT_OFF, ENQ_ALLRSP_RCD,
ARR_CUST_OFF_ID, DECL_TYP_ID, UNL_COMPL, DEP_CUST_OFF_ID, DEP_CONTR_RES_TYP_ID,
OODEP_RES_DISCR, DAT_TIM_LIM_FOR_ARR, AUD_USER_ID, DAT_STAT_UPD_NA_TRAN,
DAT_TIM_ALL_TRANS, CONTR_NAM, CONTR_BY_LNG, RISK_ANA, PROC, INC, ENQ_RCV, LRN,
CONTR_RES_SEC_COD, DAT_TIM_DEP_CONTR, TRAD_SP_AUTH_ID, AAR_SENT, TRA_RISK_ANA,
ENQ_EXP_TIMER, CONTR_REM_LNG, DAT_TIM_ARR_CONTR, DAT_ARR, NUMB_OF_LOAD_LISTS,
UNL_VERS_NUMB, Q_CUST_OFF_ID, LOCKED_DISP, MRN, STAT, SENS, DAT_DISCR_NOT,
ARR_VIA, CONTR_REM, BIND_ITIN_LNG, ARR_AGR_GOODS_LOC_COD, RISK_TIMER_STATUS,
ARR_NOT_PLAC, GUA_ACCEPTED, DEST_COUNTRY_ID, OTS_DIV_REC_BY_CUST_OFF_ID,
WAIT_FOR_INC_DOC, DAT_DOC_RET, DAT_PRINC_NOT_RESP, ARR_CONTR_RES_TYP_ID,
BIND_ITIN_FLAG, AUD_DAT_TIM, NOT_TXT, DAT_OTS_DIV_ARR_ADV, ARR_RISK_ANA,
TRANS_OPER_STAT_TYP_ID_NA_TRAN, WAIT_FOR_RES_FLAG, DAT_TIM_DES_CONTR_REC,
IS_NATIONAL, RELEASE_REQ, PRES_AT_DEST_BY_TRADS_SID, ARR_CUST_OFF_ADDR_SID FROM
TRANS_OPER WHERE (LRN = ?)
bind => [YIANNIS_TEST_HRR]
Query:
ReadAllQuery(com.intrasoft.data.jpa.TransOper)
at
org.eclipse.persistence.exceptions.DatabaseException.sqlException(DatabaseException.java:322)
at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.basicExecuteCall(DatabaseAccessor.java:646)
at
org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeCall(DatabaseAccessor.java:500)
at org.eclipse.persistence.internal.sessions.AbstractSession.executeCall(AbstractSession.java:855)
at
org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:204)
at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:190)
at
org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeSelectCall(DatasourceCallQueryMechanism.java:261)
at
org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.selectAllRows(DatasourceCallQueryMechanism.java:594)
at
org.eclipse.persistence.internal.queries.ExpressionQueryMechanism.selectAllRowsFromTable(ExpressionQueryMechanism.java:2506)
at
org.eclipse.persistence.internal.queries.ExpressionQueryMechanism.selectAllRows(ExpressionQueryMechanism.java:2464)
at org.eclipse.persistence.queries.ReadAllQuery.executeObjectLevelReadQuery(ReadAllQuery.java:478)
at
org.eclipse.persistence.queries.ObjectLevelReadQuery.executeDatabaseQuery(ObjectLevelReadQuery.java:879)
at org.eclipse.persistence.queries.DatabaseQuery.execute(DatabaseQuery.java:666)
at
org.eclipse.persistence.queries.ObjectLevelReadQuery.execute(ObjectLevelReadQuery.java:840)
at org.eclipse.persistence.queries.ReadAllQuery.execute(ReadAllQuery.java:456)
at
org.eclipse.persistence.queries.ObjectLevelReadQuery.executeInUnitOfWork(ObjectLevelReadQuery.java:902)
at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.internalExecuteQuery(UnitOfWorkImpl.java:2587)
at
org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1178)
at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1162)
at
org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1136)
at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1118)
at
org.eclipse.persistence.internal.jpa.EJBQueryImpl.executeReadQuery(EJBQueryImpl.java:399)
at
org.eclipse.persistence.internal.jpa.EJBQueryImpl.getSingleResult(EJBQueryImpl.java:547)
at
com.intrasoft.enterprise.services.spring.impl.DBUtils.retrieveTransOper(DBUtils.java:136)
at
com.intrasoft.enterprise.services.spring.impl.DeclarationManagerImpl.saveDeclarationData(DeclarationManagerImpl.java:217)
at com.intrasoft.enterprise.services.spring.impl.DeclarationManagerImpl$$FastClassByCGLIB$$e2cbb956.invoke(<generated>)
at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149)
at org.springframework.aop.framework.Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint(Cglib2AopProxy.java:700)
at
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
at org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:77)
at
com.intrasoft.enterprise.services.spring.impl.utils.LoggingAspect.log(LoggingAspect.java:74)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at
org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:627)
at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:616)
at
org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:64)
at
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at
org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
at
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at
org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
at
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at
org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
at
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at
org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:635)
at
com.intrasoft.enterprise.services.spring.impl.DeclarationManagerImpl$$EnhancerByCGLIB$$7e5fddbd.saveDeclarationData(<generated>)
at
com.intrasoft.enterprise.messaging.spring.impl.HandleReleaseRequestImpl.handleReleaseRequest(HandleReleaseRequestImpl.java:190)
at
com.intrasoft.enterprise.messaging.spring.impl.HandleReleaseRequestImpl$$FastClassByCGLIB$$28aeb121.invoke(<generated>)
at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149)
at
org.springframework.aop.framework.Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint(Cglib2AopProxy.java:700)
at
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
at
org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:77)
at
com.intrasoft.enterprise.services.spring.impl.utils.LoggingAspect.log(LoggingAspect.java:74)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:627)
at
org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:616)
at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:64)
at
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
at
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
at
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:635)
at
com.intrasoft.enterprise.messaging.spring.impl.HandleReleaseRequestImpl$$EnhancerByCGLIB$$8a719346.handleReleaseRequest(<generated>)
at com.intrasoft.enterprise.tests.HandleReleaseRequestTest.testHandleReleaseRequestAlt2(HandleReleaseRequestTest.java:169)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.springframework.test.context.junit4.SpringTestMethod.invoke(SpringTestMethod.java:160)
at
org.springframework.test.context.junit4.SpringMethodRoadie.runTestMethod(SpringMethodRoadie.java:233)
at org.springframework.test.context.junit4.SpringMethodRoadie$RunBeforesThenTestThenAfters.run(SpringMethodRoadie.java:333)
at
org.springframework.test.context.junit4.SpringMethodRoadie.runWithRepetitions(SpringMethodRoadie.java:217)
at org.springframework.test.context.junit4.SpringMethodRoadie.runTest(SpringMethodRoadie.java:197)
at
org.springframework.test.context.junit4.SpringMethodRoadie.run(SpringMethodRoadie.java:143)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.invokeTestMethod(SpringJUnit4ClassRunner.java:160)
at
org.junit.internal.runners.JUnit4ClassRunner.runMethods(JUnit4ClassRunner.java:51)
at org.junit.internal.runners.JUnit4ClassRunner$1.run(JUnit4ClassRunner.java:44)
at org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:27)
at org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:37)
at org.junit.internal.runners.JUnit4ClassRunner.run(JUnit4ClassRunner.java:42)
at
org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:97)
at
org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:45)
at
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Caused by: java.sql.SQLException:
org.apache.commons.dbcp.DelegatingPreparedStatement with address:
"oracle.jdbc.driver.OraclePreparedStatementWrapper@30e71" is closed.
at org.apache.commons.dbcp.DelegatingStatement.checkOpen(DelegatingStatement.java:137)
at
org.apache.commons.dbcp.DelegatingPreparedStatement.setString(DelegatingPreparedStatement.java:132)
at org.eclipse.persistence.internal.databaseaccess.DatabasePlatform.setParameterValueInDatabaseCall(DatabasePlatform.java:1734)
at
org.eclipse.persistence.internal.databaseaccess.DatabaseCall.prepareStatement(DatabaseCall.java:667)
at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.basicExecuteCall(DatabaseAccessor.java:550)
... 90 more

Internet
communications are not secure;
therefore, the integrity of this e-mail cannot be guaranteed following
transmission on the Internet.
This e-mail may contain confidential information. If you have received this e-mail
in error, please notify the sender and erase this e-mail. Use of this e-mail by
any person other than the addressee is strictly forbidden. This e-mail is
believed to be free of any virus that might adversely affect the addressee's
computer system; however, no responsibility is accepted for any loss or damage
arising in any way from its use. All the preceding disclaimers also apply to
any possible attachments to this e-mail.
Internet
communications are not secure;
therefore, the integrity of this e-mail cannot be guaranteed following
transmission on the Internet.
This e-mail may contain confidential information. If you have received this e-mail
in error, please notify the sender and erase this e-mail. Use of this e-mail by
any person other than the addressee is strictly forbidden. This e-mail is
believed to be free of any virus that might adversely affect the addressee's
computer system; however, no responsibility is accepted for any loss or damage
arising in any way from its use. All the preceding disclaimers also apply to
any possible attachments to this e-mail.
_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users
Internet
communications are not secure;
therefore, the integrity of this e-mail cannot be guaranteed following
transmission on the Internet.
This e-mail may contain confidential information. If you have received this
e-mail in error, please notify the sender and erase this e-mail. Use of this e-mail
by any person other than the addressee is strictly forbidden. This e-mail is
believed to be free of any virus that might adversely affect the addressee's
computer system; however, no responsibility is accepted for any loss or damage
arising in any way from its use. All the preceding disclaimers also apply to
any possible attachments to this e-mail.
_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users