-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: SQLException not catched in a EJB
PostPosted: Wed Jul 23, 2008 1:30 pm 
Newbie

Joined: Tue Jul 22, 2008 5:19 am
Posts: 10
Hello,
I have problems during the call to a remote method of an EJB that use Hibernate. I call the method, but if I have an exception like sqlexception for example, I cannot catch it. I need to catch the exceptions, but It looks like that hibernate execute the batch update after the end of EJB Remote Method. I post the stack trace and the hibernate.cfg.xml. I'm using Websphere 6.1
Thanks in advance

My stack trace is

Code:
2008-07-23 17:26:52,931 ERROR [WebContainer : 4] def.AbstractFlushingEventListener (AbstractFlushingEventListener.java:300) - 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:71)
   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:235)
   at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:139)
   at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:297)
   at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
   at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:985)
   at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:333)
   at org.hibernate.transaction.CacheSynchronization.beforeCompletion(CacheSynchronization.java:59)
   at org.hibernate.transaction.WebSphereExtendedJTATransactionLookup$1.invoke(WebSphereExtendedJTATransactionLookup.java:136)
   at $Proxy0.beforeCompletion(Unknown Source)
   at com.ibm.ws.jtaextensions.SynchronizationCallbackWrapper.beforeCompletion(SynchronizationCallbackWrapper.java:65)
   at com.ibm.ws.Transaction.JTA.RegisteredSyncs.distributeBefore(RegisteredSyncs.java:240)
   at com.ibm.ws.Transaction.JTA.TransactionImpl.prePrepare(TransactionImpl.java:2373)
   at com.ibm.ws.Transaction.JTA.TransactionImpl.stage1CommitProcessing(TransactionImpl.java:1606)
   at com.ibm.ws.Transaction.JTA.TransactionImpl.processCommit(TransactionImpl.java:1577)
   at com.ibm.ws.Transaction.JTA.TransactionImpl.commit(TransactionImpl.java:1512)
   at com.ibm.ws.Transaction.JTA.TranManagerImpl.commit(TranManagerImpl.java:237)
   at com.ibm.ws.Transaction.JTA.TranManagerSet.commit(TranManagerSet.java:162)
   at com.ibm.ejs.csi.TranStrategy.commit(TranStrategy.java:756)
   at com.ibm.ejs.csi.TranStrategy.postInvoke(TranStrategy.java:181)
   at com.ibm.ejs.csi.TransactionControlImpl.postInvoke(TransactionControlImpl.java:581)
   at com.ibm.ejs.container.EJSContainer.postInvoke(EJSContainer.java:3876)
   at it.capgemini.emsg.ejb.EJSLocalStatelessController_dfaf1f81.inserisciCanale(EJSLocalStatelessController_dfaf1f81.java:158)
   at it.capgemini.emsg.web.bean.CanaleBean.insertModal(CanaleBean.java:274)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
   at java.lang.reflect.Method.invoke(Method.java:615)
   at com.sun.el.parser.AstValue.invoke(AstValue.java:130)
   at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:274)
   at com.sun.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:68)
   at com.sun.facelets.el.LegacyMethodBinding.invoke(LegacyMethodBinding.java:69)
   at javax.faces.component.UICommand.broadcast(UICommand.java:305)
   at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:298)
   at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:412)
   at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:77)
   at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:239)
   at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:91)
   at com.icesoft.faces.webapp.http.core.JsfLifecycleExecutor.apply(JsfLifecycleExecutor.java:17)
   at com.icesoft.faces.webapp.http.core.ReceiveSendUpdates.renderCycle(ReceiveSendUpdates.java:54)
   at com.icesoft.faces.webapp.http.core.ReceiveSendUpdates.service(ReceiveSendUpdates.java:42)
   at com.icesoft.faces.webapp.http.core.ViewBoundServer.service(ViewBoundServer.java:65)
   at com.icesoft.faces.webapp.http.core.RequestVerifier.service(RequestVerifier.java:44)
   at com.icesoft.faces.webapp.http.common.standard.PathDispatcherServer$Matcher.serviceOnMatch(PathDispatcherServer.java:50)
   at com.icesoft.faces.webapp.http.common.standard.PathDispatcherServer.service(PathDispatcherServer.java:19)
   at com.icesoft.faces.webapp.http.servlet.ThreadBlockingAdaptingServlet.service(ThreadBlockingAdaptingServlet.java:19)
   at com.icesoft.faces.webapp.http.servlet.EnvironmentAdaptingServlet.service(EnvironmentAdaptingServlet.java:63)
   at com.icesoft.faces.webapp.http.servlet.MainSessionBoundServlet.service(MainSessionBoundServlet.java:139)
   at com.icesoft.faces.webapp.http.servlet.SessionDispatcher.service(SessionDispatcher.java:53)
   at com.icesoft.faces.webapp.http.servlet.PathDispatcher$Matcher.serviceOnMatch(PathDispatcher.java:52)
   at com.icesoft.faces.webapp.http.servlet.PathDispatcher.service(PathDispatcher.java:29)
   at com.icesoft.faces.webapp.http.servlet.MainServlet.service(MainServlet.java:82)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
   at com.icesoft.faces.webapp.xmlhttp.BlockingServlet.service(BlockingServlet.java:46)
   at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:972)
   at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:478)
   at com.ibm.ws.wswebcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:463)
   at com.ibm.ws.webcontainer.servlet.CacheServletWrapper.handleRequest(CacheServletWrapper.java:92)
   at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:744)
   at com.ibm.ws.wswebcontainer.WebContainer.handleRequest(WebContainer.java:1433)
   at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:93)
   at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:465)
   at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java:394)
   at com.ibm.ws.http.channel.inbound.impl.HttpICLReadCallback.complete(HttpICLReadCallback.java:102)
   at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:152)
   at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:213)
   at com.ibm.io.async.AbstractAsyncFuture.fireCompletionActions(AbstractAsyncFuture.java:195)
   at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:136)
   at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:194)
   at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:741)
   at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:863)
   at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1510)
