title: SessionContext Injection using @Resource annotation
body: <p>I need to rollback in EJB 3 Stateless SessionBean (CMT, JBoss version 5), for which I am using </p>
  
  <pre><code>sessionContext.setRollbackOnly();
  </code></pre>
  
  <p>This sessionContext is injected using @Resource annotation. My questions:
  1) Is it preferred way to rollback in EJB3?</p>
  
  <p>2) Why Jboss complains on deployment if I use public setter injection</p>
  
  <pre><code>// throws exception on deployment.
      private SessionContext sessionContext;
      @Resource
      public void setSessionContext(SessionContext sessionContext) {
       this.sessionContext = sessionContext;
      }
  </code></pre>
  
  <p>but following works fine:</p>
  
  <pre><code>@Resource
  private SessionContext sessionContext;
  </code></pre>
  
  <p>Here is the exception in first case:</p>
  
  <pre><code>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
  </code></pre>