4 Replies Latest reply on Oct 1, 2001 10:51 AM by yduchesne

    NullPointerException thrown loading datasource

    yduchesne

      Hi everyone,

      I am trying to integrate JBOSS and Gemstone OODBMS through a custom JDBC driver that I configured in the following way (jboss.jcml):

      -driver


      com.newtrade.dql.query.jdbc.JDBCDriver


      - data source


      GemstoneDB
      org.jboss.pool.jdbc.xa.wrapper.XADataSourceImpl
      jdbc:dql://employees/test
      foo
      bar


      I get the message below from XADataSourceLoader at JBoss startup. Does anyone know why such an error would occur? Any guidelines on how to integrate a JDBC driver to JBoss?

      java.lang.NullPointerException
      at org.jboss.pool.jdbc.xa.XAPoolDataSource.getConnection(XAPoolDataSource.java:178)
      at org.jboss.jdbc.XADataSourceLoader.startService(XADataSourceLoader.java:407)
      at org.jboss.util.ServiceMBeanSupport.start(ServiceMBeanSupport.java:107)
      at java.lang.reflect.Method.invoke(Native Method)
      at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1628)
      at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1523)
      at org.jboss.configuration.ConfigurationService$ServiceProxy.invoke(ConfigurationService.java:836)
      at $Proxy0.start(Unknown Source)
      at org.jboss.util.ServiceControl.start(ServiceControl.java:81)
      at java.lang.reflect.Method.invoke(Native Method)
      at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1628)
      at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1523)
      at org.jboss.Main.(Main.java:210)
      at org.jboss.Main$1.run(Main.java:116)
      at java.security.AccessController.doPrivileged(Native Method)
      at org.jboss.Main.main(Main.java:112)

        • 1. Re: NullPointerException thrown loading datasource
          camtabor

          Looks like you didn't specify the url of your database, is it running on the same machine as jboss?

          • 2. Re: NullPointerException thrown loading datasource
            yduchesne

            Me again: I solved part of my problem by specifing all the properties for the datasource (the doc says that only a few mandatory properties are required (username, password, etc), that's why I had done so).

            But then, the XADataSourceLoader hangs at startup; I get the following output:

            [XADataSourceLoader] Starting
            [GemstoneDB] XA Connection pool GemstoneDB bound to java:/GemstoneDB

            If I set the 'blocking' property to false, I get the NullPointerException again.

            It looks like the XADataSourceLoader never calls my driver's getConnection() or acceptsUrl methods - I've placed log output in the methods, which log to a file, but nothing appears.

            What are the causes for XADataSourceLoader hang ups? - n.b.: It cannot be because the driver cannot connect to the database, because for now the driver has a dummy behavior; it does not connect to a DB...

            • 3. Re: NullPointerException thrown loading datasource
              kristom

              Hi,
              not sure this helps, but I did experience similar symptoms when running JBoss on Linux with mySQL. I have a dual boot system (W2K/Red Hat) that is able to run same JBoss configuration/deployment with both OS'es, mostly for fun and proof of concept. In any case, JBoss and mySQL run on the same node. However, running on Linux was a bit more tricky than W2K.

              To cut the story short, I eventually got the Null pointer exception when JAWS made its first attempts to connnect to the database, depending on the Blocking property of the JDBS driver. The difference between using the blocking=true and ditto false was that the binding simply blocked until the locking timed out, then preceeded as before, with the null-pointer and all.

              Investigation showed that the JDBC driver tried to log on as "mysql@localhost.localdomain" (yes, the database user was "mysql") Now, in mySQL's user table only "localhost" was mentioned, which means that "localhost.localdomain" wasn't recognized. Adding that particular user combination fixed the problem, and now the same config/deployment runs equally well on Windows 2000 and Linux. Even same data files, as they share common vfat partitions.

              This story may not solve the Gemstone problem, but hopefully may help others in distress.


              Regards,

              Kristoffer Moe,
              Senior Consultant
              Elan IT ReSource Norway

              • 4. Re: NullPointerException thrown loading datasource
                yduchesne

                I found my problem; my JDBC driver code was missing the following missing static initializer:

                static {
                java.sql.DriverManager.registerDriver(new JDBCDriver());
                }

                This static initializer is called when the driver class is first loaded into the system - i.e. Class.forName(...). This is what jboss does when loading the drivers mentioned in the jboss.jcml config file; it does not instantiate the driver per say (as in DriverManager.registerDriver(new MyDriver()), but rather, the driver class is reponsible to register itself with the DriverManager; jboss just calls Class.forName("MyDriver").

                As far as the NullPointerException problem goes, it is related to jboss' pooling behavior; When jboss first starts, it tries to fill the pool with initial db connection instances. If connections cannot be found - for any underlying low-level reason), jboss blocks on the to-be-filled connection pool, unless the 'blocking' property is false. If it is false, then a null connection is returned, and therefore the NullPointerException pops up.