Caused by:
java.sql.BatchUpdateException: ORA-01401: inserted value too large for column

   at oracle.jdbc.driver.DatabaseError.throwBatchUpdateException(DatabaseError.java:343)
   at oracle.jdbc.driver.OraclePreparedStatement.executeBatch(OraclePreparedStatement.java:10656)
   at com.ibm.ws.rsadapter.jdbc.WSJdbcStatement.executeBatch(WSJdbcStatement.java:612)
   at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:58)
   at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:195)


My hibernate.cfg.xml
Code:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-configuration
    PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN"
    "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
   <session-factory>
      <!-- datasource connection properties -->
      <property name="session_factory_name">
         hibernate/EmsgSessionFactory
      </property>
      <property name="transaction.manager_lookup_class">
         org.hibernate.transaction.WebSphereExtendedJTATransactionLookup
      </property>
      <property name="connection.provider_class">
         it.common.data.dao.hbn.HibernateDataSourceProvider
      </property>
      <property name="connection.datasource">jdbc/EMsgDB</property>
      <property name="dialect">
         org.hibernate.dialect.Oracle9Dialect
      </property>
      <property name="hibernate.show_sql">true</property>
      <property name="default_schema">EMSG</property>
      <property name="hibernate.jdbc.use_streams_for_binary">true</property>
      <property name="hibernate.cglib.use_reflection_optimizer">false</property>
      
        <mapping file="db/mappings/DettaglioServizio.hbm.xml" />
        <mapping file="db/mappings/Servizio.hbm.xml" />
        <mapping file="db/mappings/Formato.hbm.xml" />
        <mapping file="db/mappings/SistemaArea.hbm.xml" />
        <mapping file="db/mappings/Messaggio.hbm.xml" />
        <mapping file="db/mappings/Canale.hbm.xml" />
       
   </session-factory>
</hibernate-configuration>



Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 25, 2008 3:43 am 
Expert
Expert

Joined: Tue May 13, 2008 3:42 pm
Posts: 919
Location: Toronto & Ajax Ontario www.hibernatemadeeasy.com
Are you catching Exception or RuntimeException?

Hibernate throws RuntimeExceptions, so simply catching Exception won't do.

_________________
Cameron McKenzie - Author of "Hibernate Made Easy" and "What is WebSphere?"
http://www.TheBookOnHibernate.com Check out my 'easy to follow' Hibernate & JPA Tutorials


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 04, 2008 5:03 am 
Newbie

Joined: Tue Jul 22, 2008 5:19 am
Posts: 10
exscuse me,
I come back today from holidays.
I solved, I had to flush the session at the end of method.
Thanks


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.