6 Replies Latest reply on Jun 3, 2012 10:13 PM by neil.zou

    Nullpointer exception in 3.0.0.Alpha4 example

    neil.zou

      Hi All,

       

      I'm trying to store modeshape cache to file system, after I did some change in the configuration files (in the modeshape-embedded-repo-demo example).  I got below errors:

       

       

      SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
      SLF4J: Defaulting to no-operation (NOP) logger implementation
      SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
      May 25, 2012 4:37:55 PM org.infinispan.factories.GlobalComponentRegistry start
      INFO: ISPN000128: Infinispan version: Infinispan 'Brahma' 5.1.2.FINAL
      javax.jcr.RepositoryException: Error while starting 'My Repository' repository: java.lang.NullPointerException
          at org.modeshape.jcr.JcrRepository.login(JcrRepository.java:566)
          at org.modeshape.jcr.JcrRepository.login(JcrRepository.java:533)
          at org.modeshape.jcr.JcrRepository.login(JcrRepository.java:138)
          at org.modeshape.demo.embedded.repo.EmbeddedRepositoryDemo.main(EmbeddedRepositoryDemo.java:53)
      Caused by: java.lang.RuntimeException: java.lang.NullPointerException
          at org.modeshape.jcr.JcrRepository$RepositorySessionEnvironment.currentTransaction(JcrRepository.java:1531)
          at org.modeshape.jcr.JcrRepository$RepositorySessionEnvironment.createMonitor(JcrRepository.java:1537)
          at org.modeshape.jcr.cache.document.WritableSessionCache.save(WritableSessionCache.java:330)
          at org.modeshape.jcr.cache.document.WritableSessionCache.save(WritableSessionCache.java:294)
          at org.modeshape.jcr.cache.RepositoryCache.<init>(RepositoryCache.java:128)
          at org.modeshape.jcr.JcrRepository$RunningState.<init>(JcrRepository.java:1004)
          at org.modeshape.jcr.JcrRepository$RunningState.<init>(JcrRepository.java:901)
          at org.modeshape.jcr.JcrRepository.doStart(JcrRepository.java:337)
          at org.modeshape.jcr.JcrRepository.login(JcrRepository.java:564)
          ... 3 more
      Caused by: java.lang.NullPointerException
          at org.modeshape.jcr.JcrRepository$RepositorySessionEnvironment.currentTransaction(JcrRepository.java:1529)
          ... 11 more
      Shutting down engine ...
      Success!
      

       

       

      Below is my configuration:

       

      {
          "name" : "My Repository",
          "workspaces" : {
              "default" : "default",
              "predefined" : ["otherWorkspace"],
              "allowCreation" : true
          },
          "storage" : {
              "cacheConfiguration" : "/Code/modeshape3/resources/infinispan.xml",
              "cacheName" : "filestore",
              "transactionManagerLookup" = "org.infinispan.transaction.lookup.GenericTransactionManagerLookup",
              "binaryStorage" : {
                  "minimumBinarySizeInBytes" : 4096,
                  "type" = "file",
                  "directory" = "/dev/infini_cache"
              } 
          },
          "security" : {
              "anonymous" : {
                  "roles" : ["readonly","readwrite","admin"],
                  "useOnFailedLogin" : false
              }
          }
      }
      

       

      And added below infinispan config xml:

      <?xml version="1.0" encoding="UTF-8"?>
      <infinispan xmlns="urn:infinispan:config:5.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="urn:infinispan:config:5.1 http://docs.jboss.org/infinispan/schemas/infinispan-config-5.1.xsd">
          <global/>
      
          <namedCache name="filestore">
              <eviction maxEntries="1000" />
              <loaders passivation="false" shared="false" preload="true">
                  <!-- We can have multiple cache loaders, which get chained -->
                  <loader class="org.infinispan.loaders.file.FileCacheStore"
                      fetchPersistentState="true" purgerThreads="3" purgeSynchronously="true"
                      ignoreModifications="false" purgeOnStartup="false">
                      <!-- See the documentation for more configuration examples and flags. -->
                      <properties>
                          <property name="location" value="/dev/infini_cache" />
                      </properties>
                      <singletonStore enabled="true"
                          pushStateWhenCoordinator="true" pushStateTimeout="20000" />
                      <async enabled="false" flushLockTimeout="15000" threadPoolSize="5" />
                  </loader>
              </loaders>
          </namedCache>
      </infinispan>
      

       

      Could anyone help to figure out what's wrong here?

       

      Thanks!

        • 1. Re: Nullpointer exception in 3.0.0.Alpha4 example
          rhauch

          There are two problems:

           

          SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
          SLF4J: Defaulting to no-operation (NOP) logger implementation
          SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.

          This problem is due to the fact that your application doesn't have on the classpath a SLF4J binding JAR to a specific logger (e.g., Log4J, etc.). What logger are you using? Perhaps the JDK logger. (I've added a comment to MODE-1462 to try to eliminate that output.)

           

           

          javax.jcr.RepositoryException: Error while starting 'My Repository' repository: java.lang.NullPointerException
              at org.modeshape.jcr.JcrRepository.login(JcrRepository.java:566)
              at org.modeshape.jcr.JcrRepository.login(JcrRepository.java:533)
              at org.modeshape.jcr.JcrRepository.login(JcrRepository.java:138)
              at org.modeshape.demo.embedded.repo.EmbeddedRepositoryDemo.main(EmbeddedRepositoryDemo.java:53)
          Caused by: java.lang.RuntimeException: java.lang.NullPointerException
              at org.modeshape.jcr.JcrRepository$RepositorySessionEnvironment.currentTransaction(JcrRepository.java:1531)
              at org.modeshape.jcr.JcrRepository$RepositorySessionEnvironment.createMonitor(JcrRepository.java:1537)
              at org.modeshape.jcr.cache.document.WritableSessionCache.save(WritableSessionCache.java:330)
              at org.modeshape.jcr.cache.document.WritableSessionCache.save(WritableSessionCache.java:294)
              at org.modeshape.jcr.cache.RepositoryCache.<init>(RepositoryCache.java:128)
              at org.modeshape.jcr.JcrRepository$RunningState.<init>(JcrRepository.java:1004)
              at org.modeshape.jcr.JcrRepository$RunningState.<init>(JcrRepository.java:901)
              at org.modeshape.jcr.JcrRepository.doStart(JcrRepository.java:337)
              at org.modeshape.jcr.JcrRepository.login(JcrRepository.java:564)
              ... 3 more
          Caused by: java.lang.NullPointerException
              at org.modeshape.jcr.JcrRepository$RepositorySessionEnvironment.currentTransaction(JcrRepository.java:1529)
              ... 11 more

          I think the problem here is that ModeShape can't find the TransactionManager (or far less likely it can but can't create a transaction).

           

          What environment is this being deployed in? Java standard edition, or an app server? Your configuration does specify the "GenericTransactionManagerLookup" class, which looks for a number of existing transaction managers (in common places, including in JNDI) and should return the DummyTransactionManager if no others could be found. Perhaps it's successfully finding a (real) TransactionManager but then having trouble using it.

           

          One thing you might try is changing the following field in your configuration from:

           

               "transactionManagerLookup" = "org.infinispan.transaction.lookup.GenericTransactionManagerLookup"

           

          to

           

               "transactionManagerLookup" = "org.infinispan.transaction.lookup.DummyTransactionManagerLookup"


          That may help isolate what the problem might be.

           

          Also, ModeShape does expect to use transactions with Infinispan, but they shouldn't be XA transactions. So you might try specifying the TransactionManager lookup class in the Infinispan configuration and setting the "transactionMode" to "TRANSACTIONAL" (see the Infinispan documentation for details and examples).

          • 2. Re: Nullpointer exception in 3.0.0.Alpha4 example
            neil.zou

            Hi Randall,

            Thanks for replying.

            1. I was using JDK logger.

            2. I'm running this in java standard edition 6.0 (windows xp).

             

            I updated the infinispan.xml as below (I changed to use DummyTransactionManagerLookup in both infinispan.xml and my-repository-config.json):

             

            <?xml version="1.0" encoding="UTF-8"?>
            <infinispan xmlns="urn:infinispan:config:5.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                xsi:schemaLocation="urn:infinispan:config:5.1 http://docs.jboss.org/infinispan/schemas/infinispan-config-5.1.xsd">
                <global/>
            
                <namedCache name="filestore">
                    <eviction maxEntries="1000" />
                    <transaction transactionManagerLookupClass="org.infinispan.transaction.lookup.DummyTransactionManagerLookup"
                        transactionMode="TRANSACTIONAL" lockingMode="OPTIMISTIC">
                    </transaction>
                    <loaders passivation="false" shared="false" preload="true">
                        <!-- We can have multiple cache loaders, which get chained -->
                        <loader class="org.infinispan.loaders.file.FileCacheStore"
                            fetchPersistentState="true" purgerThreads="3" purgeSynchronously="true"
                            ignoreModifications="false" purgeOnStartup="false">
                            <!-- See the documentation for more configuration examples and flags. -->
                            <properties>
                                <property name="location" value="/dev/infini_cache" />
                            </properties>
                        </loader>
                    </loaders>
                </namedCache>
            </infinispan>
            

             

            But now I got a new exception:

             

            15:57:21,286 ERROR ISPN000188: Error while processing a commit in a two-phase transaction
            org.infinispan.CacheException: org.infinispan.loaders.CacheLoaderException: Error while reading from file
                at org.infinispan.interceptors.InterceptorChain.invoke(InterceptorChain.java:353)
                at org.infinispan.transaction.TransactionCoordinator.commit(TransactionCoordinator.java:181)
                at org.infinispan.transaction.xa.TransactionXaAdapter.commit(TransactionXaAdapter.java:123)
                at org.infinispan.transaction.tm.DummyTransaction.runCommitTx(DummyTransaction.java:315)
                at org.infinispan.transaction.tm.DummyTransaction.commit(DummyTransaction.java:91)
                at org.infinispan.transaction.tm.DummyBaseTransactionManager.commit(DummyBaseTransactionManager.java:102)
                at org.modeshape.jcr.cache.document.WritableSessionCache.save(WritableSessionCache.java:344)
                at org.modeshape.jcr.cache.document.WritableSessionCache.save(WritableSessionCache.java:294)
                at org.modeshape.jcr.cache.RepositoryCache.workspace(RepositoryCache.java:306)
                at org.modeshape.jcr.cache.RepositoryCache.createSession(RepositoryCache.java:438)
                at org.modeshape.jcr.JcrSession.<init>(JcrSession.java:142)
                at org.modeshape.jcr.JcrRepository.login(JcrRepository.java:603)
                at org.modeshape.jcr.JcrRepository.login(JcrRepository.java:533)
                at org.modeshape.jcr.JcrRepository.login(JcrRepository.java:138)
                at org.modeshape.demo.embedded.repo.EmbeddedRepositoryDemo.main(EmbeddedRepositoryDemo.java:61)
            Caused by: org.infinispan.loaders.CacheLoaderException: Error while reading from file
                at org.infinispan.loaders.file.FileCacheStore.loadBucket(FileCacheStore.java:311)
                at org.infinispan.loaders.file.FileCacheStore.loadBucket(FileCacheStore.java:280)
                at org.infinispan.loaders.bucket.BucketBasedCacheStore.storeLockSafe(BucketBasedCacheStore.java:86)
                at org.infinispan.loaders.bucket.BucketBasedCacheStore.storeLockSafe(BucketBasedCacheStore.java:49)
                at org.infinispan.loaders.LockSupportCacheStore.store(LockSupportCacheStore.java:207)
                at org.infinispan.loaders.AbstractCacheStore.applyModifications(AbstractCacheStore.java:126)
                at org.infinispan.loaders.AbstractCacheStore.commit(AbstractCacheStore.java:163)
                at org.infinispan.interceptors.CacheStoreInterceptor.visitCommitCommand(CacheStoreInterceptor.java:148)
                at org.infinispan.commands.tx.CommitCommand.acceptVisitor(CommitCommand.java:67)
                at org.infinispan.interceptors.base.CommandInterceptor.invokeNextInterceptor(CommandInterceptor.java:116)
                at org.infinispan.interceptors.base.CommandInterceptor.handleDefault(CommandInterceptor.java:130)
                at org.infinispan.commands.AbstractVisitor.visitCommitCommand(AbstractVisitor.java:136)
                at org.infinispan.commands.tx.CommitCommand.acceptVisitor(CommitCommand.java:67)
                at org.infinispan.interceptors.base.CommandInterceptor.invokeNextInterceptor(CommandInterceptor.java:116)
                at org.infinispan.interceptors.EntryWrappingInterceptor.visitCommitCommand(EntryWrappingInterceptor.java:103)
                at org.infinispan.commands.tx.CommitCommand.acceptVisitor(CommitCommand.java:67)
                at org.infinispan.interceptors.base.CommandInterceptor.invokeNextInterceptor(CommandInterceptor.java:116)
                at org.infinispan.interceptors.base.CommandInterceptor.handleDefault(CommandInterceptor.java:130)
                at org.infinispan.commands.AbstractVisitor.visitCommitCommand(AbstractVisitor.java:136)
                at org.infinispan.interceptors.locking.AbstractTxLockingInterceptor.visitCommitCommand(AbstractTxLockingInterceptor.java:104)
                at org.infinispan.commands.tx.CommitCommand.acceptVisitor(CommitCommand.java:67)
                at org.infinispan.interceptors.base.CommandInterceptor.invokeNextInterceptor(CommandInterceptor.java:116)
                at org.infinispan.interceptors.NotificationInterceptor.visitCommitCommand(NotificationInterceptor.java:65)
                at org.infinispan.commands.tx.CommitCommand.acceptVisitor(CommitCommand.java:67)
                at org.infinispan.interceptors.base.CommandInterceptor.invokeNextInterceptor(CommandInterceptor.java:116)
                at org.infinispan.interceptors.TxInterceptor.visitCommitCommand(TxInterceptor.java:120)
                at org.infinispan.commands.tx.CommitCommand.acceptVisitor(CommitCommand.java:67)
                at org.infinispan.interceptors.base.CommandInterceptor.invokeNextInterceptor(CommandInterceptor.java:116)
                at org.infinispan.interceptors.InvocationContextInterceptor.handleAll(InvocationContextInterceptor.java:131)
                at org.infinispan.interceptors.InvocationContextInterceptor.handleDefault(InvocationContextInterceptor.java:90)
                at org.infinispan.commands.AbstractVisitor.visitCommitCommand(AbstractVisitor.java:136)
                at org.infinispan.commands.tx.CommitCommand.acceptVisitor(CommitCommand.java:67)
                at org.infinispan.interceptors.InterceptorChain.invoke(InterceptorChain.java:345)
                ... 14 more
            Caused by: java.io.StreamCorruptedException: Invalid length value for string in stream (0)
                at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:296)
                at org.jboss.marshalling.river.BlockUnmarshaller.readToEndBlockData(BlockUnmarshaller.java:124)
                at org.jboss.marshalling.river.RiverUnmarshaller.doReadNewObject(RiverUnmarshaller.java:1276)
                at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:272)
                at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:209)
                at org.jboss.marshalling.AbstractObjectInput.readObject(AbstractObjectInput.java:37)
                at org.infinispan.container.entries.ImmortalCacheEntry$Externalizer.readObject(ImmortalCacheEntry.java:160)
                at org.infinispan.container.entries.ImmortalCacheEntry$Externalizer.readObject(ImmortalCacheEntry.java:150)
                at org.infinispan.marshall.jboss.ExternalizerTable$ExternalizerAdapter.readObject(ExternalizerTable.java:394)
                at org.infinispan.marshall.jboss.ExternalizerTable.readObject(ExternalizerTable.java:223)
                at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:351)
                at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:209)
                at org.jboss.marshalling.AbstractObjectInput.readObject(AbstractObjectInput.java:37)
                at org.infinispan.loaders.bucket.Bucket$Externalizer.readObject(Bucket.java:157)
                at org.infinispan.loaders.bucket.Bucket$Externalizer.readObject(Bucket.java:139)
                at org.infinispan.marshall.jboss.ExternalizerTable$ExternalizerAdapter.readObject(ExternalizerTable.java:394)
                at org.infinispan.marshall.jboss.ExternalizerTable.readObject(ExternalizerTable.java:223)
                at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:351)
                at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:209)
                at org.jboss.marshalling.AbstractObjectInput.readObject(AbstractObjectInput.java:37)
                at org.infinispan.marshall.jboss.AbstractJBossMarshaller.objectFromObjectStream(AbstractJBossMarshaller.java:144)
                at org.infinispan.marshall.VersionAwareMarshaller.objectFromObjectStream(VersionAwareMarshaller.java:189)
                at org.infinispan.marshall.AbstractDelegatingMarshaller.objectFromObjectStream(AbstractDelegatingMarshaller.java:60)
                at org.infinispan.loaders.file.FileCacheStore.objectFromInputStreamInReentrantMode(FileCacheStore.java:433)
                at org.infinispan.loaders.file.FileCacheStore.loadBucket(FileCacheStore.java:306)
                ... 46 more
            Caused by: an exception which occurred:
                in object of type org.infinispan.schematic.internal.SchematicEntryLiteral
            15:57:21,286  WARN ISPN000112: exception while committing
            javax.transaction.xa.XAException
                at org.infinispan.transaction.TransactionCoordinator.handleCommitFailure(TransactionCoordinator.java:223)
                at org.infinispan.transaction.TransactionCoordinator.commit(TransactionCoordinator.java:184)
                at org.infinispan.transaction.xa.TransactionXaAdapter.commit(TransactionXaAdapter.java:123)
                at org.infinispan.transaction.tm.DummyTransaction.runCommitTx(DummyTransaction.java:315)
                at org.infinispan.transaction.tm.DummyTransaction.commit(DummyTransaction.java:91)
                at org.infinispan.transaction.tm.DummyBaseTransactionManager.commit(DummyBaseTransactionManager.java:102)
                at org.modeshape.jcr.cache.document.WritableSessionCache.save(WritableSessionCache.java:344)
                at org.modeshape.jcr.cache.document.WritableSessionCache.save(WritableSessionCache.java:294)
                at org.modeshape.jcr.cache.RepositoryCache.workspace(RepositoryCache.java:306)
                at org.modeshape.jcr.cache.RepositoryCache.createSession(RepositoryCache.java:438)
                at org.modeshape.jcr.JcrSession.<init>(JcrSession.java:142)
                at org.modeshape.jcr.JcrRepository.login(JcrRepository.java:603)
                at org.modeshape.jcr.JcrRepository.login(JcrRepository.java:533)
                at org.modeshape.jcr.JcrRepository.login(JcrRepository.java:138)
                at org.modeshape.demo.embedded.repo.EmbeddedRepositoryDemo.main(EmbeddedRepositoryDemo.java:61)
            

            Attached is the full log.

             

            I tried to check but can't figure out why..

            Could you please help to look again?

            • 3. Re: Nullpointer exception in 3.0.0.Alpha4 example
              neil.zou

              BTW, I tried to use infinispan API directly (with the same infinispan.xml file), cache can stored to file system successfully on each step I put something to the cache.

              • 4. Re: Nullpointer exception in 3.0.0.Alpha4 example
                rhauch

                Duncan is having a similar problem in another thread. Obviously something is amiss. I'll try to take a look at the code a bit later today.

                • 5. Re: Nullpointer exception in 3.0.0.Alpha4 example
                  rhauch

                  Please look at the other thread, where Duncan reports that he was able to get it working with Infinispan 5.1.4.Final rather than 5.1.2.Final (which we reference as a dependency in ModeShape 3.0.0.Alpha4).

                  1 of 1 people found this helpful
                  • 6. Re: Nullpointer exception in 3.0.0.Alpha4 example
                    neil.zou

                    I tried that version, the example can partially work now.

                    I added a file to the repository, saved successfully, and can retrieve this file in the same process.

                    But when I re-run this app, the uploaded file can't be retrieved anymore. So I believe there is still something wrong with cache reloading.