i have application running on seam 2.3, ejb 3 , mysql 5.6. trying out bulk upload kinda functionality (takes values csv , saves them database)
here if records fine, gets committed database, if there incorrect record transaction fails , entity manager loses connection database. operation query.getresultset(), em.persist() fail point.
all records point error out below exception (stacktrace). using usertransaction commit 1 record @ time ... things don't rollback.
[org.hibernate.engine.jdbc.spi.sqlexceptionhelper] (http--127.0.0.1-8080-1) sql error: 0, sqlstate: null [org.hibernate.engine.jdbc.spi.sqlexceptionhelper] (http--127.0.0.1-8080-1) javax.resource.resourceexception: ij000460: error checking transaction info [stdout] (http--127.0.0.1-8080-1) role err: org.hibernate.exception.genericjdbcexception: not open connection error [stderr] (http--127.0.0.1-8080-1) javax.persistence.persistenceexception: org.hibernate.exception.genericjdbcexception: not open connection error [stderr] (http--127.0.0.1-8080-1) @ org.hibernate.ejb.abstractentitymanagerimpl.convert(abstractentitymanagerimpl.java:1361) error [stderr] (http--127.0.0.1-8080-1) @ org.hibernate.ejb.abstractentitymanagerimpl.convert(abstractentitymanagerimpl.java:1289) error [stderr] (http--127.0.0.1-8080-1) @ org.hibernate.ejb.queryimpl.getresultlist(queryimpl.java:261) ... 16:15:44,275 error [stderr] (http--127.0.0.1-8080-1) caused by: org.hibernate.exception.genericjdbcexception: not open connection 16:15:44,279 error [stderr] (http--127.0.0.1-8080-1) @ org.hibernate.exception.internal.standardsqlexceptionconverter.convert(standardsqlexceptionconverter.java:52) 16:15:44,283 error [stderr] (http--127.0.0.1-8080-1) @ org.hibernate.engine.jdbc.spi.sqlexceptionhelper.convert(sqlexceptionhelper.java:125) 16:15:44,288 error [stderr] (http--127.0.0.1-8080-1) @ org.hibernate.engine.jdbc.spi.sqlexceptionhelper.convert(sqlexceptionhelper.java:110) 16:15:44,291 error [stderr] (http--127.0.0.1-8080-1) @ org.hibernate.engine.jdbc.internal.logicalconnectionimpl.obtainconnection(logicalconnectionimpl.java:304) 16:15:44,295 error [stderr] (http--127.0.0.1-8080-1) @ org.hibernate.engine.jdbc.internal.logicalconnectionimpl.getconnection(logicalconnectionimpl.java:169) 16:15:44,298 error [stderr] (http--127.0.0.1-8080-1) @ org.hibernate.engine.jdbc.internal.proxy.connectionproxyhandler.extractphysicalconnection(connectionproxyhand ler.java:82) 16:15:44,302 error [stderr] (http--127.0.0.1-8080-1) @ org.hibernate.engine.jdbc.internal.proxy.connectionproxyhandler.continueinvocation(connectionproxyhandler.jav a:138) 16:15:44,306 error [stderr] (http--127.0.0.1-8080-1) @ org.hibernate.engine.jdbc.internal.proxy.abstractproxyhandler.invoke(abstractproxyhandler.java:81) 16:15:44,309 error [stderr] (http--127.0.0.1-8080-1) @ $proxy94.preparestatement(unknown source) 16:15:44,312 error [stderr] (http--127.0.0.1-8080-1) @ org.hibernate.engine.jdbc.internal.statementpreparerimpl$5.doprepare(statementpreparerimpl.java:147) 16:15:44,315 error [stderr] (http--127.0.0.1-8080-1) @ org.hibernate.engine.jdbc.internal.statementpreparerimpl$statementpreparationtemplate.preparestatement(statem entpreparerimpl.java:166) 16:15:44,319 error [stderr] (http--127.0.0.1-8080-1) @ org.hibernate.engine.jdbc.internal.statementpreparerimpl.preparequerystatement(statementpreparerimpl.java:145 ) ... 16:15:44,369 error [stderr] (http--127.0.0.1-8080-1) caused by: java.sql.sqlexception: javax.resource.resourceexception: ij000460: error checking transaction 16:15:44,375 error [stderr] (http--127.0.0.1-8080-1) @ org.jboss.jca.adapters.jdbc.wrapperdatasource.getconnection(wrapperdatasource.java:137) 16:15:44,380 error [stderr] (http--127.0.0.1-8080-1) @ org.hibernate.ejb.connection.injecteddatasourceconnectionprovider.getconnection(injecteddatasourceconnectionp rovider.java:67) 16:15:44,385 error [stderr] (http--127.0.0.1-8080-1) @ org.hibernate.internal.abstractsessionimpl$noncontextualjdbcconnectionaccess.obtainconnection(abstractsession impl.java:276) 16:15:44,393 error [stderr] (http--127.0.0.1-8080-1) @ org.hibernate.engine.jdbc.internal.logicalconnectionimpl.obtainconnection(logicalconnectionimpl.java:297) 16:15:44,412 error [stderr] (http--127.0.0.1-8080-1) ... 94 more 16:15:44,415 error [stderr] (http--127.0.0.1-8080-1) caused by: javax.resource.resourceexception: ij000460: error checking transaction 16:15:44,418 error [stderr] (http--127.0.0.1-8080-1) @ org.jboss.jca.core.connectionmanager.tx.txconnectionmanagerimpl.getmanagedconnection(txconnectionmanagerimpl. java:362) 16:15:44,422 error [stderr] (http--127.0.0.1-8080-1) @ org.jboss.jca.core.connectionmanager.abstractconnectionmanager.allocateconnection(abstractconnectionmanager.j ava:464) 16:15:44,427 error [stderr] (http--127.0.0.1-8080-1) @ org.jboss.jca.adapters.jdbc.wrapperdatasource.getconnection(wrapperdatasource.java:129) 16:15:44,444 error [stderr] (http--127.0.0.1-8080-1) ... 97 more 16:15:44,447 error [stderr] (http--127.0.0.1-8080-1) caused by: javax.resource.resourceexception: ij000459: transaction not active: tx=transactionimple < ac, basicac tion: 0:ffff0a6a6520:25c36e83:51de8ae5:24 status: actionstatus.abort_only > 16:15:44,464 error [stderr] (http--127.0.0.1-8080-1) @ org.jboss.jca.core.connectionmanager.tx.txconnectionmanagerimpl.getmanagedconnection(txconnectionmanagerimpl. java:352)
code snippets:
try { usertransaction utx = transaction.instance(); getrole(newuser, em, utx); commit(newuser, em, utx); log.info("after flush::::::::::::::::::::::::::::::"); }catch (exception e) { system.out.println("inside exception !!!!!!!!"); em.clear(); } public void getrole(user newuser, entitymanager em, usertransaction utx) { try { role newrole = new role(); system.out.println("is connection open: " + em.isopen()); query rolequery = em .createquery("from role role role.roleid=:roleid"); rolequery.setparameter("roleid", 1); list<role> listrole = new arraylist<>(); listrole = rolequery.getresultlist(); newuser.setrole(newrole); } catch (exception e) { system.out.println("get role err: " + e.getcause()); e.printstacktrace(); } public void commit(user newuser, entitymanager em, usertransaction utx) { try { // em.setflushmode(flushmodetype.commit); system.out.println("before utx begin"); utx.begin(); system.out.println("before em persist"); em.persist(newuser); system.out.println("before em flush"); system.out.println("before em begin: " + utx.getstatus() + ": " + utx.isactive() + ": " + utx.isnotransaction()); em.flush(); system.out.println("before em commit"); utx.commit(); } }
Comments
Post a Comment