A problem on SLSB which contains a database connection
cool_xiong Apr 14, 2004 9:27 AMI have a problem on SLSB. My SLSB has a database connection field, and I get connection through container(jboss) in ejbCreate and close connection in ejbRemove. As follows:
package com.smartcode.framework.persistence;
...
public class PersistenceBean
implements SessionBean {
SessionContext sessionContext;
Connection cn;
ClassMap classmap;
public void ejbCreate() throws CreateException {
cn = PersistenceResource.getConnection();
classmap = ClassMapGetter.getClassMapBean();
}
public void ejbRemove() {
try {
if (cn != null) {
cn.close();
}
}
catch (Exception ex) {
throw new RuntimeException(ex);
}
}
public void ejbActivate() {
}
public void ejbPassivate() {
}
public void setSessionContext(SessionContext sessionContext) {
this.sessionContext = sessionContext;
}
public ValueObject save(ValueObject v) {
try{
CommandListFactory factory = new CommandListFactory(cn, classmap);
Iterator ite = factory.createCommands(v).iterator();
while (ite.hasNext()) {
((DaoCommand)ite.next()).execute();
}
v.setAllNormal();
}
catch (Exception ex) {
throw new javax.ejb.EJBException(ex.getMessage(), ex);
}
return v;
}
...
}
When the SessionBean is invoked by a general java application through remote interface, it works well.
But it is invoked by another SSLB A which is invoked by a general java application, either remote interface or local interface, when SSLB A return result to client, jboss throw a exception, as follows
[CachedConnectionManager] Successfully closed a connection for you. Please close them yourself: org.jboss.resource.adapter.jdbc.WrappedConnection@133b16ajava.lang.Exception: Stack Trace at org.jboss.resource.connectionmanager.CachedConnectionManager.closeAll(CachedConnectionManager.java:376) at org.jboss.resource.connectionmanager.CachedConnectionManager.popMetaAwareObject(CachedConnectionManager.java:199) at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:190) at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSessionInstanceInterceptor.java:72) at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:84) at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:243) at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:104) at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:117) at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:191) at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:122) at org.jboss.ejb.StatelessSessionContainer.internalInvoke(StatelessSessionContainer.java:322) at org.jboss.ejb.Container.invoke(Container.java:674) at sun.reflect.GeneratedMethodAccessor35.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:284) at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:549) at org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:359) at sun.reflect.GeneratedMethodAccessor34.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:261) at sun.rmi.transport.Transport$1.run(Transport.java:148) at java.security.AccessController.doPrivileged(Native Method) at sun.rmi.transport.Transport.serviceCall(Transport.java:144) at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460) at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701) at java.lang.Thread.run(Thread.java:534)
I guess this problem is revelant with the connection pool, but I don't know jboss how release a connection.
Thanks.