2 Replies Latest reply on Sep 6, 2002 8:53 AM by jsurf

    Stop/Restart XADataSource Service in 2.4.8

    jsurf

      I'm trying to stop/restart my database connection from a servlet, because i want to do some backup/restore stuff and no connections to the database are allowed. Stopping with the RMIAdaptor works fine:

      JMXAdaptor adaptor = (JMXAdaptor)ic.lookup("jmx");
      ObjectName dbService = new ObjectName("DefaultDomain:service=XADataSource,name=ContentDS");
      adaptor.invoke(dbService,"stop",null,null);

      ... this works fine so now i can do my backup/restore stuff...

      no i try to restart my connection pool:

      JMXAdaptor adaptor = (JMXAdaptor)ic.lookup("jmx");
      ObjectName dbService = new ObjectName("DefaultDomain:service=XADataSource,name=ContentDS");
      adaptor.invoke(dbService,"start",null,null);

      but this fails:

      javax.naming.NameAlreadyBoundException: java:/ContentDS already exist
      s in the NonSerializableFactory map
      at org.jboss.naming.NonSerializableFactory.bind(NonSerializableFactory.j
      ava:88)
      at org.jboss.jdbc.XADataSourceLoader.bind(XADataSourceLoader.java:456)
      at org.jboss.jdbc.XADataSourceLoader.startService(XADataSourceLoader.jav
      a:409)
      ...

      I looked in the JndiView and ContentDS does not show up there !
      What am i doing wrong ?




        • 1. Re: Stop/Restart XADataSource Service in 2.4.8
          jsurf

          I found it !
          It's a bug in XADatasourceLoader:
          The connection pool is not correctly unbound:
          It uses NonSerializableFactory for binding the Datasource to JNDI but not for unbind:

          private void bind(Context ctx, String name, Object val) throws NamingException
          {
          // Ah ! Session isn't serializable, so we use a helper class
          NonSerializableFactory.bind(name, val);

          ...

          }

          Here is the bug:

          public void stopService()
          {
          // Unbind from JNDI
          try {
          String name = getSource().getPoolName();
          new InitialContext().unbind("java:/"+name);

          ...

          }

          should be:

          public void stopService()
          {
          // Unbind from JNDI
          try {
          String name = getSource().getPoolName();
          // new InitialContext().unbind("java:/"+name); // Perhaps i need both unbind ??
          NonSerializableFactory.unbind("java:/"+name);

          ...

          }

          so that it is removed from the internal map of NonSerializableFactory


          • 2. Re: Stop/Restart XADataSource Service in 2.4.8
            jsurf

            And a short look in NonSerializableFactory, shows the correct code:

            String name = getSource().getPoolName();
            new InitialContext().unbind("java:/"+name); NonSerializableFactory.unbind("java:/"+name);

            Both unbind operations are needed!