I am using JOnAS 2.2.6 and wrote a SLSB that has only on method. This method does this:
try {
Context context = new InitialContext();
DataSource dataSource = (DataSource)
context.lookup("java:comp/env/jdbc/EmployeeAppDB");
Connection con = dataSource.getConnection();
CallableStatement stat = con.prepareCall("{?=call test(?,?,?,?)}");
stat.registerOutParameter(1,java.sql.Types.INTEGER);
stat.registerOutParameter(4,java.sql.Types.INTEGER);
stat.registerOutParameter(5,java.sql.Types.VARCHAR);
stat.setString(2, "This is a test.");
stat.setTimestamp(3, new Timestamp((new Date().getTime())));
stat.execute();
int rR = stat.getInt(1);
int r1 = stat.getInt(4);
String r2 = stat.getString(5);
System.out.println("Result: " + rR + " - " + r1 + " - " + " - " + r2);
}
catch (Exception e) {
e.printStackTrace();
}
and I wrote a test program that does this:
System.setProperty("java.naming.factory.initial",
"com.sun.jndi.rmi.registry.RegistryContextFactory");
System.setProperty("java.naming.provider.url", "rmi://localhost:1099");
System.setProperty("java.naming.factory.url.pkgs", "org.objectweb.jonas.naming");
try {
Context initialContext = new InitialContext();
UserTransaction utx = (UserTransaction)
PortableRemoteObject.narrow(initialContext.lookup("javax.transaction.UserTransaction"),
UserTransaction.class);
TestHome home = (TestHome)
PortableRemoteObject.narrow(initialContext.lookup("TestHome"), TestHome.class);
utx.begin();
Test t1 = home.create();
t1.test();
t1.remove();
utx.commit();
}
catch (Exception e) {
e.printStackTrace();
}
and when I try to start the testprogram, all runs fine but then I get this error
message:
> XAResource ---> commit: XA START without XA END
> WARNING: Connection not closed by caller
> Force a physical close to avoid reusing it in another transaction
I have this DD:
<!DOCTYPE ejb-jar SYSTEM "C:\JOnAS/xml/ejb-jar_1_1.dtd">
<ejb-jar>
<description></description>
<enterprise-beans>
<session>
<ejb-name>Test</ejb-name>
<home>test.TestHome</home>
<remote>test.Test</remote>
<ejb-class>test.TestBean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
<resource-ref>
<res-ref-name>jdbc/EmployeeAppDB</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
</session>
</enterprise-beans>
<assembly-descriptor>
<container-transaction>
<method>
<ejb-name>Test</ejb-name>
<method-name>*</method-name>
</method>
<trans-attribute>Required</trans-attribute>
</container-transaction>
</assembly-descriptor>
</ejb-jar>
and this JOnAS-specific DD:
<!DOCTYPE jonas-ejb-jar SYSTEM "C:\JOnAS/xml/jonas-ejb-jar.dtd">
<jonas-ejb-jar>
<jonas-session>
<ejb-name>Test</ejb-name>
<jndi-name>TestHome</jndi-name>
<jonas-resource>
<res-ref-name>jdbc/EmployeeAppDB</res-ref-name>
<jndi-name>jdbc_1</jndi-name>
</jonas-resource>
</jonas-session>
</jonas-ejb-jar>
Does anybody have an Idea what the problem is?