1 Reply Latest reply on Nov 10, 2014 10:12 AM by Horia Chiorean

    Exception The 'query' field on '' is not defined in the schema

    David virgil naranjo Novice

      Hi I receive the following exception when the json modeshape config file is validated

       

      Caused by: javax.jcr.RepositoryException: ERROR: Error at query : The 'query' field on '' is not defined in the schema and the schema does not allow additional properties.

       

      We are using modeshape 4.0.0.Final and infinispan 6.0.2.Final

       

      The json file is:

       

      {

          "name" : "sramp",

          "jndiName" : "",

          "workspaces" : {

              "predefined" : ["otherWorkspace"],

              "default" : "default",

              "allowCreation" : true

          },

          "security" : {

              "anonymous" : {

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

                  "useOnFailedLogin" : false

              },

              "providers" : [

                  {

                      "classname" : "org.modeshape.jcr.security.ServletProvider"

                  }

               ]

          },"storage": {

              "cacheName": "sramp",

              "cacheConfiguration" : "infinispan-configuration-webapp.xml",

              "binaryStorage": {

                  "type"  : "database",

                  "dataSourceJndiName" : "java:comp/env/jdbc/sramp",

                  "minimumBinarySizeInBytes" : "${application.min.binary.size:4096}"

              }

          },"query" : {

              "indexStorage" : {

                  "type" : "filesystem",

                  "location" : "overlord-data/index",

                  "lockingStrategy" : "simple",

                  "fileSystemAccessType" : "auto"

              }

          }

      }

       

       

      The problem is in the validation of the field "query". Having debugged the validation process,  that is done in the class: org.infinispan.schematic.internal.InMemorySchemaLibrary. Then it is called this class JsonSchemaValidatorFactory$CompositeValidator  and the validation is done:

       

      There are like 20 different validators. The validator that fails is the one called "additional properties not allowed"

       

      The problem is in this part of the validation:

       

      public void validate( Object fieldValue,

                                    String fieldName,

                                    Document parent,

                                    Path pathToParent,

                                    Problems problems,

                                    SchemaDocumentResolver resolver ) {

                  if (fieldValue == null) {

                      if (fieldName == null) {

                          // Go through all of the fields in the document ...

                          for (Field field : parent.fields()) {

                              validate(field.getValue(), field.getName(), parent, pathToParent, problems, resolver);

                          }

                      }

                  } else {

                      if (!allowedPropertyNames.contains(fieldName)) {

                          // Then the field is not handled by an explicit schema, so it's not allowed ...

                          problems.recordError(pathToParent.with(fieldName),

                                               "The '" + fieldName + "' field on '" + pathToParent

                                               + "' is not defined in the schema and the schema does not allow additional properties.");

                      } else {

                          problems.recordSuccess();

                      }

                  }

              }

       

      The values of allowedPropertyNames are:

       

      [externalSources, monitoring, node-types, garbageCollection, indexes, sequencing, security, journaling, transactionMode, indexProviders, textExtraction, description, name, workspaces, jndiName, storage]

       

      That means the field "query" is not used anymore in the modeshape 4.0.0.Final.

       

      Anyway, I am trying to discover what happened, so I changed the field "query to "indexes". Then when the validation process was run, this exception appeared:

       

      Caused by: javax.jcr.RepositoryException: ERROR: The 'indexStorage' index must have a valid 'provider' value that matches an existing index provider.

       

      As your documentation said, the field query should be allowed:

       

      https://docs.jboss.org/author/display/MODE40/Getting+Started

       

      i do not know if could be related with the infinispan-version. I am just trying to adapt to the versions used in wildfly for modeshape and infinispan.