Hello i am a newby with EJBTransactions,

i just create some Hello World examples on how EJB works.

But after reading a lot and searching the WEB for two days i see no reason why that 
should not work. Imo this should be the standard way for Client managed explicit 
Transactions. Isnt it?

I already solved two non standard problems: 1st setting the jndi Props by 
System.setProperty() and 2nd the non standard JNDI name of the UserTransaction is 
"java:UserTransaction" instead of the spec. defined standard 
"java:comp/UserTransaction".

But it always throws this Exception in the line of home.create():

javax.transaction.TransactionRequiredException: Transaction Required
at 
org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:316)
at org.jboss.ejb.plugins.TxInterceptorCMT.invokeHome(TxInterceptorCMT.java:74)


Imo the UserTransaction should be passed to the Bean and used.
The transaction-attribute = mandatory forced that.

// ######### The Client ##################
public class ExplicitUserTransactionClient  {
    public static void main(String argv[]) throws Exception {
        // solves JBoss Bug: UT factory lookup failed
        System.setProperty(Context.INITIAL_CONTEXT_FACTORY, 
"org.jboss.naming.HttpNamingContextFactory");
        System.setProperty(Context.PROVIDER_URL, 
"http://vwplan.wob.vw.vwg:8092/invoker/JNDIFactory";);        
        Context context = new InitialContext();
        
        // Lookup non standard Name of Jboss UserTransaction and start it
        UserTransaction ta = (UserTransaction)context.lookup("UserTransaction");
        ta.begin();

        // use an EJBean, TA should be propagated to it
        Object ref = context.lookup("java:/ejbtest/ejb/EXTABean");
        EXTABeanHome home = (EXTABeanHome)PortableRemoteObject.narrow(ref, 
EXTABeanHome.class);
        EXTABean bean = (EXTABean) home.create();
        
        // End userTransaktion (on the Client)
        ta.commit();
        context.close();       
    }
}

// ######### The Bean ##################
/**
 * @ejb.bean
 *              name="EXTABean"
 *              view-type="remote"
 *              type="Stateful"
 *              jndi-name="ejbtest/ejb/EXTABean"
 * @jboss.container-configuration name="HTTP Stateful SessionBean"
 *              
 *              @ejb.bean transaction-type="Container"
 *              @ejb.transaction type="mandatory"
 */
public class EXTABean implements SessionBean {
    public EXTABean() {
        super();
    }
    public void ejbCreate() throws CreateException {}
    public void ejbActivate() throws EJBException, RemoteException {}
    public void ejbPassivate() throws EJBException,RemoteException {}
    public void ejbRemove() throws EJBException, RemoteException {}
    public void setSessionContext(SessionContext arg0) 
        throws EJBException, RemoteException {}
}


// ######### The XDoclet generated ejb-jar.xml  (partially) ####
     <!-- Session Beans -->
      
         <![CDATA[]]>
         <ejb-name>EXTABean</ejb-name>
         ejbtest.interfaces.EXTABeanHome
         ejbtest.interfaces.EXTABean
         <ejb-class>ejbtest.ejb.EXTABean</ejb-class>
         <session-type>Stateful</session-type>
         <transaction-type>Container</transaction-type>
      
<!-- transactions -->
<container-transaction >

<ejb-name>EXTABean</ejb-name>
<method-name>*</method-name>

<trans-attribute>mandatory</trans-attribute>
</container-transaction>

Thanks for your help.
Markus

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

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


-------------------------------------------------------
This SF.Net email is sponsored by BEA Weblogic Workshop
FREE Java Enterprise J2EE developer tools!
Get your free copy of BEA WebLogic Workshop 8.1 today.
http://ads.osdn.com/?ad_id=4721&alloc_id=10040&op=click
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to