Uploaded image for project: 'ModeShape'
  1. ModeShape
  2. MODE-693

Hibernate error when using JPA Connector with MySQL and deleting a node from a branch that also contains a large value (file) node

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Blocker Blocker
    • 1.1.0.Final
    • 1.0.0.Final
    • Storage
    • None

      When using ModeShape 1.0.0.Final (plus patch for MODE-691) with the JPA Connector, MySQL v5.1.41-community, and MySQL Connector/J 5.1.12, a hibernate NodeTraverser error is thrown under the following conditions:

      An nt:file node has been created with binary content larger than the repository configuration's mode:source setting for mode:largeValueSizeInBytes.
      An nt:unstructured node has been created in the same branch as the file node.

      For example, the nt:file node could have the path:
      /project1/images/filenode (with large binary data for the data property of its jcr:content node)
      and the nt:unstructured node could have the path:
      /project1/content/contentnode

      The exception is thrown when the session is saved after calling node.remove() on the nt:unstructured node.
      This error occurs with MySQL but not with HSQLDB, and appears to be triggered by the call to org.modeshape.connector.store.jpa.model.simple.LargeValueEntity.deleteUnused().
      The error does not occur if the file node's data size is less than mode:largeValueSizeInBytes.

      Code block which triggers the SQL error (session is the javax.jcr.Session, pathToNode is relative to the workspace root node):

      Node root = session.getRootNode();
      if(!root.hasNode(pathToNode)) {
      throw new RepositoryException("Cannot delete node at path=" + pathToNode + " since no node exists at this path");
      }
      Node nodeToDelete = root.getNode(pathToNode);
      nodeToDelete.remove();
      session.save();

      The repository source settings in my configuration XML are like this:
      <mode:source jcr:name="ContentLibrary" mode:classname="org.modeshape.connector.store.jpa.JpaSource"
      mode:model="Simple"
      mode:dialect="org.hibernate.dialect.MySQL5InnoDBDialect"
      mode:driverClassName="com.mysql.jdbc.Driver"
      mode:username="modeshapeuser"
      mode:password="modeshapepassword"
      mode:url="jdbc:mysql://localhost:3306/modeshapetest?autoReconnect=true"
      mode:maximumConnectionsInPool="1"
      mode:referentialIntegrityEnforced="true"
      mode:largeValueSizeInBytes="1024"
      mode:retryLimit="3"
      mode:compressData="false"
      mode:predefinedWorkspaceNames="default"
      mode:showSql="false"
      mode:autoGenerateSchema="create"
      mode:creatingWorkspacesAllowed="true"
      mode:defaultWorkspaceName="default" />

      And here is the relevant part of the exception stack trace:

      org.springframework.extensions.jcr.JcrSystemException: Repository access exception; nested exception is javax.jcr.RepositoryException: java.lang.IllegalArgumentException: node to traverse cannot be null!: java.lang.IllegalArgumentException: node to traverse cannot be null!: java.lang.IllegalArgumentException: node to traverse cannot be null!
      at org.springframework.extensions.jcr.SessionFactoryUtils.translateException(SessionFactoryUtils.java:223)
      at org.springframework.extensions.jcr.JcrAccessor.convertJcrAccessException(JcrAccessor.java:58)
      at org.springframework.extensions.jcr.JcrTemplate.execute(JcrTemplate.java:94)
      at org.springframework.extensions.jcr.JcrTemplate.execute(JcrTemplate.java:115)
      at com.xxxxx.xxx.dao.jcr.JcrNodeDao.remove(JcrNodeDao.java:541)
      at com.xxxxx.xxx.dao.jcr.JcrNodeDaoIntegrationTest.testRemoveAfterFileUpoad(JcrNodeDaoIntegrationTest.java:305)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:597)
      at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
      at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
      at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
      at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
      at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
      at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74)
      at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:82)
      at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:72)
      at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:240)
      at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
      at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
      at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
      at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
      at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
      at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
      at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
      at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
      at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
      at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:180)
      at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:46)
      at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
      Caused by: javax.jcr.RepositoryException: java.lang.IllegalArgumentException: node to traverse cannot be null!: java.lang.IllegalArgumentException: node to traverse cannot be null!: java.lang.IllegalArgumentException: node to traverse cannot be null!
      at org.modeshape.jcr.SessionCache.save(SessionCache.java:380)
      at org.modeshape.jcr.JcrSession.save(JcrSession.java:1015)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:597)
      at org.springframework.extensions.jcr.JcrTemplate$LogoutSuppressingInvocationHandler.invoke(JcrTemplate.java:706)
      at $Proxy52.save(Unknown Source)
      at com.xxxxx.xxx.dao.jcr.JcrNodeDao$14.doInJcr(JcrNodeDao.java:554)
      at com.xxxxx.xxx.dao.jcr.JcrNodeDao$14.doInJcr(JcrNodeDao.java:1)
      at org.springframework.extensions.jcr.JcrTemplate.execute(JcrTemplate.java:89)
      ... 32 more
      Caused by: org.modeshape.graph.connector.RepositorySourceException: java.lang.IllegalArgumentException: node to traverse cannot be null!
      at org.modeshape.graph.session.GraphSession.save(GraphSession.java:817)
      at org.modeshape.jcr.SessionCache.save(SessionCache.java:374)
      ... 42 more
      Caused by: java.lang.IllegalArgumentException: node to traverse cannot be null!
      at org.hibernate.hql.ast.util.NodeTraverser.traverseDepthFirst(NodeTraverser.java:55)
      at org.hibernate.hql.ast.QueryTranslatorImpl.parse(QueryTranslatorImpl.java:277)
      at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:180)
      at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:134)
      at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:101)
      at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:80)
      at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:94)
      at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:156)
      at org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:135)
      at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1650)
      at org.hibernate.ejb.AbstractEntityManagerImpl.createQuery(AbstractEntityManagerImpl.java:93)
      at org.modeshape.connector.store.jpa.model.simple.LargeValueEntity.deleteUnused(LargeValueEntity.java:216)
      at org.modeshape.connector.store.jpa.model.simple.SimpleJpaRepository$Workspace.removeUuidReference(SimpleJpaRepository.java:412)
      at org.modeshape.graph.connector.map.AbstractMapWorkspace.removeNode(AbstractMapWorkspace.java:268)
      at org.modeshape.graph.connector.map.MapRequestProcessor.process(MapRequestProcessor.java:315)
      at org.modeshape.graph.request.processor.RequestProcessor.process(RequestProcessor.java:229)
      at org.modeshape.graph.request.processor.RequestProcessor.process(RequestProcessor.java:316)
      at org.modeshape.graph.request.processor.RequestProcessor.process(RequestProcessor.java:223)
      at org.modeshape.connector.store.jpa.model.simple.SimpleJpaConnection.execute(SimpleJpaConnection.java:127)
      at org.modeshape.graph.connector.RepositoryConnectionPool$ConnectionWrapper.execute(RepositoryConnectionPool.java:997)
      at org.modeshape.graph.request.CompositeRequestChannel$2.call(CompositeRequestChannel.java:193)
      at org.modeshape.graph.request.CompositeRequestChannel$2.call(CompositeRequestChannel.java:183)
      at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
      at java.util.concurrent.FutureTask.run(FutureTask.java:138)
      at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
      at java.lang.Thread.run(Thread.java:619)

              bcarothers_jira Brian Carothers (Inactive)
              lookfar1090_jira Greg Larson (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: