-
Notifications
You must be signed in to change notification settings - Fork 304
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Payara does NOT rollback when RuntimeException occurs in CDI @Transactional method using JDBC #505
Comments
Log is here.
|
Thanks for the test case we will try to reproduce the problem with your test case |
The log message 2015-11-01T13:12:40.200+0900] [Payara 4.1] [INFO] [AS-JTA-00002] [javax.enterprise.resource.jta] [tid: _ThreadID=25 _ThreadName=http-listener-1(2)] [timeMillis: 1446351160200] [levelValue: 800] [[
About to setRollbackOnly from @Transactional interceptor on transaction: JavaEETransactionImpl: txId=2 nonXAResource=null jtsTx=null localTxStatus=1 syncs=[]]] Seems to suggest that the interceptor is trying to set rollback on the transaction correctly. Can you check the autocommit setting on the JDBC connection is set to false. |
Thank you for your comment and seeing my test programs. My processes are below. (1) Add property to connection pool To make sure, I add this property to my JDBC connection pool "SandboxPool" from Payara Admin Console. $ pwd
/Users/tada/Java/ap-server/payara-web-4.1.1.154-ml/bin
$ ./asadmin get "domain.resources.jdbc-connection-pool.SandboxPool.property.*"
domain.resources.jdbc-connection-pool.SandboxPool.property.UnknownLength=2147483647
domain.resources.jdbc-connection-pool.SandboxPool.property.SocketTimeout=0
domain.resources.jdbc-connection-pool.SandboxPool.property.DisableColumnSanitiser=false
domain.resources.jdbc-connection-pool.SandboxPool.property.PreparedStatementCacheSizeMiB=5
domain.resources.jdbc-connection-pool.SandboxPool.property.PrepareThreshold=5
domain.resources.jdbc-connection-pool.SandboxPool.property.SendBufferSize=-1
domain.resources.jdbc-connection-pool.SandboxPool.property.GssLib=auto
domain.resources.jdbc-connection-pool.SandboxPool.property.Url=jdbc:postgresql://localhost:5432/sandbox
domain.resources.jdbc-connection-pool.SandboxPool.property.PortNumber=0
domain.resources.jdbc-connection-pool.SandboxPool.property.ProtocolVersion=0
domain.resources.jdbc-connection-pool.SandboxPool.property.ServerName=localhost
domain.resources.jdbc-connection-pool.SandboxPool.property.LoadBalanceHosts=true
domain.resources.jdbc-connection-pool.SandboxPool.property.Loglevel=0
domain.resources.jdbc-connection-pool.SandboxPool.property.Compatible=9.4
domain.resources.jdbc-connection-pool.SandboxPool.property.AllowEncodingChanges=false
domain.resources.jdbc-connection-pool.SandboxPool.property.ReceiveBufferSize=-1
# I add this property
domain.resources.jdbc-connection-pool.SandboxPool.property.defaultAutoCommit=false
domain.resources.jdbc-connection-pool.SandboxPool.property.Password=XXXXXXXX
domain.resources.jdbc-connection-pool.SandboxPool.property.LogUnclosedConnections=false
domain.resources.jdbc-connection-pool.SandboxPool.property.SspiServiceClass=POSTGRES
domain.resources.jdbc-connection-pool.SandboxPool.property.HostRecheckSeconds=10
domain.resources.jdbc-connection-pool.SandboxPool.property.Ssl=false
domain.resources.jdbc-connection-pool.SandboxPool.property.User=XXXXXXXX
domain.resources.jdbc-connection-pool.SandboxPool.property.ReadOnly=false
domain.resources.jdbc-connection-pool.SandboxPool.property.UseSpNego=false
domain.resources.jdbc-connection-pool.SandboxPool.property.DefaultRowFetchSize=0
domain.resources.jdbc-connection-pool.SandboxPool.property.TargetServerType=any
domain.resources.jdbc-connection-pool.SandboxPool.property.TcpKeepAlive=false
domain.resources.jdbc-connection-pool.SandboxPool.property.BinaryTransfer=true
domain.resources.jdbc-connection-pool.SandboxPool.property.PreparedStatementCacheQueries=256
domain.resources.jdbc-connection-pool.SandboxPool.property.LogLevel=0
domain.resources.jdbc-connection-pool.SandboxPool.property.LoginTimeout=0
domain.resources.jdbc-connection-pool.SandboxPool.property.ConnectTimeout=0
Command get executed successfully. (2) Add Connection#setAutoCommit(false) @RequestScoped
public class JdbcCdiRequiredTestDao implements Serializable {
@Resource(lookup = "jdbc/sandbox")
private DataSource dataSource;
private Connection getNonAutoCommitConnection() throws Exception {
Connection con = dataSource.getConnection();
// set to false
con.setAutoCommit(false);
return con;
}
private int insert(TestEntity testEntity) throws Exception {
String sql = "INSERT INTO test_entity(id, thrown, rollbackon, dontrollbackon, expected) VALUES(?, ?, ?, ?, ?)";
try (Connection con = this.getNonAutoCommitConnection();
PreparedStatement ps = con.prepareStatement(sql)) {
ps.setInt(1, testEntity.getId());
ps.setString(2, testEntity.getThrown());
ps.setString(3, testEntity.getRollbackOn());
ps.setString(4, testEntity.getDontRollbackOn());
ps.setString(5, testEntity.getExpected());
int rows = ps.executeUpdate();
return rows;
}
}
/** ************************************************************************
* 01. rollbackOn={} dontRollbackOn={}
* @throws NullPointerException
* *************************************************************************
*/
@Transactional(value = Transactional.TxType.REQUIRED,
rollbackOn = {},
dontRollbackOn = {})
public void insert01RollbackOnNoDontRollbackonNoThrowsNPE(TestEntity testEntity) throws Exception {
this.insert(testEntity);
throw new NullPointerException();
}
// more methods are below (3) Run test program [2015-11-04T14:18:46.256+0900] [Payara 4.1] [INFO] [AS-JTA-00009] [javax.enterprise.resource.jta] [tid: _ThreadID=26 _ThreadName=http-listener-1(2)] [timeMillis: 1446614326256] [levelValue: 800] [[
In REQUIRED TransactionalInterceptor]]
[2015-11-04T14:18:46.259+0900] [Payara 4.1] [INFO] [AS-JTA-00010] [javax.enterprise.resource.jta] [tid: _ThreadID=26 _ThreadName=http-listener-1(2)] [timeMillis: 1446614326259] [levelValue: 800] [[
Managed bean with Transactional annotation and TxType of REQUIRED called outside a transaction context. Beginning a transaction...]]
[2015-11-04T14:18:46.289+0900] [Payara 4.1] [INFO] [AS-JTA-00009] [javax.enterprise.resource.jta] [tid: _ThreadID=26 _ThreadName=http-listener-1(2)] [timeMillis: 1446614326289] [levelValue: 800] [[
In REQUIRED TransactionalInterceptor]]
[2015-11-04T14:18:46.290+0900] [Payara 4.1] [INFO] [AS-JTA-00010] [javax.enterprise.resource.jta] [tid: _ThreadID=26 _ThreadName=http-listener-1(2)] [timeMillis: 1446614326290] [levelValue: 800] [[
Managed bean with Transactional annotation and TxType of REQUIRED called outside a transaction context. Beginning a transaction...]]
[2015-11-04T14:18:46.296+0900] [Payara 4.1] [INFO] [] [javax.enterprise.resource.jta] [tid: _ThreadID=26 _ThreadName=http-listener-1(2)] [timeMillis: 1446614326296] [levelValue: 800] [[
Error during transaction processing
java.lang.NullPointerException
at com.example.jdbc.JdbcCdiRequiredTestDao.insert01RollbackOnNoDontRollbackonNoThrowsNPE(JdbcCdiRequiredTestDao.java:89)
at com.example.jdbc.JdbcCdiRequiredTestDao$Proxy$_$$_WeldSubclass.insert01RollbackOnNoDontRollbackonNoThrowsNPE$$super(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.jboss.weld.interceptor.proxy.TerminalAroundInvokeInvocationContext.proceedInternal(TerminalAroundInvokeInvocationContext.java:49)
at org.jboss.weld.interceptor.proxy.AroundInvokeInvocationContext.proceed(AroundInvokeInvocationContext.java:77)
at org.glassfish.jersey.ext.cdi1x.transaction.internal.WebAppExceptionInterceptor.intercept(WebAppExceptionInterceptor.java:77)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.jboss.weld.interceptor.reader.SimpleInterceptorInvocation$SimpleMethodInvocation.invoke(SimpleInterceptorInvocation.java:74)
at org.jboss.weld.interceptor.proxy.NonTerminalAroundInvokeInvocationContext.proceedInternal(NonTerminalAroundInvokeInvocationContext.java:64)
at org.jboss.weld.interceptor.proxy.AroundInvokeInvocationContext.proceed(AroundInvokeInvocationContext.java:77)
at org.glassfish.cdi.transaction.TransactionalInterceptorBase.proceed(TransactionalInterceptorBase.java:226)
at org.glassfish.cdi.transaction.TransactionalInterceptorRequired.transactional(TransactionalInterceptorRequired.java:94)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.jboss.weld.interceptor.reader.SimpleInterceptorInvocation$SimpleMethodInvocation.invoke(SimpleInterceptorInvocation.java:74)
at org.jboss.weld.interceptor.proxy.InterceptorMethodHandler.executeAroundInvoke(InterceptorMethodHandler.java:84)
at org.jboss.weld.interceptor.proxy.InterceptorMethodHandler.executeInterception(InterceptorMethodHandler.java:72)
at org.jboss.weld.interceptor.proxy.InterceptorMethodHandler.invoke(InterceptorMethodHandler.java:56)
at org.jboss.weld.bean.proxy.CombinedInterceptorAndDecoratorStackMethodHandler.invoke(CombinedInterceptorAndDecoratorStackMethodHandler.java:79)
at org.jboss.weld.bean.proxy.CombinedInterceptorAndDecoratorStackMethodHandler.invoke(CombinedInterceptorAndDecoratorStackMethodHandler.java:68)
at com.example.jdbc.JdbcCdiRequiredTestDao$Proxy$_$$_WeldSubclass.insert01RollbackOnNoDontRollbackonNoThrowsNPE(Unknown Source)
at com.example.jdbc.JdbcCdiRequiredTestDao$Proxy$_$$_WeldClientProxy.insert01RollbackOnNoDontRollbackonNoThrowsNPE(Unknown Source)
at com.example.jdbc.JdbcCdiRequiredTestServlet.lambda$doGet$39(JdbcCdiRequiredTestServlet.java:28)
at com.example.jdbc.JdbcCdiRequiredTestServlet.executeQuietly(JdbcCdiRequiredTestServlet.java:80)
at com.example.jdbc.JdbcCdiRequiredTestServlet.doGet(JdbcCdiRequiredTestServlet.java:28)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:687)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1682)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:318)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:734)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:673)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:174)
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:416)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:283)
at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:459)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:167)
at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:206)
at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:180)
at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:235)
at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:283)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:200)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:132)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:111)
at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:536)
at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:112)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:117)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:56)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:137)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:591)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:571)
at java.lang.Thread.run(Thread.java:745)
]]
[2015-11-04T14:18:46.297+0900] [Payara 4.1] [INFO] [AS-JTA-00002] [javax.enterprise.resource.jta] [tid: _ThreadID=26 _ThreadName=http-listener-1(2)] [timeMillis: 1446614326297] [levelValue: 800] [[
About to setRollbackOnly from @Transactional interceptor on transaction: JavaEETransactionImpl: txId=2 nonXAResource=null jtsTx=null localTxStatus=4 syncs=[]]]
[2015-11-04T14:18:46.297+0900] [Payara 4.1] [INFO] [] [] [tid: _ThreadID=26 _ThreadName=Thread-8] [timeMillis: 1446614326297] [levelValue: 800] [[
null]] My friend who use MySQL has same problem. I'm very confused... |
We think this is a bug in upstream |
Thank you for your bug fix! |
Hello. I'm very glad about release of Payara 4.1.1.161. But, it seems this bug is NOT fixed when TxType is Please try my test program again. And if you need, please reopen this issue. |
…ayara#505) PAYARA-3153 OpenAPI doesn't support child schema on @...Param annotations - 5.183.maintenance
FISH-5801: Custom Vendor MP Metrics Using Placeholders Require 'tags'
Hello.
I tried to use JDBC+CDI+JTA in Payara Web ML 4.1.1.154.
Database is PostgreSQL 9.4, and JDBC resource named "jdbc/sandbox" is XADataSource.
My code is here.
https://github.com/MasatoshiTada/TransactionalSample-Doma/blob/master/src/main/java/com/example/jdbc/JdbcCdiRequiredTestDao.java
I think it is not in accordance with the JTA specification.
When I created DAO class as @stateless EJB, Payara rollback.
JDBC + CDI -> NG
JDBC + EJB -> OK
JPA + CDI -> OK (Why???)
JPA + EJB -> OK
Doma + CDI -> NG
Doma + EJB -> OK
(Doma is Japanese O/R mapping framework)
I hope to use Doma or MyBatis (not JPA) in Payara.
I'm very troubled by this problem.
Please check this issue.
This is my first issue comment in my life, and I'm not good at English writing...
I'm very sorry for my English writing (-:
The text was updated successfully, but these errors were encountered: