1 Reply Latest reply on Jan 14, 2015 4:15 AM by Horia Chiorean

    ModeShape and Infinispan 7 usage error

    Prashant Thakur Novice

      We would like to use ModeShape as a query interface over our Infinispan 7 deployment.

      The reason being we have related data across multiple caches and would like to create joins across them.

      New to Modeshape and when I looked into latest release it shows Infinispan 6.0.2.Final is used.

      While trying to run a sample program specifying configuration file for Infinispan 7 its throwing errors.

      Account and Subscriber are two related entities which we want to query together using Modeshape. First attempt is just to iniitialize with Account and it throws error.

      Am I missing something or Modeshape doesn't support Infinispan 7 as yet. According to my understanding from getting started page versions can be upgraded, Might be something is missing where I need some help.

      Code Used is same as from sample just changed the Account as new class

       

      Random rnd = new Random();
      // Create and start the engine ...
              ModeShapeEngine engine = new ModeShapeEngine();
              engine.start();

       

       

              // Load the configuration for a repository via the classloader (can also use path to a file)...
              Repository repository = null;
              String repositoryName = null;
              try {
                  URL url = DistTestServer.class.getClassLoader().getResource("my-repository-config.json");
                  RepositoryConfiguration config = RepositoryConfiguration.read(url);

       

       

                  // We could change the name of the repository programmatically ...
                  // config = config.withName("Some Other Repository");

       

       

                  // Verify the configuration for the repository ...
                  Problems problems = config.validate();
                  if (problems.hasErrors()) {
                      System.err.println("Problems starting the engine.");
                      System.err.println(problems);
                      System.exit(-1);
                  }

       

       

                  // Deploy the repository ...
                  repository = engine.deploy(config);
                  repositoryName = config.getName();
              } catch (Throwable e) {
                  e.printStackTrace();
                  System.exit(-1);
                  return;
              }
             
              Session session = null;
              try {
                  // Get the repository
                  repository = engine.getRepository(repositoryName);

       

       

                  // Create a session ...
                  session = repository.login();

       

       

                  // Get the root node ...
                  Node root = session.getRootNode();
                  assert root != null;

       

       

                  System.out.println("Found the root node in the \"" + session.getWorkspace().getName() + "\" workspace");

       

       

                  Node n = root.addNode("Node" + rnd.nextInt());

       

       

                  n.setProperty("key", "value");
                  n.setProperty("content", session.getValueFactory().createBinary(new ByteArrayInputStream(new byte[1000])));

       

       

                  session.save();

       

       

                  System.out.println("Added one node under root");
                  System.out.println("+ Root childs");

       

       

                  NodeIterator it = root.getNodes();
                  while (it.hasNext()) {
                      System.out.println("+---> " + it.nextNode().getName());
                  }
              } catch (Exception e) {
                  e.printStackTrace();
              } finally {
                  if (session != null) session.logout();
                  System.out.println("Shutting down engine ...");
                  try {
                      engine.shutdown().get();
                      System.out.println("Success!");
                  } catch (Exception e) {
                      e.printStackTrace();
                  }
              }

      INFO [org.modeshape.jcr.JcrRepository] [main] (Log4jLoggerImpl.java:87) - ModeShape version 4.1.0.Final

      javax.jcr.RepositoryException: Error while starting 'ACCOUNT' repository: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file:  java.naming.factory.initial

        at org.modeshape.jcr.JcrRepository.login(JcrRepository.java:652)

        at org.modeshape.jcr.JcrRepository.login(JcrRepository.java:611)

        at org.modeshape.jcr.JcrRepository.login(JcrRepository.java:143)

        at com.subex.spark.DistTestServer.main(DistTestServer.java:100)

      Caused by: javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file:  java.naming.factory.initial

        at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:662)

        at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:307)

        at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:344)

        at javax.naming.InitialContext.lookup(InitialContext.java:411)

        at org.modeshape.jcr.LocalEnvironment.createContainer(LocalEnvironment.java:201)

        at org.modeshape.jcr.LocalEnvironment.getCacheContainer(LocalEnvironment.java:106)

        at org.modeshape.jcr.RepositoryConfiguration.getCacheContainer(RepositoryConfiguration.java:982)

        at org.modeshape.jcr.RepositoryConfiguration.getContentCacheContainer(RepositoryConfiguration.java:972)

        at org.modeshape.jcr.JcrRepository$RunningState.<init>(JcrRepository.java:1073)

        at org.modeshape.jcr.JcrRepository$RunningState.<init>(JcrRepository.java:977)

        at org.modeshape.jcr.JcrRepository.doStart(JcrRepository.java:386)

        at org.modeshape.jcr.JcrRepository.login(JcrRepository.java:650)

        ... 3 more

      Shutting down engine ...