3 Replies Latest reply on Feb 18, 2002 10:49 PM by David Jencks

    Does JBoss always create a connection on startup, even when

    J. Wolfgang Kaltz Novice

      Hi everyone,

      it seems that upon starting, JBoss always tries to create a connection from each configured connection pool, even if MinSize=0
      Though from the documentation for ObjectPool.java
      MinSize "Sets the minimum size of the pool. The pool will create this many instances at startup (...). The default is zero."
      What gives ?

      My problem is, I can not be assured that the DB machine is up when my application server machine is rebooted (once a week, at night). In that case, at startup JBoss has the exception

      java.lang.NullPointerException at org.jboss.pool.jdbc.xa.XAPoolDataSource.getConnection(Unknown Source)

      which always occurs in JBoss when a JDBC connection can not be created. The only solution when this happens seems to be to restart JBoss.

      Anybody else have this problem ? Any ideas ?

        • 1. Re: Does JBoss always create a connection on startup, even w
          David Jencks Master

          This is a "feature" of the XADataSourceLoader: it tries to help you by checking if a connection can be made when it is started. The ConnectionFactoryLoader version of things doesn't do this. So, you could comment out the lines that make this check, or if you are using jboss 2.4.4 or later, use ConnectionFactoryLoader. (There is one line, something like ds.getConnection().close() that you'd need to remove.)

          I think that you need to also tell jaws not to create your tables on deploy of beans... that would also need a connection.

          If you find other dependencies like this please let us know.

          • 2. Re: Does JBoss always create a connection on startup, even w
            J. Wolfgang Kaltz Novice

            Thanks for the reply, I'm now trying the ConnectionFactoryLoader approach as we are using JBoss 2.4.4. However I can't get it to work - I assume I'm doing something stupid while trying to "convert" my XADataSourceLoader into a ConnectionFactoryLoader:
            my understanding is, the jndi lookup string should be the same, that is java:/<factory-name> as mentioned in the book.

            Upon starting, JBoss finds my ConnectionFactoryLoader, "DBKnown" :
            2002-02-18 19:48:20,738 [org.jboss.resource.ConnectionFactoryLoader.DBKnown] Starting
            2002-02-18 19:48:20,740 [org.jboss.resource.ConnectionFactoryLoader.DBKnown] Started

            But the lookup fails:
            javax.naming.NameNotFoundException: DBKnown not bound
            at org.jnp.server.NamingServer.getBinding(NamingServer.java:495)
            at org.jnp.server.NamingServer.getBinding(NamingServer.java:503)
            at org.jnp.server.NamingServer.getObject(NamingServer.java:509)
            at org.jnp.server.NamingServer.lookup(NamingServer.java:282)
            at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:349)
            at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:333)
            at javax.naming.InitialContext.lookup(InitialContext.java:347)

            Is my lookup correct, or what else could I be doing wrong ?
            My config follows:

            -- BEFORE (XADataSourceLoader) --


            -- AFTER (ConnectionFactoryLoader) --

            JDBC ResourceAdapter





            • 3. Re: Does JBoss always create a connection on startup, even w
              David Jencks Master

              (it's probably a copying typo, but maxSize=0 is probably not what you want)

              I'm sorry, I don't remember exactly what things are called in 2.4.4 so I might give you the wrong name.

              You need jbosscx.jar and jbosspool.jar (and your driver) in lib/ext, and the .rar containing the "JDBC ResourceAdapter" in deploy or deploy/lib.

              On startup, you should see the ConnectionFactoryLoader init and start, and later the RARDeployer deploy the JDBC ResourceAdapter rar. When it is deployed, the RARDeployer notifies (through jmx) the ConnectionFactoryLoader that its rar is available, and it then sets itself up and binds to jndi (as you think, the name should be the same).

              So... check the log carefully, see if these steps are happening.

              (in 3.0 the deployment sequence uses an mbean dependency mechanism to result in slightly less convoluted actions)