1 2 Previous Next 24 Replies Latest reply on Sep 5, 2012 4:09 AM by K. Bachl

    Modeshape 3 Beta 2: java.lang.NumberFormatException: For input string: "classname"

    K. Bachl Novice

      Hi,

       

      I tried to give ModeShape3 Beta 2 a go but I somehow hit a wall I cant see. I change my createRepo for a modshape 3 base:

       

       

      public Repository createRepository(String modeshapePath) {

              try {

                  log.info("JCR...");

       

                  engine = new ModeShapeEngine();

                  engine.start();

       

                  RepositoryConfiguration config = RepositoryConfiguration

                          .read(JcrServiceModeshape3.class.getResource("config/repository-ms3.json"));

                  Problems problems = config.validate();

                  if (problems.hasErrors()) {

                      System.err.println("Problems starting the engine.");

                      System.err.println(problems);

                      System.exit(-1);

                  }

       

                  return engine.deploy(config);

       

              } catch (Exception e) {

                  throw new RuntimeException("Could not create repository! ", e);

              }

          }

       

       

      where my json is:

       

       

      {

          "name":"wwRepo",

          "jndiName":"",

       

          "security":{

              "jaas":{

                  "policyName":""

              },

              "anonymous":{

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

                  "username":"<anonymous>",

                  "useOnFailedLogin":true

              }

          },

          "sequencing":{

              "removeDerivedContentWithOriginal":true,

              "sequencers":{

                  "description":"CND Sequencer Same Location",

                  "type":"CNDSequencer",

                  "pathExpressions":[ "default://(*.cnd)/jcr:content[@jcr:data]" ]

              }

       

          }

      }

      however, when I boot it up I get:

       

       

      [#|2012-08-15T21:25:00.506+0200|SEVERE|glassfish3.1.2|javax.enterprise.system.container.web.com.sun.enterprise.web|_ThreadID=18;_ThreadName=Thread-6;|WebModule[]PWC1270: Exception starting filter brix.app-shop

      java.lang.InstantiationException

          at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:124)

      ....

       

      Caused by: java.lang.NumberFormatException: For input string: "classname"

          at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)

          at java.lang.Integer.parseInt(Integer.java:449)

          at java.lang.Integer.parseInt(Integer.java:499)

          at org.infinispan.schematic.internal.document.BasicArray.indexFrom(BasicArray.java:636)

          at org.infinispan.schematic.internal.document.BasicArray.get(BasicArray.java:93)

          at org.infinispan.schematic.internal.document.BasicArray.getString(BasicArray.java:400)

          at org.infinispan.schematic.internal.document.BasicArray.getString(BasicArray.java:394)

          at org.modeshape.jcr.RepositoryConfiguration.readComponents(RepositoryConfiguration.java:1602)

          at org.modeshape.jcr.RepositoryConfiguration$Sequencing.validateSequencers(RepositoryConfiguration.java:1532)

          at org.modeshape.jcr.RepositoryConfiguration.validate(RepositoryConfiguration.java:1728)

          at de.xxxx.jcr.JcrServiceModeshape3.createRepository(JcrServiceModeshape3.java:45)

          ... 46 more

       

      What is going on here? - Any Idea how I can fix this?

        • 1. Re: Modeshape 3 Beta 2: java.lang.NumberFormatException: For input string: "classname"
          Randall Hauch Master

          The structure of the "sequencing" nested document in the JSON is incorrect. The "sequencers" field should contain another nested document, where the field represents an identifier (or name) for the sequencer and whose fields are "description", "classname" (instead of "type"; see MODE-1519), and "pathExpressions".

           

          For example, this should work:

           

          {
              "name":"wwRepo",
              "jndiName":"",
          
              "security":{
                  "jaas":{
                      "policyName":""
                  },
                  "anonymous":{
                      "roles":["readonly", "readwrite", "admin"],
                      "username":"<anonymous>",
                      "useOnFailedLogin":true
                  }
              },
              "sequencing":{
                  "removeDerivedContentWithOriginal":true,
                  "sequencers":{
                      "cndSequencer" : {
                          "description":"CND Sequencer Same Location",
                          "classname":"CNDSequencer",
                          "pathExpressions":[ "default://(*.cnd)/jcr:content[@jcr:data]" ]
                      }
                  }
          
              }
          }
          

           

           

          You can look at several example configurations that define sequencers.

           

          BTW, the "jaas" nested document is not necessary, as JAAS authentication is only enabled by default in the JBoss AS7 kit (whereas in 2.x it was always enabled by default). Additionally, the "roles" and "username" fields are not required as the values match the defaults; the default for the "useOnFailedLogin" field is "false", however, so that field in your configuration would be required.

          1 of 1 people found this helpful
          • 2. Re: Modeshape 3 Beta 2: java.lang.NumberFormatException: For input string: "classname"
            K. Bachl Novice

            thank you Randall, that allowed me to startup the repo and put data in; Now, after that I tried to make my data persistent by using an infinispan cache loader,

             

             

            {

                "name":"wwRepo",

                "jndiName":"",

             

                "security":{

                    "anonymous":{

                        "useOnFailedLogin":true

                    }

                },

             

                "storage":{

                    "cacheConfiguration":"cache-ms3.xml",

                    "cacheName":"wwRepoCache",

                    "transactionManagerLookup":"org.infinispan.transaction.lookup.GenericTransactionManagerLookup",

                    "binaryStorage":{

                        "minimumBinarySizeInBytes":10244096,

                        "type":"file",

                        "directory":"/z-modeshape/modeshape3/jcr"

                    }

                },

             

                "sequencing":{

                    "removeDerivedContentWithOriginal":true,

                    "sequencers":{

                        "cndSequencer":{

                            "description":"CND Sequencer Same Location",

                            "classname":"CNDSequencer",

                            "pathExpressions":[ "default://(*.cnd)/jcr:content[@jcr:data]" ]

                        }

                    }

                }

             

             

            }

             

            where cache-ms3.xml is:

             

             

            <?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 settings shared by all caches managed by this cache container. -->

                <global/>

                <!-- Individually named caches. -->

                <namedCache name="wwRepoCache">

                    <transaction

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

                                   transactionMode="TRANSACTIONAL"

                                   lockingMode="OPTIMISTIC"/>

                    <loaders

                            passivation="false"

                            shared="false"

                            preload="false">

             

                        <loader

                                class="org.infinispan.loaders.jdbm.JdbmCacheStore"

                                fetchPersistentState="false"

                                purgeOnStartup="false">

             

                            <properties>

                                <property name="location" value="/z-modeshape/modeshape3/jdbmcachestore"/>

                            </properties>

             

                        </loader>

                    </loaders>

                </namedCache>

            </infinispan>

             

             

            This works ok on empty startup, and I can import an existing workspace.xml into it and then use it in my app as expected. However, after shutting down the server and restarting it, my app screams: "...

            Caused by: javax.jcr.ItemNotFoundException: The primary type "nt:file" for node "/brix:root/brix:web/brix:site/index" in workspace "bx_ZbybnPXdVXcNKZbdqXsHDHrONJ" does not define a primary item name

                at org.modeshape.jcr.AbstractJcrNode.getPrimaryItem(AbstractJcrNode.java:1954)

            " - meaning he misses a primary item name that was there before restart. I tried to narrow it down and so made it that no files are touched by storage.binaryStorage but only infinispan, however, this was no solution at all. Any Idea what mistake I made here?

             

            From my first view on modeShape 3 the performance of our jcr based webapp increased by nearly 100% by just switiching from 2.8.2 to 3.0.Beta2 - so I really want it

            • 3. Re: Modeshape 3 Beta 2: java.lang.NumberFormatException: For input string: "classname"
              Randall Hauch Master

              It might be an issue with how we're trying to find the primary item, especially with a node that has mixins that define the primary item (or override the primary item). Can you share your CND?

              • 4. Re: Modeshape 3 Beta 2: java.lang.NumberFormatException: For input string: "classname"
                K. Bachl Novice

                This is somehow hard to do. I use BrixCMS and it uses CND to specify some special things but the code that does this is cluttered over the project, if your remember some time ago: http://lists.jboss.org/pipermail/modeshape-issues/2012-February/005764.html

                 

                There is no easy way to export all CND from a running modeshape system?

                 

                I could give you an exported workspace.xml (nearly empty - but error also occurs there) if this helps...

                • 5. Re: Modeshape 3 Beta 2: java.lang.NumberFormatException: For input string: "classname"
                  Randall Hauch Master

                  Unfortunately there's not. Feel free to add a feature request in our JIRA for it; exporting CNDs would be useful.

                   

                  Do you know which mixins were added to the 'nt:file' node? Can you debug into the code to find out what's going on?

                  • 6. Re: Modeshape 3 Beta 2: java.lang.NumberFormatException: For input string: "classname"
                    K. Bachl Novice

                    Hi Randall,

                     

                    sorry for the late answer. I digged through all places and in fact, there is only 1 place where a CNDImporter is doing its job. I made him to spell out the type info he gets and this is the relevant log part:

                     

                     

                    INFO  - BrixRepositoryInitializer  - Registering Brix JCR Namespace: brix

                     

                    INFO  - Brix                       - Registering node type: brix:node in workspace default

                     

                    INFO  - Brix                       - CND: [brix:node] > nt:unstructured , mix:referenceable orderable  mixin

                     

                    INFO  - Brix                       - Registering node type: brix:folder in workspace default

                     

                    INFO  - Brix                       - CND: [brix:folder] > nt:unstructured  mixin

                     

                    INFO  - Brix                       - Registering node type: brix:tile in workspace default

                     

                    INFO  - Brix                       - CND: [brix:tile] > nt:unstructured orderable

                     

                    INFO  - Brix                       - Registering node type: brix:hidden in workspace default

                     

                    INFO  - Brix                       - CND: [brix:hidden] > nt:unstructured  mixin

                     

                    INFO  - Brix                       - Registering node type: brix:globalContainer in workspace default

                     

                    INFO  - Brix                       - CND: [brix:globalContainer] > nt:unstructured  mixin

                     

                    INFO  - Brix                       - Registering node type: brix:tilePage in workspace default

                     

                    INFO  - Brix                       - CND: [brix:tilePage] > nt:unstructured  mixin

                     

                    INFO  - Brix                       - Registering node type: brix:tileTemplate in workspace default

                     

                    INFO  - Brix                       - CND: [brix:tileTemplate] > nt:unstructured  mixin

                     

                    INFO  - Brix                       - Registering node type: brix:webDavContainer in workspace default

                     

                    INFO  - Brix                       - CND: [brix:webDavContainer] > nt:unstructured  mixin

                     

                    As you can see those are basically all unstructured, nodes where the content (including the mixins) can be specified by the implementing classes, in our case FolderNode that extends the basic BrixNode (see: https://github.com/brix-cms/brix-cms/blob/master/brix-core/src/main/java/org/brixcms/plugin/site/folder/FolderNode.java and its superclass https://github.com/brix-cms/brix-cms/blob/master/brix-core/src/main/java/org/brixcms/jcr/wrapper/BrixNode.java ); So far there is quite few there that even could lead to a problem;

                     

                    The workspace-export of an html-file that leads to  the above error is usually just this:

                     

                    <sv:node sv:name="index.html">

                                    <sv:property sv:name="jcr:primaryType" sv:type="Name">

                                        <sv:value>nt:file</sv:value>

                                    </sv:property>

                                    <sv:property sv:name="jcr:mixinTypes" sv:type="Name">

                                        <sv:value>brix:node</sv:value>

                                    </sv:property>

                                    <sv:property sv:name="jcr:uuid" sv:type="String">

                                        <sv:value>1e1d60f2-403b-4014-9dfe-e81a3f03f9e9</sv:value>

                                    </sv:property>

                                    <sv:property sv:name="brix:created" sv:type="Date">

                                        <sv:value>2008-06-19T17:14:32.982-07:00</sv:value>

                                    </sv:property>

                                    <sv:property sv:name="brix:createdBy" sv:type="String">

                                        <sv:value>demo</sv:value>

                                    </sv:property>

                                    <sv:property sv:name="brix:lastModified" sv:type="Date">

                                        <sv:value>2008-07-07T14:48:00.186-07:00</sv:value>

                                    </sv:property>

                                    <sv:property sv:name="brix:lastModifiedBy" sv:type="String">

                                        <sv:value>demo</sv:value>

                                    </sv:property>

                                    <sv:property sv:name="brix:nodeType" sv:type="String">

                                        <sv:value>brix:tilePage</sv:value>

                                    </sv:property>

                                    <sv:property sv:name="brix:template" sv:type="Reference">

                                        <sv:value>080b93f9-a879-4433-ba91-c93ae8083c3d</sv:value>

                                    </sv:property>

                                    <sv:property sv:name="brix:title" sv:type="String">

                                        <sv:value>Home</sv:value>

                                    </sv:property>

                                    <sv:property sv:name="jcr:created" sv:type="Date">

                                        <sv:value>2008-07-07T23:57:28.387+02:00</sv:value>

                                    </sv:property>

                                    <sv:node sv:name="jcr:content">

                                        <sv:property sv:name="jcr:primaryType" sv:type="Name">

                                            <sv:value>nt:unstructured</sv:value>

                                        </sv:property>

                                        <sv:property sv:name="jcr:data" sv:type="String">

                                            <sv:value>&lt;h2&gt;Welcome to BrixCMS Demo Site&lt;/h2&gt;&lt;br/&gt;&lt;br/&gt;&#13;

                                                &#13;

                                                You can access the Admin Console at the &lt;a href="admin"&gt;/admin&lt;/a&gt; URL.&lt;br/&gt;&lt;br/&gt;&#13;

                                                &#13;

                                                Visit &lt;a href="http://brix-cms.googlecode.com"&gt;Brix project site&lt;/a&gt; for more

                                                information about Brix CMS.

                                            </sv:value>

                                        </sv:property>

                                        <sv:property sv:name="jcr:encoding" sv:type="String">

                                            <sv:value>UTF-8</sv:value>

                                        </sv:property>

                                        <sv:property sv:name="jcr:lastModified" sv:type="Date">

                                            <sv:value>2008-07-06T22:40:06.482+02:00</sv:value>

                                        </sv:property>

                                        <sv:property sv:name="jcr:mimeType" sv:type="String">

                                            <sv:value>text/html</sv:value>

                                        </sv:property>

                                    </sv:node>

                                </sv:node>

                     

                    So basically brix doesnt expect an "primary item name" on anything, but modeshape 3 somehow wants it. However, this is not necessary IMHO as neither jackrabbit 1 or 2 or modeshape 2 ever had a problem with that, as an nt:unstructured node may contain anything it wants but isn't forced to have anything special on it;

                     

                    Hope that helps.

                     

                    Best

                    • 7. Re: Modeshape 3 Beta 2: java.lang.NumberFormatException: For input string: "classname"
                      Randall Hauch Master

                      Based upon your partial stack trace above, brix does expect the primary item because it is calling "Node.getPrimaryItem()":

                       

                      Caused by: javax.jcr.ItemNotFoundException: The primary type "nt:file" for node "/brix:root/brix:web/brix:site/index" in workspace "bx_ZbybnPXdVXcNKZbdqXsHDHrONJ" does not define a primary item name

                          at org.modeshape.jcr.AbstractJcrNode.getPrimaryItem(AbstractJcrNode.java:1954)

                       

                      Perhaps it's not brix that's doing that, but in that case we'll need more than one line of a stack trace.

                       

                      Now, in Beta2, line 1954 of AbstractJcrNode is indeed an exception, but the exception is caused by the node's primary node type not having a property definition or child node definition that is marked as "primary". That's strange, given that the primary type of the "index.html" node shown above is "nt:file", which is defined as follows:

                       

                      [nt:file] > nt:hierarchyNode

                        + jcr:content (nt:base) primary mandatory

                       

                      Note how the "jcr:content" is listed as "primary", meaning the "jcr:content" child node should be considered the primary item.

                       

                      I looked briefly at the Brix code, and it looks like the BrixRepositoryInitializer registers a few node types, but always using the RepositoryUtil.registerNodeType(...) that registers the same kind of pattern every time.

                      So the only way I can understand how this exception can be thrown is if the node is not an "nt:file" node (e.g., "nt:unstructured" nodes do not have primary items), or if it is an "nt:file" node but the "nt:file" node type has been changed.

                       

                      Is there any way you can debug this to find out the NodeType instance that is being accessed in AbstractJcrNode.getPrimaryItem(), and why there's no primary item name?

                      • 8. Re: Modeshape 3 Beta 2: java.lang.NumberFormatException: For input string: "classname"
                        K. Bachl Novice

                        I can try to dig further, but I'm not sure it will help. (or at least I don't know what exactly I should look for)

                        You need to remember that this only happens on a restart of the repository. If an empty brix app is started (during its startup a whole new repo gets created of none exists) and then an empty one (empty in terms of brix -> only a single html index file) gets imported all is OK. Even if I take over my big 5MB XML and import it all works as expected and runs like hell. However, when the repo gets shutdown and then restarted like it is when it gets redeployed, then this error comes up.

                         

                        I might need to retry this with berkeleyDB in next days as I'm only tried yet with:

                        class="org.infinispan.loaders.jdbm.JdbmCacheStore"

                        • 9. Re: Modeshape 3 Beta 2: java.lang.NumberFormatException: For input string: "classname"
                          Randall Hauch Master

                          I can try to dig further, but I'm not sure it will help. (or at least I don't know what exactly I should look for)

                          If you can debug the application, you could set a breakpoint on line 1954 of AbstractJcrNode, and when the repository (re)starts and hits that error, you could then inspect the NodeType obtained on line 1950 to see the NodeType's name. If the NodeType's name is "nt:file", then that means the primary item name on the "nt:file" is no longer there (when it should always be there). Even this information would help a little.

                           

                           

                          You need to remember that this only happens on a restart of the repository. If an empty brix app is started (during its startup a whole new repo gets created of none exists) and then an empty one (empty in terms of brix -> only a single html index file) gets imported all is OK. Even if I take over my big 5MB XML and import it all works as expected and runs like hell. However, when the repo gets shutdown and then restarted like it is when it gets redeployed, then this error comes up.

                           

                          Hmm... that's new information. I just looked in our code that re-read the node type definitions from the Infinispan cache, and it looks like there's a bug there. I've logged MODE-1602 as a blocker issue, and I've already got a fix ready to be tested; it'll be in Wednesday's Beta3 release.

                           

                          Thanks for helping us track this down! As usual, it's just a matter of identifying the important and relevant information, which can be a challenge.

                           

                          UPDATE: a fix for MODE-1602 has been merged onto the 'master' branch and will be in 3.0.0.Beta3.

                          • 10. Re: Modeshape 3 Beta 2: java.lang.NumberFormatException: For input string: "classname"
                            K. Bachl Novice

                            Thanks for the update!

                             

                             

                            Hmm... that's new information.

                             

                            not really, in my first post regarding that error I wrote:

                             

                            This works ok on empty startup, and I can import an existing workspace.xml into it and then use it in my app as expected. However, after shutting down the server and restarting it, my app screams: "...

                            Caused by: javax.jcr.ItemNotFoundException: The primary type "nt:file" for node "/brix:root/brix:web/brix:site/index" in workspace "bx_ZbybnPXdVXcNKZbdqXsHDHrONJ" does not define a primary item name

                                at org.modeshape.jcr.AbstractJcrNode.getPrimaryItem(AbstractJcrNode.java:1954)

                            " - meaning he misses a primary item name that was there before restart. I tried to narrow it down and so made it that no files are touched by storage.binaryStorage but only infinispan, however, this was no solution at all. Any Idea what mistake I made here?

                            but I know that its hard to track things like that down - it also took me a while till I could blame modeshape 3 and not brix

                             

                            I'll no have a look at master or 3.0.0.Beta3 and let you know if this will fix the problem

                             

                            Best

                            • 11. Re: Modeshape 3 Beta 2: java.lang.NumberFormatException: For input string: "classname"
                              K. Bachl Novice

                              Ok, I can confirm that with latest master it works!

                               

                              One thing thow thats quite bad is the current infinispan handling within modeshape - in its main pom there are 3 different versions handled: https://github.com/ModeShape/modeshape/blob/master/modeshape-parent/pom.xml

                              5.1.2.Final

                              5.1.4.Final

                              5.1.5.Final

                               

                              This leads to a major problem with the cachestore connectors as those need to be same version, e.g:

                              <dependency>

                                          <groupId>org.infinispan</groupId>

                                          <artifactId>infinispan-cachestore-jdbm</artifactId>

                                          <version>5.1.2.FINAL</version>

                                      </dependency>

                               

                              cant be changed to latest 5.1.6.Final as then the repo cant be created/ wont come up;

                              • 12. Re: Modeshape 3 Beta 2: java.lang.NumberFormatException: For input string: "classname"
                                K. Bachl Novice

                                Follow up:

                                 

                                the last master works not as expected, as the repo content is lost after a restart of the system with current SNAPSHOT; storage is configured as:

                                 

                                 

                                 

                                "storage":{

                                        "cacheConfiguration":"cache-ms3.xml",

                                        "cacheName":"wwRepoCache",

                                        "transactionManagerLookup":"org.infinispan.transaction.lookup.GenericTransactionManagerLookup",

                                        "binaryStorage":{

                                            "minimumBinarySizeInBytes":4096,

                                            "type":"file",

                                            "directory":"/z-modeshape/modeshape3/jcr"

                                        }

                                    },

                                any error here? - because I also get an

                                 

                                 

                                INFO  - TransientBinaryStore   - ModeShape is using the following directory for transient storage of binary values: /var/folders/ql/9xg715td53s6prn53sj9szkw0000gn/T

                                 

                                in logs?

                                 

                                Interestingwise the cloned repos of my main one stay intact over restart, no matter if JDBM or BERKELE DB JE is used for infinispan cache storage;

                                • 13. Re: Modeshape 3 Beta 2: java.lang.NumberFormatException: For input string: "classname"
                                  Randall Hauch Master

                                  Yes, those were incorrect merges done yesterday that weren't caught until this morning. We're working on a fix.

                                  • 14. Re: Modeshape 3 Beta 2: java.lang.NumberFormatException: For input string: "classname"
                                    K. Bachl Novice

                                    ahh, understood - was some WTF? moments today when I realized that now restarting works but content is lost

                                     

                                    hope to see beta3 soon

                                    1 2 Previous Next