[jboss-user] [JBoss Seam] - transaction failed" using injected JavaBean

d00roth do-not-reply at jboss.com
Tue Nov 27 08:03:19 EST 2007


Hi all,

I have struggled some time with a problem I get when trying to persist some objects. I use the exact same setup as jboss-seam-jpa running om tomcat6 without jboss embedded. (JavaBean an POJO:s).

Persisting an object with 


  | @Name("register")
  | public class RegisterAction {
  |     @In
  |     private EntityManager em;
  | 
  |     public void register() {
  |         em.persist(someObject);
  |     }
  | }
  | 

works perfectly, even without the @Transactional annotation. However this:


  | @Name("register")
  | public class RegisterAction {
  |     @In
  |     private MyService service;
  | 
  |     public void register() {
  |         service.register(someObject);
  |     }
  | }
  | 
  | @Name("service")
  | @AutoCreate
  | public class MyService {
  |     @In
  |     private EntityManager em;
  | 
  |     public void register(Object someObject) {
  |         em.persist(someObject);
  |     }
  | }
  | 

does not work(and I have tried using @Transactional on 'register' and MyService). I get a "Transaction failed" in my jsf h:messages, but apart from that, there is no error message what so ever.

I guess I have missed something fundamental, especially when I read this in the Seam doc: 

anonymous wrote : 25.3... Seam JavaBean components do not provide declarative transaction demarcation like session beans do. You could manage your transactions manually using the JTA UserTransaction or declaratively using Seam's @Transactional  annotation. But most applications will just use Seam managed transactions when using Hibernate with JavaBeans.

anonymous wrote : 1.2.1.2... Our session bean action listener performs the business and persistence logic for our mini-application. In more complex applications, we might need to layer the code and refactor persistence logic into a dedicated data access component. That's perfectly trivial to do. But notice that Seam does not force you into any particular strategy for application layering.

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

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



More information about the jboss-user mailing list