4 Replies Latest reply on Nov 8, 2001 5:55 AM by cincaipatron

    NullPointerException when starting PostgreSQL

    toften

      When I am trying to start JBoss 2.4.2/Tomcat 3.2.3 I get a NullPointerException when JBoss tries to run the XADataSourceLoader. I have tried with version 2.4.1 and I get the same problem.
      The problem appears both in Win2K and RedHat7.1 environments with Java1.3.1_01

      I have added the following to jboss.jcml:


      org.postgresql.Driver



      PostgresDS
      org.jboss.pool.jdbc.xa.wrapper.XADataSourceImpl

      jdbc:postgresql://192.168.1.10/mydatabase
      postgres



      I have added jdbc7.1-1.2.jar to the /lib/ext

      This results in the following output:

      [PostgresDS] XA Connection pool PostgresDS bound to java:/PostgresDS
      [XADataSourceLoader] Stopped
      java.lang.NullPointerException
      at org.jboss.pool.jdbc.xa.XAPoolDataSource.getConnection(XAPoolDataSourc
      e.java:178)
      at org.jboss.jdbc.XADataSourceLoader.startService(XADataSourceLoader.jav
      a: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:16
      28)
      at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:15
      23)
      at org.jboss.configuration.ConfigurationService$ServiceProxy.invoke(Conf
      igurationService.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:16
      28)
      at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:15
      23)
      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)
      [Configuration] java.lang.NullPointerException
      [Configuration] at org.jboss.pool.jdbc.xa.XAPoolDataSource.getConnection
      (XAPoolDataSource.java:178)
      [Configuration] at org.jboss.jdbc.XADataSourceLoader.startService(XAData
      SourceLoader.java:407)
      [Configuration] at org.jboss.util.ServiceMBeanSupport.start(ServiceMBean
      Support.java:107)
      [Configuration] at java.lang.reflect.Method.invoke(Native Method)
      [Configuration] at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanSe
      rverImpl.java:1628)
      [Configuration] at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanSe
      rverImpl.java:1523)
      [Configuration] at org.jboss.configuration.ConfigurationService$ServiceP
      roxy.invoke(ConfigurationService.java:836)
      [Configuration] at $Proxy0.start(Unknown Source)
      [Configuration] at org.jboss.util.ServiceControl.start(ServiceControl.ja
      va:81)
      [Configuration] at java.lang.reflect.Method.invoke(Native Method)
      [Configuration] at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanSe
      rverImpl.java:1628)
      [Configuration] at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanSe
      rverImpl.java:1523)
      [Configuration] at org.jboss.Main.(Main.java:210)
      [Configuration] at org.jboss.Main$1.run(Main.java:116)
      [Configuration] at java.security.AccessController.doPrivileged(Native Me
      thod)
      [Configuration] at org.jboss.Main.main(Main.java:112)


      I can connect to the database source with the followning program:

      public class db extends java.lang.Object {

      static String myValue;

      public db() {
      getValue();
      }

      /**
      * @param args the command line arguments
      */
      public static void main (String args[]) {
      new db();

      System.out.print(myValue);
      }

      public java.lang.String toString() {
      return myValue;
      }

      public String getValue() {
      String url = "jdbc:postgresql://192.168.1.10/mydatabase";
      //String url = "jdbc:odbc:JavaTest";
      Connection con;
      String createString;
      createString = "SELECT * from Persons";
      //createString = "SELECT * from Company";
      Statement stmt;
      ResultSet rset;

      try {
      //Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
      Class.forName("org.postgresql.Driver");

      } catch(java.lang.ClassNotFoundException e) {
      System.err.print("ClassNotFoundException: ");
      System.err.println(e.getMessage());
      }

      try {
      con = DriverManager.getConnection(url, "postgres", "dummy");

      stmt = con.createStatement();
      rset = stmt.executeQuery(createString);

      rset.next();
      myValue = rset.getString("name");


      rset.close();
      stmt.close();
      con.close();

      } catch(SQLException ex) {
      System.err.println("SQLException: " + ex.getMessage());
      }
      return myValue;
      }
      }


      Hope someone can help - I am desperately running out of ideas.....


      Thanks
      Thomas