SessionContext Injektion über @Resource annotation

Muss ich rollback in EJB3 Stateless SessionBean (CMT, JBoss version 5), für die ich bin mit

sessionContext.setRollbackOnly();

Diese sessionContext injiziert wird die annotation @Resource verwenden. Meine Fragen:
1) Ist es am günstigsten gelegene Möglichkeit zum rollback in EJB3?

2) Warum Jboss beschwert sich über den Einsatz, wenn ich mit öffentlichen setter-Injektion

//throws exception on deployment.
    private SessionContext sessionContext;
    @Resource
    public void setSessionContext(SessionContext sessionContext) {
     this.sessionContext = sessionContext;
    }

aber Folgendes gut funktioniert:

@Resource
private SessionContext sessionContext;

Hier ist die Ausnahme im ersten Fall:

javax.ejb.SessionContext is an interface, and JAXB can't handle interfaces.
        this problem is related to the following location:
                at javax.ejb.SessionContext
                at public javax.ejb.SessionContext invoice.sap.service.jaxws.SetSctx.arg0
                at invoice.sap.service.jaxws.SetSctx
javax.ejb.SessionContext does not have a no-arg default constructor.
        this problem is related to the following location:
                at javax.ejb.SessionContext

InformationsquelleAutor anergy | 2011-04-04

Schreibe einen Kommentar