ejbStore is called at the end of a transaction, which is why you're seeing the output you are. I would verify that the datasource you're looking up in your session bean is through a resource-ref in that bean's deployment descriptor, as well as pointing to an xa-datasource. The fact that you're seeing all the output before your exception is thrown proves that the transaction is falling through from the session to the entity and back, which is a good thing. Jeff. [EMAIL PROTECTED] wrote: > Hello everyone, > I have an entity bean(Account) which is throwing an exception and > this is not being caught by the session bean. The sequence is that > > one insert > entity update > another insert. > > all should go as one unit of transaction or not at all. > > We try to update the entity bean with an illegal value so that it > fails and the whole transaction rolls back. > > The code is as below > > PreparedStatement prepFirst = con.prepareStatement("insert into sabra values(?,?)"); > prepFirst.setString(1,id); > prepFirst.setString(2,name); > prepFirst.executeUpdate(); > prepFirst.close(); > try > { > InitialContext context = new InitialContext(); > Object objref = context.lookup("java:comp/env/ejb/AccountService"); > AccountHome home = > (AccountHome)PortableRemoteObject.narrow(objref, > AccountHome.class); > Account account = home.findByPrimaryKey("123"); > account.credit(12345.00); > System.out.println("here after credit"); > > System.out.println("here again"); > PreparedStatement prepTwo = con.prepareStatement("insert into sabra >values(?,?)"); > prepTwo.setString(1,idFail); > prepTwo.setString(2,nameFail); > > prepTwo.executeUpdate(); > > System.out.println("here again again"); > prepTwo.close(); > con.close(); > } > catch(Exception e) > { > System.out.println("here babe exception"); > throw new EJBException("failed babe"); > } > > The sequence in which actions happen > > the sql insert one happens > the entity does not throw an exception yet > the sql insert two happens > > and then > the ejbstore of the entity is called which only then has the error happening and the > EJBException is thrown, but there is nothing to catch it then. > > o/p is like this > > here after credit > here again > here again again > > and then the exception thrown by the entity although this should have happened >before 'here after credit' > > although the sequence should have been > > only the exception thrown by the entity bean and then nothing else..... > > Can anyone help out? > > Kind Regards > Aby Philip -- Jeff Hubbach Internet Developer New Media Designs, Inc. www.nmd.com