2 Replies Latest reply on Sep 8, 2008 6:41 AM by Kumar Jaya

    JBoss Transaction Manager Exception Handling

    Kumar Jaya Newbie

      I am using JBoss4.2.2, EJB 3.0 along with Hibernate. Suppose I insert an row into my table which has an invalid column length may be more than I have declared in my table. I get an exception in the code. I am catching the exception within my code with a try catch block and doing my necessary steps. While this is the case I am also getting exception statements in my JBoss console ...

      org.hibernate.exception.DataException: could not insert: [com.abc.comp.Name]
      at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:77)
      at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
      at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2217)
      at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2610)
      at org.hibernate.action.EntityInsertAction.execute(EntityInsertAction.java:52)
      at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:248)
      at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:232)
      at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:139)
      at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298)
      at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
      at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
      at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338)
      at org.hibernate.transaction.CacheSynchronization.beforeCompletion(CacheSynchronization.java:59)
      at com.arjuna.ats.internal.jta.resources.arjunacore.SynchronizationImple.beforeCompletion(SynchronizationImple.java:114)
      at com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.beforeCompletion(TwoPhaseCoordinator.java:247)
      at com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.end(TwoPhaseCoordinator.java:86)
      at com.arjuna.ats.arjuna.AtomicAction.commit(AtomicAction.java:177)
      at com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple.commitAndDisassociate(TransactionImple.java:1389)
      at com.arjuna.ats.internal.jta.transaction.arjunacore.BaseTransaction.commit(BaseTransaction.java:135)
      at com.arjuna.ats.jbossatx.BaseTransactionManagerDelegate.commit(BaseTransactionManagerDelegate.java:87)
      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$RequiresNew.invoke(TxInterceptor.java:253)
      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
      at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:95)
      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
      at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:62)
      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
      at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:77)
      at org.jboss.ejb3.security.Ejb3AuthenticationInterceptor.invoke(Ejb3AuthenticationInterceptor.java:110)
      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
      at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:46)
      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
      at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
      at org.jboss.ejb3.stateless.StatelessContainer.localInvoke(StatelessContainer.java:240)
      at org.jboss.ejb3.stateless.StatelessContainer.localInvoke(StatelessContainer.java:210)
      at org.jboss.ejb3.stateless.StatelessLocalProxy.invoke(StatelessLocalProxy.java:84)
      ..........................
      .........................
      ........................
      Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: String or binary data would be truncated.
      at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(Unknown Source)
      at com.microsoft.sqlserver.jdbc.IOBuffer.processPackets(Unknown Source)
      at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.getPrepExecResponse(Unknown Source)
      at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.doExecutePreparedStatement(Unknown Source)
      at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement$PreparedStatementExecutionRequest.executeStatement(Unknown Source)
      at com.microsoft.sqlserver.jdbc.CancelableRequest.execute(Unknown Source)
      at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeRequest(Unknown Source)
      at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.executeUpdate(Unknown Source)
      at org.jboss.resource.adapter.jdbc.WrappedPreparedStatement.executeUpdate(WrappedPreparedStatement.java:251)
      at org.hibernate.jdbc.NonBatchingBatcher.addToBatch(NonBatchingBatcher.java:23)
      at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2197)

      Is there a way I can avoid this exception to be seen in my console and get it caught any where in my code????

      Thanks in advance

        • 1. Re: JBoss Transaction Manager Exception Handling
          jaikiran pai Master

           

          at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
          at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
          at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338)
          at org.hibernate.transaction.CacheSynchronization.beforeCompletion(CacheSynchronization.java:59)
          at com.arjuna.ats.internal.jta.resources.arjunacore.SynchronizationImple.beforeCompletion(SynchronizationImple.java:114)


          The insert/update statements are fired (flushed) when the transaction commits at the end of your method. The exception happens when the flush is issued through the callback methods of transaction and as a result, your try/catch block within the same method will be of no use.

          Is there a way I can avoid this exception to be seen in my console


          One way of avoiding these logs on the console is to change the log level in the jboss-log4j.xml (under %JBOSS_HOME%\server\< serverName>\conf folder) for org.hibernate.exception.DataException category:
          <category name="org.hibernate.exception.DataException">
           <priority value="FATAL" />
          </category>


          Note that this will also suppress any other logs from the org.hibernate.exception.DataException too.

          • 2. Re: JBoss Transaction Manager Exception Handling
            Kumar Jaya Newbie

            Thanks for the reply.. I will try that in my configuration file..