cannot invoke remove() on stateful session bean
cincaipatron Oct 24, 2001 8:06 AMHi, I got trouble with stateful session bean, I'm using mySql, jboss 2.4.1. I got error when I
invoke remove() method (end a session) from client. I included some code from my bean, even if
I let ejbPassivate() and ejbActivate() blank still product the same result.
Here's the exception:
====================
[SynchCatalog] TRANSACTION ROLLBACK EXCEPTION:null
Embedded Exception
Unable to deregister with TransactionManager: java.lang.IllegalArgumentException: xaRes not enlisted; nested exception is:
javax.ejb.EJBException: null
Embedded Exception
Unable to deregister with TransactionManager: java.lang.IllegalArgumentException: xaRes not enlisted
[SynchCatalog] java.lang.RuntimeException: Unable to deregister with TransactionManager: java.lang.IllegalArgumentException: xaRes not enlisted
[SynchCatalog] at org.jboss.pool.jdbc.xa.XAConnectionFactory$2.closeConnection(XAConnectionFactory.java:110)
[SynchCatalog] at org.jboss.pool.jdbc.xa.XAConnectionFactory$2.connectionClosed(XAConnectionFactory.java:89)
[SynchCatalog] at org.jboss.pool.jdbc.xa.wrapper.XAConnectionImpl.clientConnectionClosed(XAConnectionImpl.java:134)
[SynchCatalog] at org.jboss.pool.jdbc.xa.wrapper.XAClientConnection.close(XAClientConnection.java:250)
[SynchCatalog] at matashop.product.ejb.SynchCatalogBean.ejbRemove(SynchCatalogBean.java:417)
[SynchCatalog] at java.lang.reflect.Method.invoke(Native Method)
[SynchCatalog] at org.jboss.ejb.plugins.StatefulSessionFilePersistenceManager.removeSession(StatefulSessionFilePersistenceManager.java:327)
[SynchCatalog] at org.jboss.ejb.StatefulSessionContainer.remove(StatefulSessionContainer.java:349)
[SynchCatalog] at java.lang.reflect.Method.invoke(Native Method)
...
...
etc
====================
Here's my bean:
public class MyStatefulBean implements SessionBean {
private transient Connection con;
public void ejbCreate() throws CreateException, RemoteException {
try
{
InitialContext jndiContext = new InitialContext();
DataSource dataSource = (DataSource)jndiContext.lookup(DATASOURCE);
con = dataSource.getConnection();
}
catch (SQLException e) { throw new CreateException("Error acquiring dbase connection"); }
catch (NamingException e) { throw new CreateException("Error initializing jndiContext"); }
}
public void ejbRemove() throws RemoteException {
if (con != null)
try
{
con.close();
con = null;
}
catch(SQLException e) { throw new RemoteException("Error closing connection. " + e.getMessage()); }
}
public void ejbActivate() throws EJBException {
try
{
InitialContext jndiContext = new InitialContext();
DataSource dataSource = (DataSource)jndiContext.lookup(DATASOURCE);
con = dataSource.getConnection();
}
catch (SQLException e) { throw new EJBException("Error acquiring dbase connection"); }
catch (NamingException e) { throw new EJBException("Error initializing jndiContext"); }
}
public void ejbPassivate() throws EJBException {
if (con != null)
try
{
con.close();
con = null;
}
catch(SQLException e) { throw new RemoteException("Error closing connection. " + e.getMessage()); }
}