Hi,
I find that the XADataSourceLoader MBean cannot be stopped and restarted
through the web-mbean interface: I get a Pool already initialized
message/error. It also looks fishy to me that the JNDI name is bound
before the datasource is tested. I propose the following patch which:
tests the connection before registering the datasource in jndi
when the service is stopped or if an error occurs testing the
datasource/connection, closes and discards the pool for the service.
I find this makes fixing connection parameter problems a bit easier-- I
don't have to stop and restart all of jboss.
Thanks
David Jencks
patch from cvs diff -c.
Is this the right format?
I wasn't sure if this or jbosscmp would be the better list, I chose this
since the file in question is in jboss directory structure, even though it
depends on the minerva pooled datasource.
Index: jboss/src/main/org/jboss/jdbc/XADataSourceLoader.java
===================================================================
RCS file: /products/cvs/ejboss/jboss/src/main/org/jboss/jdbc/XADataSourceLoader.java,v
retrieving revision 1.15
diff -c -r1.15 XADataSourceLoader.java
*** jboss/src/main/org/jboss/jdbc/XADataSourceLoader.java 2001/01/31
21:48:29 1.15
--- jboss/src/main/org/jboss/jdbc/XADataSourceLoader.java 2001/03/06
16:42:43
***************
*** 317,333 ****
mgr = ctx.lookup("java:/TransactionManager");
} catch(NamingException e)
{
throw new IllegalStateException("Cannot start XA Connection
Pool; there is no TransactionManager in JNDI!");
}
getSource().initialize();
// Bind in JNDI
bind(new InitialContext(), "java:/"+getSource().getPoolName(),
source);
log.log("XA Connection pool "+getSource().getPoolName()+" bound to
java:/"+getSource().getPoolName());
- // Test database
- getSource().getConnection().close();
}
public void stopService()
--- 317,342 ----
mgr = ctx.lookup("java:/TransactionManager");
} catch(NamingException e)
{
+ cleanupSource();
throw new IllegalStateException("Cannot start XA Connection
Pool; there is no TransactionManager in JNDI!");
}
getSource().initialize();
+ // Test database
+ try
+ {
+ getSource().getConnection().close();
+ }
+ catch (Exception e)
+ {
+ cleanupSource();
+ throw e;
+ }
// Bind in JNDI
bind(new InitialContext(), "java:/"+getSource().getPoolName(),
source);
log.log("XA Connection pool "+getSource().getPoolName()+" bound to
java:/"+getSource().getPoolName());
}
public void stopService()
***************
*** 337,343 ****
String name = getSource().getPoolName();
new InitialContext().unbind("java:/"+name);
log.log("XA Connection pool "+name+" removed from JNDI");
! getSource().close();
log.log("XA Connection pool "+name+" shut down");
} catch (NamingException e)
{
--- 346,352 ----
String name = getSource().getPoolName();
new InitialContext().unbind("java:/"+name);
log.log("XA Connection pool "+name+" removed from JNDI");
! cleanupSource();
log.log("XA Connection pool "+name+" shut down");
} catch (NamingException e)
{
***************
*** 351,356 ****
--- 360,373 ----
if (source == null)
source = new XAPoolDataSource();
return source;
+ }
+
+ private void cleanupSource()
+ {
+ if (source != null) {
+ source.close();
+ }
+ source = null;
}
private void bind(Context ctx, String name, Object val) throws
NamingException