Hello.
'org.jboss.tm.JBossRollbackException' is generated, and rollback cannot be done 
though RuntimeException came to be able to do 
in catche by using '@ApplicationException(rollback=true)' as advised.
Is there a problem in the writing of the code? 
Or, is it a setting of Jboss and is there anything necessary?
May I have the known person advice?
It asks suitably. 



My Exception Class: 

  | @ApplicationException(rollback=true)
  | public class MyAppException extends Exception{
  |     
  |     public MyAppException(){}
  |     public MyAppException(String msg){
  |             super(msg);
  |     }
  | }
  | 


Stateless Session Bean Class: 

  | @Stateless
  | @Local(TestSession.class)
  | @Remote(TestSession.class)
  | 
  | public class TestSessionBean  implements TestSession{
  |     @PersistenceContext
  |     protected  EntityManager em;
  |     
  |     @TransactionAttribute(TransactionAttributeType.REQUIRED)
  |     public void insertTestUser(TestUserBean usrs) throws MyAppException{
  |             em.persist(usrs);
  |     }
  | }
  | 


Servlet Class: 

  |     public Value doBiz(Hashtable param, HttpServletRequest req){
  |             String  page = "/jsp/test/TestEntryEnd.jsp";
  |             Value value = new Value();
  |             
  |             try{
  |                     TestUserBean usrs = new TestUserBean();
  |                     usrs.setTestUserId(1);
  |                     usrs.setTestName("test name");
  |                     
  |                     /* DB insert */
  |                     TestService service = new TestService();
  |                     service.insertTestUser(usrs);
  |                     
  |                     /* To cause the exception, the data of same ID is 
inserted again. */
  |                     TestUserBean usrs2 = new TestUserBean();
  |                     usrs2.setTestUserId(1);
  |                     usrs2.setTestName("test name2");
  |                     
  |                     service.insertTestUser(usrs2);
  |                     
  |                     value.setForwardPage(page);
  |             }catch(Exception ex){
  |                     System.out.println("***** TestEntryEnd.doBiz catch ex = 
" + ex);
  |                     value.addErrorMessage("TestEntryEnd Error");
  |                     value.setError(true);
  |             }
  |             return value;
  |     }
  | 

Error stack trace
12:30:14,603 WARN  [JDBCExceptionReporter] SQL Error: 0, SQLState: null
12:30:14,603 ERROR [JDBCExceptionReporter] Batch entry 0 insert into testmail 
(testMail, testUserId, testMailId) values (13, 13, 13) was aborted.  Call 
getNextException to see the cause.
12:30:14,603 WARN  [JDBCExceptionReporter] SQL Error: 0, SQLState: 23505
12:30:14,603 ERROR [JDBCExceptionReporter] ERROR: duplicate key violates unique 
constraint "testmail_pkey"
12:30:14,604 ERROR [AbstractFlushingEventListener] Could not synchronize 
database state with session
org.hibernate.exception.ConstraintViolationException: Could not execute JDBC 
batch update
        at 
org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:69)
        at 
org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
        at 
org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:202)
        at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:230)
        at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:140)
        at 
org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:296)
        at 
org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
        at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1009)
        at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:356)
        at 
org.hibernate.transaction.CacheSynchronization.beforeCompletion(CacheSynchronization.java:59)
        at 
org.jboss.tm.TransactionImpl.doBeforeCompletion(TransactionImpl.java:1473)
        at org.jboss.tm.TransactionImpl.beforePrepare(TransactionImpl.java:1092)
        at org.jboss.tm.TransactionImpl.commit(TransactionImpl.java:306)
        at org.jboss.aspects.tx.TxPolicy.endTransaction(TxPolicy.java:175)
        at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:87)
        at 
org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:192)
        at 
org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
        at 
org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:76)
        at 
org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
        at 
org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:54)
        at 
org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
        at 
org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:78)
        at 
org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
        at 
org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:47)
        at 
org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
        at 
org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
        at 
org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
        at 
org.jboss.ejb3.stateless.StatelessContainer.localInvoke(StatelessContainer.java:178)
        at 
org.jboss.ejb3.stateless.StatelessLocalProxy.invoke(StatelessLocalProxy.java:74)
        at $Proxy112.insertTestMail(Unknown Source)
        at TestService.insertTestMail(TestService.java:55)
        at TestEntryEnd.doBiz(TestEntryEnd.java:73)
        at TestServlet.service(TestServlet.java:95)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
        at 
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
        at 
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
        at 
org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)
        at 
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
        at 
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
        at 
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
        at 
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
        at 
org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:39)
        at 
org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:159)
        at 
org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:59)
        at 
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
        at 
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
        at 
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
        at 
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
        at 
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
        at 
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
        at 
org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
        at 
org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
        at java.lang.Thread.run(Thread.java:595)
Caused by: java.sql.BatchUpdateException: Batch entry 0 insert into testmail 
(testMail, testUserId, testMailId) values (13, 13, 13) was aborted.  Call 
getNextException to see the cause.
        at 
org.postgresql.jdbc2.AbstractJdbc2Statement$BatchResultHandler.handleError(AbstractJdbc2Statement.java:2497)
        at 
org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1298)
        at 
org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:347)
        at 
org.postgresql.jdbc2.AbstractJdbc2Statement.executeBatch(AbstractJdbc2Statement.java:2559)
        at 
org.jboss.resource.adapter.jdbc.WrappedStatement.executeBatch(WrappedStatement.java:487)
        at 
org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:58)
        at 
org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:195)
        ... 50 more
12:30:14,616 INFO  [STDOUT] ***** TestEntryEnd.doBiz catch ex = 
java.lang.RuntimeException: org.jboss.tm.JBossRollbackException: Unable to 
commit, tx=TransactionImpl:XidImpl[FormatId=257, GlobalId=22, BranchQual=, 
localId=22] status=STATUS_NO_TRANSACTION; - nested throwable: 
(org.hibernate.exception.ConstraintViolationException: Could not execute JDBC 
batch update)


View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3950368#3950368

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3950368


_______________________________________________
JBoss-user mailing list
JBoss-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to