3 Replies Latest reply on Feb 26, 2010 5:52 AM by galder.zamarreno

    NPE in ClusteredCacheLoader (JBoss Cache 3.2.1.GA)

    jamie.s

      Hello,

       

      Trying out a chained cacheloader configuration.

       

      Previously, I had JDBCCacheLoader as the only loader, and that is working properly.

      Now, I want to delegate to the cluster first, so I added ClusteredCacheLoader first.

       

      However, when I start the first node in the cluster, and get to my first API call  (which is addChild() ), I hit an NPE in clustered cache loader:

       

      java.lang.NullPointerException
          at org.jboss.cache.loader.ClusteredCacheLoader.exists(ClusteredCacheLoader.java:212)

       

      Which I take to mean commandsFactory is null:

       

      public boolean exists(Fqn name) throws Exception
         {
            // DON'T make a remote call if this is a remote call in the first place - leads to deadlocks - JBCACHE-1103
            if (!isCacheReady() || !cache.getInvocationContext().isOriginLocal()) return false;

       

            lock.acquireLock(name, false);
            try
            {
               ExistsCommand command = commandsFactory.buildExistsNodeCommand(name);
               Object resp = callRemote(command);
               return resp != null && (Boolean) resp;
            }
            finally
            {
               lock.releaseLock(name);
            }
         }

       

      It would seem though, that isCacheReady returned true, and the invocationContext says it's a local call...

       

      Here's my loader config:

       

      <loaders passivation="false" shared="false">
             
              <loader
                  class="org.jboss.cache.loader.ClusteredCacheLoader"
                  async="false"
                  ignoreModifications="true"
              >
                  <properties>
                      timeout=1500
                  </properties>
              </loader>
             
              <!-- if passivation is true, only the first cache loader is used; the rest are ignored -->
              <loader
                      class="org.jboss.cache.loader.JDBCCacheLoader"
                      async="false"
                      fetchPersistentState="true"
                      ignoreModifications="false"
                      purgeOnStartup="false">
                  <properties>
                      cache.jdbc.table.name=jbosscache
                      cache.jdbc.table.create=true
                      cache.jdbc.table.drop=false
                      cache.jdbc.table.primarykey=jbosscache_pkey
                      cache.jdbc.fqn.column=fqn
                      cache.jdbc.fqn.type=VARCHAR(255)
                      cache.jdbc.node.column=node
                      cache.jdbc.node.type=bytea
                      cache.jdbc.parent.column=parent
                      cache.jdbc.driver=org.postgresql.Driver
                      cache.jdbc.url=jdbc:postgresql:testdb
                      cache.jdbc.user=deleted
                      cache.jdbc.password=deleted
                 </properties>
              </loader>
          </loaders>

       

      And finally, the stack trace back to my call:

      java.lang.NullPointerException
          at org.jboss.cache.loader.ClusteredCacheLoader.exists(ClusteredCacheLoader.java:212)
          at org.jboss.cache.loader.AbstractDelegatingCacheLoader.exists(AbstractDelegatingCacheLoader.java:94)
          at org.jboss.cache.loader.ChainingCacheLoader.exists(ChainingCacheLoader.java:128)
          at org.jboss.cache.interceptors.CacheLoaderInterceptor.loadIfNeeded(CacheLoaderInterceptor.java:311)
          at org.jboss.cache.interceptors.CacheLoaderInterceptor.visitGetNodeCommand(CacheLoaderInterceptor.java:176)
          at org.jboss.cache.commands.read.GetNodeCommand.acceptVisitor(GetNodeCommand.java:76)
          at org.jboss.cache.interceptors.base.CommandInterceptor.invokeNextInterceptor(CommandInterceptor.java:116)
          at org.jboss.cache.interceptors.base.CommandInterceptor.handleDefault(CommandInterceptor.java:131)
          at org.jboss.cache.commands.AbstractVisitor.visitGetNodeCommand(AbstractVisitor.java:115)
          at org.jboss.cache.commands.read.GetNodeCommand.acceptVisitor(GetNodeCommand.java:76)
          at org.jboss.cache.interceptors.base.CommandInterceptor.invokeNextInterceptor(CommandInterceptor.java:116)
          at org.jboss.cache.interceptors.base.CommandInterceptor.handleDefault(CommandInterceptor.java:131)
          at org.jboss.cache.commands.AbstractVisitor.visitGetNodeCommand(AbstractVisitor.java:115)
          at org.jboss.cache.commands.read.GetNodeCommand.acceptVisitor(GetNodeCommand.java:76)
          at org.jboss.cache.interceptors.base.CommandInterceptor.invokeNextInterceptor(CommandInterceptor.java:116)
          at org.jboss.cache.interceptors.TxInterceptor.attachGtxAndPassUpChain(TxInterceptor.java:301)
          at org.jboss.cache.interceptors.TxInterceptor.handleDefault(TxInterceptor.java:283)
          at org.jboss.cache.commands.AbstractVisitor.visitGetNodeCommand(AbstractVisitor.java:115)
          at org.jboss.cache.commands.read.GetNodeCommand.acceptVisitor(GetNodeCommand.java:76)
          at org.jboss.cache.interceptors.base.CommandInterceptor.invokeNextInterceptor(CommandInterceptor.java:116)
          at org.jboss.cache.interceptors.base.CommandInterceptor.handleDefault(CommandInterceptor.java:131)
          at org.jboss.cache.commands.AbstractVisitor.visitGetNodeCommand(AbstractVisitor.java:115)
          at org.jboss.cache.commands.read.GetNodeCommand.acceptVisitor(GetNodeCommand.java:76)
          at org.jboss.cache.interceptors.base.CommandInterceptor.invokeNextInterceptor(CommandInterceptor.java:116)
          at org.jboss.cache.interceptors.InvocationContextInterceptor.handleAll(InvocationContextInterceptor.java:178)
          at org.jboss.cache.interceptors.InvocationContextInterceptor.handleDefault(InvocationContextInterceptor.java:130)
          at org.jboss.cache.commands.AbstractVisitor.visitGetNodeCommand(AbstractVisitor.java:115)
          at org.jboss.cache.commands.read.GetNodeCommand.acceptVisitor(GetNodeCommand.java:76)
          at org.jboss.cache.interceptors.InterceptorChain.invoke(InterceptorChain.java:287)
          at org.jboss.cache.invocation.CacheInvocationDelegate.getNode(CacheInvocationDelegate.java:494)
          at org.jboss.cache.invocation.NodeInvocationDelegate.getChild(NodeInvocationDelegate.java:361)
          at org.jboss.cache.invocation.NodeInvocationDelegate.addChild(NodeInvocationDelegate.java:330)
          at com.whatever.configuration.initCache(configuration.java:134)

       

       

      Anyone run into anything like this before?

      I can't imagine it is the configuration of the ClusteredCacheLoader, that's pretty straight forward.

       

      Thanks for any input,

       

      Jamie

        • 1. Re: NPE in ClusteredCacheLoader (JBoss Cache 3.2.1.GA)
          galder.zamarreno
          Any chance you could provide a unit test that fails with that NPE?
          • 2. Re: NPE in ClusteredCacheLoader (JBoss Cache 3.2.1.GA)
            jamie.s

            You betcha!

             

            Here it is.

             

            To install: unzip it, and then run ant, specifying the root of jboss, and target 'install', like so:

             

            ant -Djboss.install="/home/{whatever}/jboss5/jboss-5.1.0.GA" install

             

            or you may just wish to edit build.xml to alter the jboss.install property.

             

             

            The install target will recompile, jar up a sar file, and copy it into server/all/deploy

             

            I tried two underlying cacheloaders, both FileCacheLoader and JDBCCacheLoader, with no change.

            So, in this configuration, I am *only* running the ClusteredCacheLoader.  (I commented out the FileCacheLoader in replsync-service.)

            Note that I am running a single cluster node.

             

            Here are some relevant bits from the server log:

             

            10:22:04,363 INFO  [STDOUT]
            ---------------------------------------------------------
            GMS: address is 127.0.0.1:36794 (cluster=JBossCache-Cluster)
            ---------------------------------------------------------
            10:22:06,379 INFO  [RPCManagerImpl] Received new cluster view: [127.0.0.1:36794|0] [127.0.0.1:36794]
            10:22:06,379 INFO  [RPCManagerImpl] Cache local address is 127.0.0.1:36794
            10:22:06,380 INFO  [RPCManagerImpl] state was retrieved successfully (in 2.02 seconds)
            10:22:06,380 INFO  [ComponentRegistry] JBoss Cache version: JBossCache 'Malagueta' 3.2.1.GA
            10:22:06,380 INFO  [STDOUT] Calling cache.start...
            10:22:06,381 INFO  [STDOUT] Calling cache.getRoot...
            10:22:06,381 INFO  [STDOUT] getRoot returned: UnversionedNode[ /]
            10:22:06,382 INFO  [STDOUT] Calling addChild...
            10:22:06,382 ERROR [STDERR] java.lang.NullPointerException
            10:22:06,383 ERROR [STDERR]     at org.jboss.cache.loader.ClusteredCacheLoader.exists(ClusteredCacheLoader.java:212)
            10:22:06,383 ERROR [STDERR]     at org.jboss.cache.loader.AbstractDelegatingCacheLoader.exists(AbstractDelegatingCacheLoader.java:94)
            10:22:06,383 ERROR [STDERR]     at org.jboss.cache.interceptors.CacheLoaderInterceptor.loadIfNeeded(CacheLoaderInterceptor.java:311)
            10:22:06,383 ERROR [STDERR]     at org.jboss.cache.interceptors.CacheLoaderInterceptor.visitGetNodeCommand(CacheLoaderInterceptor.java:176)
            10:22:06,383 ERROR [STDERR]     at org.jboss.cache.commands.read.GetNodeCommand.acceptVisitor(GetNodeCommand.java:76)
            10:22:06,383 ERROR [STDERR]     at org.jboss.cache.interceptors.base.CommandInterceptor.invokeNextInterceptor(CommandInterceptor.java:116)
            10:22:06,383 ERROR [STDERR]     at org.jboss.cache.interceptors.base.CommandInterceptor.handleDefault(CommandInterceptor.java:131)
            10:22:06,383 ERROR [STDERR]     at org.jboss.cache.commands.AbstractVisitor.visitGetNodeCommand(AbstractVisitor.java:115)
            10:22:06,383 ERROR [STDERR]     at org.jboss.cache.commands.read.GetNodeCommand.acceptVisitor(GetNodeCommand.java:76)
            10:22:06,384 ERROR [STDERR]     at org.jboss.cache.interceptors.base.CommandInterceptor.invokeNextInterceptor(CommandInterceptor.java:116)
            10:22:06,384 ERROR [STDERR]     at org.jboss.cache.interceptors.base.CommandInterceptor.handleDefault(CommandInterceptor.java:131)
            10:22:06,384 ERROR [STDERR]     at org.jboss.cache.commands.AbstractVisitor.visitGetNodeCommand(AbstractVisitor.java:115)
            10:22:06,384 ERROR [STDERR]     at org.jboss.cache.commands.read.GetNodeCommand.acceptVisitor(GetNodeCommand.java:76)
            10:22:06,384 ERROR [STDERR]     at org.jboss.cache.interceptors.base.CommandInterceptor.invokeNextInterceptor(CommandInterceptor.java:116)
            10:22:06,384 ERROR [STDERR]     at org.jboss.cache.interceptors.TxInterceptor.attachGtxAndPassUpChain(TxInterceptor.java:301)
            10:22:06,384 ERROR [STDERR]     at org.jboss.cache.interceptors.TxInterceptor.handleDefault(TxInterceptor.java:283)
            10:22:06,384 ERROR [STDERR]     at org.jboss.cache.commands.AbstractVisitor.visitGetNodeCommand(AbstractVisitor.java:115)
            10:22:06,384 ERROR [STDERR]     at org.jboss.cache.commands.read.GetNodeCommand.acceptVisitor(GetNodeCommand.java:76)
            10:22:06,384 ERROR [STDERR]     at org.jboss.cache.interceptors.base.CommandInterceptor.invokeNextInterceptor(CommandInterceptor.java:116)
            10:22:06,384 ERROR [STDERR]     at org.jboss.cache.interceptors.base.CommandInterceptor.handleDefault(CommandInterceptor.java:131)
            10:22:06,385 ERROR [STDERR]     at org.jboss.cache.commands.AbstractVisitor.visitGetNodeCommand(AbstractVisitor.java:115)
            10:22:06,385 ERROR [STDERR]     at org.jboss.cache.commands.read.GetNodeCommand.acceptVisitor(GetNodeCommand.java:76)
            10:22:06,385 ERROR [STDERR]     at org.jboss.cache.interceptors.base.CommandInterceptor.invokeNextInterceptor(CommandInterceptor.java:116)
            10:22:06,385 ERROR [STDERR]     at org.jboss.cache.interceptors.InvocationContextInterceptor.handleAll(InvocationContextInterceptor.java:178)
            10:22:06,385 ERROR [STDERR]     at org.jboss.cache.interceptors.InvocationContextInterceptor.handleDefault(InvocationContextInterceptor.java:130)
            10:22:06,385 ERROR [STDERR]     at org.jboss.cache.commands.AbstractVisitor.visitGetNodeCommand(AbstractVisitor.java:115)
            10:22:06,385 ERROR [STDERR]     at org.jboss.cache.commands.read.GetNodeCommand.acceptVisitor(GetNodeCommand.java:76)
            10:22:06,385 ERROR [STDERR]     at org.jboss.cache.interceptors.InterceptorChain.invoke(InterceptorChain.java:287)
            10:22:06,385 ERROR [STDERR]     at org.jboss.cache.invocation.CacheInvocationDelegate.getNode(CacheInvocationDelegate.java:494)
            10:22:06,385 ERROR [STDERR]     at org.jboss.cache.invocation.NodeInvocationDelegate.getChild(NodeInvocationDelegate.java:361)
            10:22:06,385 ERROR [STDERR]     at org.jboss.cache.invocation.NodeInvocationDelegate.addChild(NodeInvocationDelegate.java:330)
            10:22:06,385 ERROR [STDERR]     at com.something.test.Test.startService(Unknown Source)
            10:22:06,386 ERROR [STDERR]     at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:376)
            etc...

             

            10:22:06,390 INFO  [STDOUT] Calling rootNode.getChildrenNames...
            10:22:06,391 INFO  [CacheLoaderInterceptor] Cache loader was unable to load state
            java.lang.NullPointerException
                at org.jboss.cache.loader.ClusteredCacheLoader.getChildrenNames(ClusteredCacheLoader.java:118)
                at org.jboss.cache.loader.AbstractDelegatingCacheLoader.getChildrenNames(AbstractDelegatingCacheLoader.java:84)
                at org.jboss.cache.interceptors.CacheLoaderInterceptor.loadChildren(CacheLoaderInterceptor.java:359)
                at org.jboss.cache.interceptors.CacheLoaderInterceptor.visitGetChildrenNamesCommand(CacheLoaderInterceptor.java:188)
                at org.jboss.cache.commands.read.GetChildrenNamesCommand.acceptVisitor(GetChildrenNamesCommand.java:115)
                at org.jboss.cache.interceptors.base.CommandInterceptor.invokeNextInterceptor(CommandInterceptor.java:116)
                at org.jboss.cache.interceptors.base.CommandInterceptor.handleDefault(CommandInterceptor.java:131)
                at org.jboss.cache.commands.AbstractVisitor.visitGetChildrenNamesCommand(AbstractVisitor.java:125)
                at org.jboss.cache.commands.read.GetChildrenNamesCommand.acceptVisitor(GetChildrenNamesCommand.java:115)
                at org.jboss.cache.interceptors.base.CommandInterceptor.invokeNextInterceptor(CommandInterceptor.java:116)
                at org.jboss.cache.interceptors.base.CommandInterceptor.handleDefault(CommandInterceptor.java:131)
                at org.jboss.cache.commands.AbstractVisitor.visitGetChildrenNamesCommand(AbstractVisitor.java:125)
                at org.jboss.cache.commands.read.GetChildrenNamesCommand.acceptVisitor(GetChildrenNamesCommand.java:115)
                at org.jboss.cache.interceptors.base.CommandInterceptor.invokeNextInterceptor(CommandInterceptor.java:116)
                at org.jboss.cache.interceptors.TxInterceptor.attachGtxAndPassUpChain(TxInterceptor.java:301)
                at org.jboss.cache.interceptors.TxInterceptor.handleDefault(TxInterceptor.java:283)
                at org.jboss.cache.commands.AbstractVisitor.visitGetChildrenNamesCommand(AbstractVisitor.java:125)
                at org.jboss.cache.commands.read.GetChildrenNamesCommand.acceptVisitor(GetChildrenNamesCommand.java:115)
                at org.jboss.cache.interceptors.base.CommandInterceptor.invokeNextInterceptor(CommandInterceptor.java:116)
                at org.jboss.cache.interceptors.base.CommandInterceptor.handleDefault(CommandInterceptor.java:131)
                at org.jboss.cache.commands.AbstractVisitor.visitGetChildrenNamesCommand(AbstractVisitor.java:125)
                at org.jboss.cache.commands.read.GetChildrenNamesCommand.acceptVisitor(GetChildrenNamesCommand.java:115)
                at org.jboss.cache.interceptors.base.CommandInterceptor.invokeNextInterceptor(CommandInterceptor.java:116)
                at org.jboss.cache.interceptors.InvocationContextInterceptor.handleAll(InvocationContextInterceptor.java:178)
                at org.jboss.cache.interceptors.InvocationContextInterceptor.handleDefault(InvocationContextInterceptor.java:130)
                at org.jboss.cache.commands.AbstractVisitor.visitGetChildrenNamesCommand(AbstractVisitor.java:125)
                at org.jboss.cache.commands.read.GetChildrenNamesCommand.acceptVisitor(GetChildrenNamesCommand.java:115)
                at org.jboss.cache.interceptors.InterceptorChain.invoke(InterceptorChain.java:287)
                at org.jboss.cache.invocation.CacheInvocationDelegate.getChildrenNamesInternal(CacheInvocationDelegate.java:654)
                at org.jboss.cache.invocation.CacheInvocationDelegate.getChildrenNames(CacheInvocationDelegate.java:639)
                at org.jboss.cache.invocation.NodeInvocationDelegate.getChildrenNames(NodeInvocationDelegate.java:293)
                at com.something.test.Test.startService(Unknown Source)
            etc...

             

            10:22:06,397 INFO  [STDOUT] getChildrenNames returned:

             

            Thank you for any help on this!!!

             

            Jamie Strachan

            • 3. Re: NPE in ClusteredCacheLoader (JBoss Cache 3.2.1.GA)
              galder.zamarreno

              I created a JIRA for this: https://jira.jboss.org/jira/browse/JBCACHE-1571. It includes a basic unit test that can be run standalone with AS. Fancy having a crack at fixing it?