4 Replies Latest reply on Oct 5, 2004 9:39 AM by chriss

    NPE in org.jboss.mq.pm.jdbc3.PersistenceManager in Jboss 4.0

      I posted this to user, but after no response and sleeping on it , I thought it should be posted here... Kick me if I'm wrong...


      I am trying to jbbc3 persistance for jms. Here is the backtrace

      15:24:16,572 ERROR [PersistenceManager] Starting failed jboss.mq:service=PersistenceManager
      java.lang.NullPointerException
      at org.jboss.mq.pm.jdbc3.PersistenceManager.removeMarkedReferences(PersistenceManager.java:1559)
      at org.jboss.mq.pm.jdbc3.PersistenceManager.resolveAllUncommitedTXs(PersistenceManager.java:1325)
      at org.jboss.mq.pm.jdbc3.PersistenceManager.startService(PersistenceManager.java:1139)
      at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:271)
      at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:221)
      at sun.reflect.GeneratedMethodAccessor3.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:324)
      at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:141)
      at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
      at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
      at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:242)
      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:642)
      at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:891)
      at $Proxy0.start(Unknown Source)
      at org.jboss.system.ServiceController.start(ServiceController.java:416)
      at org.jboss.system.ServiceController.start(ServiceController.java:438)
      at org.jboss.system.ServiceController.start(ServiceController.java:438)
      at org.jboss.system.ServiceController.start(ServiceController.java:438)
      at sun.reflect.GeneratedMethodAccessor7.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:324)
      at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:141)
      at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
      at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
      at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:242)
      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:642)
      at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:176)
      at $Proxy4.start(Unknown Source)
      at org.jboss.deployment.SARDeployer.start(SARDeployer.java:261)
      at org.jboss.deployment.MainDeployer.start(MainDeployer.java:935)
      at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:746)
      at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:709)
      at sun.reflect.GeneratedMethodAccessor37.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

      Looking at the code ..

      the call
      removeMarkedReferences(c, null, "T");

      the method
      protected void removeMarkedReferences(Connection c, Tx txid, String mark) throws SQLException
      {
      PreparedStatement stmt = null;
      try
      {
      stmt = c.prepareStatement(DELETE_MARKED_REFERENCES);
      stmt.setLong(1, txid.longValue());
      stmt.setString(2, mark);
      stmt.executeUpdate();
      }


      I'm assuming that the NPE is that txid is null?

        • 1. Re: NPE in org.jboss.mq.pm.jdbc3.PersistenceManager in Jboss
          chriss

          The Exception is caused by the the following line:

          [L1325] removeMarkedReferences(c, null, "T");

          which in turn causes the NullPointerException in the following mthod:

           protected void removeMarkedReferences(Connection c, Tx txid, String mark) throws SQLException
           {
           PreparedStatement stmt = null;
           try
           {
           stmt = c.prepareStatement(DELETE_MARKED_REFERENCES);
           stmt.setLong(1, txid.longValue());
           stmt.setString(2, mark);
           stmt.executeUpdate();
           }
          
           finally
           {
           try
           {
           stmt.close();
           }
           catch (Throwable e)
           {
           }
           }
           }
          


          on the line:
          stmt.setLong(1, txid.longValue());



          I commented out the statement
          // removeMarkedReferences(c, null, "T");
          and ran some tests. Everything seemed to work OK after the change.

          Should I submit a patch or did I just something stupid?

          chriss

          • 2. Re: NPE in org.jboss.mq.pm.jdbc3.PersistenceManager in Jboss

            But are they really not trying to DELETE_TEMPORARY_MESSAGES ?

            That way it should look like ..


            reparedStatement stmt = null;
            try
            {
            if(txid == null)
            {
            stmt = c.prepareStatement(DELETE_TEMPORARY_MESSAGES);
            }
            else
            {
            stmt = c.prepareStatement(DELETE_MARKED_REFERENCES);

            stmt.setLong(1, txid.longValue());

            stmt.setString(2, mark);
            }
            stmt.executeUpdate();
            }

            • 3. Re: NPE in org.jboss.mq.pm.jdbc3.PersistenceManager in Jboss
              chriss

              ... but that's already being done right at the beginning of the method:

              .
              .
               try
               {
               c = this.getConnection();
              
               // Delete the temporary messages.
               stmt = c.prepareStatement(DELETE_TEMPORARY_MESSAGES);
               stmt.executeUpdate();
               stmt.close();
              .
              .
              


              but maybe the method call
              removeMarkedReferences(c, null, "T");

              should be replaced by :
               stmt = c.prepareStatement(DELETE_MARKED_REFERENCES);
               stmt.setNull(1, Types.BIGINT);
               stmt.setString(2, "T");
               stmt.executeUpdate();
               stmt.close();
              


              • 4. Re: NPE in org.jboss.mq.pm.jdbc3.PersistenceManager in Jboss
                chriss

                ... OK, as nobody has been complaining about the proposed fix, I have now submitted a bug report as well as a patch.

                Request ID 1040506

                chriss