3 Replies Latest reply on Aug 31, 2012 9:22 AM by Randall Hauch

    ModeShape 3 beta3 and J2SE example

    Jaroslaw Palka Newbie

      Hi,

       

      I am at the moment evaluating ModeShape for one of our projects. I have downloaded latest beta version and tried to run J2SE example with following config:

       

      {

          "name" : "webdav_repo",

          "jndiName" : "",

          "storage" : {

              "binaryStorage" : {

                  "type" : "file",

                  "directory" : "/home/palkaj01/tlkrepo/binary"

              }

          },

          "query" : {

              "enabled" : true,

              "indexStorage" : {

              "type" : "filesystem",

              "location" : "/home/palkaj01/tlkrepo/index"

              }

          },

          "workspaces" : {

              "predefined" : ["cars"],

              "default" : "default",

              "allowCreation" : true

          },

          "security" : {

              "anonymous" : {

                  "roles" : ["readonly","readwrite","admin", "connect"],

                  "useOnFailedLogin" : false

              },

              "providers" : [

                  { "classname" : "servlet" }

              ]

          }

      }

       

      What I see in logs is:

       

      4:08:15,179 DEBUG logging:38 - Logging Provider: org.jboss.logging.Log4jLoggerProvider

      true

      14:08:15,374  INFO JcrRepository:191 - Initializing ModeShape version 3.0.0.Beta3

      14:08:15,374 DEBUG JcrRepository:111 - Initializing 'webdav_repo' repository

      14:08:15,396  INFO TransientBinaryStore:191 - ModeShape is using the following directory for transient storage of binary values: /tmp

      NOT_RUNNING

      14:08:15,538 DEBUG JcrRepository:111 - Starting 'webdav_repo' repository with configuration:

      { "name" : "webdav_repo" , "jndiName" : "" , "storage" : { "binaryStorage" : { "type" : "file" , "directory" : "/home/palkaj01/tlkrepo/binary" } } , "query" : { "enabled" : true , "indexStorage" : { "type" : "filesystem" , "location" : "/home/palkaj01/tlkrepo/index" } } , "workspaces" : { "predefined" : [ "cars" ] , "default" : "default" , "allowCreation" : true } , "security" : { "anonymous" : { "roles" : [ "readonly" , "readwrite" , "admin" , "connect" ] , "useOnFailedLogin" : false } , "providers" : [ { "classname" : "servlet" } ] } }

      14:08:15,631 DEBUG ModuleProperties:76 - No module lifecycle SPI classes available

      14:08:15,691 DEBUG ModuleProperties:117 - No module command extensions to load

      14:08:15,692 DEBUG DefaultCacheManager:690 - Started cache manager ISPN on null

      14:08:15,694  INFO GlobalComponentRegistry:203 - ISPN000128: Infinispan version: Infinispan 'Brahma' 5.1.2.FINAL

      14:08:15,736 DEBUG GenericTransactionManagerLookup:167 - Trying to lookup TransactionManager for JBoss AS 7

      14:08:15,737 DEBUG GenericTransactionManagerLookup:171 - Failed to perform a lookup for [java:jboss/TransactionManager (JBoss AS 7)]

      14:08:15,738 DEBUG GenericTransactionManagerLookup:167 - Trying to lookup TransactionManager for JBoss AS 4 ~ 6, JRun4

      14:08:15,739 DEBUG GenericTransactionManagerLookup:171 - Failed to perform a lookup for [java:/TransactionManager (JBoss AS 4 ~ 6, JRun4)]

      14:08:15,739 DEBUG GenericTransactionManagerLookup:167 - Trying to lookup TransactionManager for Resin 3.x

      14:08:15,740 DEBUG GenericTransactionManagerLookup:171 - Failed to perform a lookup for [java:comp/TransactionManager (Resin 3.x)]

      14:08:15,740 DEBUG GenericTransactionManagerLookup:167 - Trying to lookup TransactionManager for Sun Glassfish

      14:08:15,741 DEBUG GenericTransactionManagerLookup:171 - Failed to perform a lookup for [java:appserver/TransactionManager (Sun Glassfish)]

      14:08:15,742 DEBUG GenericTransactionManagerLookup:167 - Trying to lookup TransactionManager for Borland, Sun

      14:08:15,742 DEBUG GenericTransactionManagerLookup:171 - Failed to perform a lookup for [java:pm/TransactionManager (Borland, Sun)]

      14:08:15,743 DEBUG GenericTransactionManagerLookup:167 - Trying to lookup TransactionManager for BEA WebLogic

      14:08:15,744 DEBUG GenericTransactionManagerLookup:171 - Failed to perform a lookup for [javax.transaction.TransactionManager (BEA WebLogic)]

      14:08:15,744 DEBUG GenericTransactionManagerLookup:167 - Trying to lookup TransactionManager for Resin, Orion, JOnAS (JOTM)

      14:08:15,745 DEBUG GenericTransactionManagerLookup:171 - Failed to perform a lookup for [java:comp/UserTransaction (Resin, Orion, JOnAS (JOTM))]

      14:08:15,745 DEBUG GenericTransactionManagerLookup:190 - Trying WebSphere 5.1: com.ibm.ws.Transaction.TransactionManagerFactory

      14:08:15,746 DEBUG GenericTransactionManagerLookup:196 - Trying WebSphere 5.0: com.ibm.ejs.jts.jta.TransactionManagerFactory

      14:08:15,748 DEBUG GenericTransactionManagerLookup:202 - Trying WebSphere 4: com.ibm.ejs.jts.jta.JTSXA

      14:08:15,749 DEBUG GenericTransactionManagerLookup:207 - Couldn't find any WebSphere TransactionManager factory class, neither for WebSphere version 5.1 nor 5.0 nor 4

      14:08:15,754  WARN GenericTransactionManagerLookup:132 - ISPN000104: Falling back to DummyTransactionManager from Infinispan

      14:08:15,915 DEBUG AbstractJBossMarshaller:56 - Using JBoss Marshalling

      14:08:15,925 DEBUG InterceptorChain:75 - Interceptor chain size: 6

      14:08:15,925 DEBUG InterceptorChain:76 - Interceptor chain is:

          >> org.infinispan.interceptors.InvocationContextInterceptor

          >> org.infinispan.interceptors.TxInterceptor

          >> org.infinispan.interceptors.NotificationInterceptor

          >> org.infinispan.interceptors.locking.OptimisticLockingInterceptor

          >> org.infinispan.interceptors.EntryWrappingInterceptor

          >> org.infinispan.interceptors.CallInterceptor

      14:08:15,928 DEBUG CacheImpl:502 - Started cache webdav_repo on null

      14:08:15,945 DEBUG StringURLClassLoader:111 - org.modeshape.extractor.tika is not a valid url

      14:08:15,989 DEBUG RepositoryCache:111 - Initializing the 'system' workspace in repository 'webdav_repo'

      14:08:16,310 DEBUG JcrRepository:111 - Enabling anonymous authentication and authorization.

      14:08:16,350 DEBUG RepositoryCache:111 - Initializing 'cars' workspace in repository 'webdav_repo'

      14:08:16,420 DEBUG RepositoryQueryManager:111 - Hibernate Search configuration for repository 'webdav_repo': hibernate.search.worker.thread_pool.size = 1

      hibernate.search.lucene_version = LUCENE_CURRENT

      hibernate.search.reader.strategy = shared

      hibernate.search.similarity = org.apache.lucene.search.DefaultSimilarity

      hibernate.search.default.worker.backend = lucene

      hibernate.search.default.filesystem_access_type = auto

      hibernate.search.default.indexBase = /home/palkaj01/tlkrepo/index

      hibernate.search.worker.buffer_queue.max = 1

      hibernate.search.worker.execution = sync

      hibernate.search.worker.batch_size = -1

      hibernate.search.default.locking_strategy = native

      hibernate.search.default.directory_provider = filesystem

      14:08:16,434  INFO Version:39 - HSEARCH000034: Hibernate Search 4.1.1.Final

      14:08:16,452  INFO Version:37 - HCANN000001: Hibernate Commons Annotations {4.0.1.Final}

      14:08:16,457 DEBUG ConfigContext:306 - Setting Lucene compatibility to Version LUCENE_CURRENT

      14:08:16,478 DEBUG ConfigContext:208 - Using default similarity implementation: org.apache.lucene.search.DefaultSimilarity

      14:08:16,544 DEBUG DirectoryProviderHelper:142 - Initialize index: '/home/palkaj01/tlkrepo/index/nodeinfo'

      14:08:16,600 DEBUG WorkspaceFactory:43 - Starting workspace for index nodeinfo using an exclusive index strategy

      14:08:16,674  INFO AvroSerializationProvider:73 - HSEARCH000079: Serialization protocol version 1.0

      14:08:16,924 DEBUG DocumentBuilderIndexedEntity:206 - Field selection in projections is set to false for entity org.modeshape.jcr.query.lucene.basic.NodeInfo.

       

      It looks like it uses transient storage. I load some content for tests, but when I restart application, the repository is empty. What I am doing wrong? The same happens is when I use this config with WEBDAV WAR.

       

      Regards,

      Jarek

        • 1. Re: ModeShape 3 beta3 and J2SE example
          Randall Hauch Master

          Yes, unless otherwise specified in the configuration, a repository will not be persistent. (This has been an ongoing and unsettled debate within the community about what the defaults should be.) Your configuration is:

           

          {

              "name" : "webdav_repo",

              "jndiName" : "",

              "storage" : {

                  "binaryStorage" : {

                      "type" : "file",

                      "directory" : "/home/palkaj01/tlkrepo/binary"

                  }

              },

              "query" : {

                  "enabled" : true,

                  "indexStorage" : {

                  "type" : "filesystem",

                  "location" : "/home/palkaj01/tlkrepo/index"

                  }

              },

              "workspaces" : {

                  "predefined" : ["cars"],

                  "default" : "default",

                  "allowCreation" : true

              },

              "security" : {

                  "anonymous" : {

                      "roles" : ["readonly","readwrite","admin", "connect"],

                      "useOnFailedLogin" : false

                  },

                  "providers" : [

                      { "classname" : "servlet" }

                  ]

              }

          }

           

          The "storage" section identifies where/how content should be stored. There are two kinds of content: regular node content (stored in Infinispan) and BINARY values (stored in the binary store, of which there are multiple implementations). You've correctly specified using the file-based binary store to use a specific directory, but you've not specified anything about the Infinispan cache. To do that, add "cacheName" and "cacheConfiguration" fields to the "storage" section:

           

              ...
              "storage" : {
                  "cacheName" : "webdav_repo",
                  "cacheConfiguration" : "infinispan_configuration.xml",
                  "binaryStorage" : {
                      "type" : "file",
                      "directory" : "/home/palkaj01/tlkrepo/binary"
                  }
              },
               ...
          

           

          The "cacheConfiguration" is required to tell ModeShape where it can find the Infinispan configuration file, which is where you specify (among other things) where Infinispan is to persist the information. The "cacheName" defaults to the name of the repository, so you can leave that out if you configure Infinispan to have a cache with that name. Of course, you can always be explicit and provide the "cacheName" field.

           

          There are lots of examples of Infinispan configuration files available online, but here's one that might give you a starting point:

           

          <?xml version="1.0" encoding="UTF-8"?>
          <infinispan
                  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                  xsi:schemaLocation="urn:infinispan:config:5.1 http://www.infinispan.org/schemas/infinispan-config-5.1.xsd"
                  xmlns="urn:infinispan:config:5.1">
              <global/>
              <namedCache name="webdav_repo">
                  <transaction transactionManagerLookupClass="org.infinispan.transaction.lookup.DummyTransactionManagerLookup"
                               transactionMode="TRANSACTIONAL" lockingMode="OPTIMISTIC"/>
                  <loaders passivation="false" shared="false" preload="false">
                      <loader class="org.infinispan.loaders.file.FileCacheStore"
                              fetchPersistentState="false" purgeOnStartup="false">
                          <properties>
                              <property name="location" value="target/persistent_repository/store"/>
                          </properties>
                      </loader>
                  </loaders>
              </namedCache>
          </infinispan>
          


          This defines a file-based cache loader that persists (node) content in a directory relative to where the JVM is started. It also specifies a lookup that uses a dummy (but functional) Transaction Manager, which is usable in non-clustered (single-process) J2SE environments.

           

          Hope this helps!

          • 2. Re: ModeShape 3 beta3 and J2SE example
            Jaroslaw Palka Newbie

            As I understand the actual content (in my case images) will be store in this directory /home/palkaj01/tlkrepo/binary, as defined in modeshape config and all other node types in directory defined in infinispan? Am I correct? Just checking if I read your response correctly

             

            Thanks for fast response,

            Jarek

            • 3. Re: ModeShape 3 beta3 and J2SE example
              Randall Hauch Master

              As I understand the actual content (in my case images) will be store in this directory /home/palkaj01/tlkrepo/binary, as defined in modeshape config and all other node types in directory defined in infinispan? Am I correct? Just checking if I read your response correctly

              Yes, the binary values (that is, the content of "javax.jcr.Binary" instances) will be stored on the file system in the "/home/palkaj01/tlkrepo/binary" directory, the ModeShape search indexes will be stored on the file system in the "/home/palkaj01/tlkrepo/index" directory, and the rest of the content will be stored in Infinispan -- but Infinispan will only persist the information to the file system if you (a) provide an Infinispan configuration that specifies this, and (b) tell ModeShape where to find the Infinispan configuration.

               

              Best regards!