4 Replies Latest reply on Jun 3, 2014 9:35 AM by rhauch

    Versioning: Java exceptions at the "session.save()"




      I m new in ModeShape and I m try do understand it mostly by examples.


      I m trying to update a node content with a string value and byte values and visualize all the versions about it. I reatrieve the node by path and it is laready "mix:versionable" at the moment of creation.

      I get the problem when I try to save the session  (at the call "session.save()")  because it always throws me  "NullPointerException"



      Reading my code did I write something wrong ? any ideas?



      Thanks in advance!





      public void updateNode(InputStream in1,String newInfo, String pathNodo) {


      Session session = null;

                  try {


                      repository = istanceRepository();

                      session = repository.login(workspaceName);


                      org.modeshape.jcr.api.Session msSession = (org.modeshape.jcr.api.Session)session;

                      org.modeshape.jcr.api.RepositoryManager repoMgr = ((org.modeshape.jcr.api.Session)session).getWorkspace().getRepositoryManager();


                      Node node = session.getNode(pathNodo); 



                      Binary binary1 = session.getValueFactory().createBinary(in1);        

                      node.setProperty("jcr:content", binary1);





                      //print version history

                      VersionHistory history = node.getVersionHistory();

                      for (VersionIterator it = history.getAllVersions(); it.hasNext();) {

                        Version version = (Version) it.next();




      } catch ( Exception e1) {


                      out.println("<p> ErrorMessage: "+ e1.getMessage()+ "<p>");

                      out.println("<p> ErrorCause: "+ e1.getCause()+ "<p>");


                  } finally {

                      // Always close the session ...

                      if ( session != null ) session.logout();