-
1. Re: How to create a UserTransaction in a JSP running on a se
mrgarageman Apr 21, 2004 7:37 PM (in response to icordoba)InitialContext initial = new InitialContext();
UserTransaction transaction = (UserTransaction) initial.lookup("java:comp/UserTransaction");
YourSessionAhome homeA = (YourSessionAHome) javax.rmi.PortableRemoteObject.narrow(initial.lookup("java:comp/env/ejb/SampleA"), YourSessionAHome.class);
YourSessionA yourSessionA = homeA.create();
YourSessionBHome homeB = (YourSessionBHome) javax.rmi.PortableObject.narrow(initial.lookup("java:comp/env/ejb/SampleB"),YourSessionBHome.class);
YourSessionBHome yourSessionB = homeB.create();
try{
transaction.begin();
yourSessionA.someMethod();
yourSessionB.someMethod();
transaction.commit();
}
catch(Exception ex){
ex.printStackTrace;
}
public class YourSessionA implements SessionBean {
public void someMethod(){
System.out.println("Hope This Helps.");
}
// ... callbacks etc.
}
public class YourSessionB implements SessionBean{
public void someMethod(){
System.out.println("From mrgarageman.");
}
// .. callback etc.
} -
2. Re: How to create a UserTransaction in a JSP running on a se
jurban May 18, 2004 10:40 AM (in response to icordoba)I tried this and it failed. I get the following error:
java.lang.NoClassDefFoundError: org/jnp/server/NamingServer
Any idea what I am doing wrong? I copied the suggested code.
Thanks,
Jim -
3. Re: How to create a UserTransaction in a JSP running on a se
sesques May 18, 2004 2:01 PM (in response to icordoba)Hi,
If you use a standalone Tomcat server, it depends on the version but it does not have a native JTA driver. Verify you have Tyrex installed and check Tomcat documentation to use it.
Pascal