1 2 Previous Next 18 Replies Latest reply on Feb 4, 2010 10:29 AM by Bernd Ruecker

    Problems with SVN Connector

    Bernd Ruecker Master

      Hey guys, I checked out the Beta1 version but get into some trouble with SVN. Basically it seems not all nodes have the primaryTypes attached correctly.

       

      I just wrote some very easy to dump the content of the SVN to the console:

       

        private void print(Node node, String intend) throws RepositoryException {
          if (node.hasProperty("jcr:primaryType")) {
            try {
              Value v = node.getProperty("jcr:primaryType").getValue(); //JcrLexicon.PRIMARY_TYPE.getNamespaceUri());
              if ("nt:file".equals(v.getString())) {
                if (node.getNode("jcr:content").hasProperty("jcr:data")) {
                  System.out.println(intend + "FILE -> " + node.getName() + " -> " ); 
                      + node.getNode("jcr:content").getProperty("jcr:data").getValue().getString());
                }
                else {
                  System.out.println(intend + "FILE -> " + node.getName() + "  IS EMPTY");
                }
              }
              if ("nt:folder".equals(v.getString())) {
                System.out.println(intend + "FOLDER -> " + node.getName());
              }
            }
            catch (Exception ex) {
              System.out.println("ERROR ON: " + node.getName());
              PropertyIterator iter = node.getProperties();
              while (iter.hasNext()) {
                System.out.println("         property:" + iter.nextProperty().getName());
              }
              ex.printStackTrace();
            }
          }
          else {
            System.out.println("NO PRIMARY TYPE: " + node.getName());
          }
          NodeIterator iter = node.getNodes();
          while (iter.hasNext()) {
            Node nextNode = iter.nextNode();
            print(nextNode, intend + "   ");
          }   
        }
      
      

       

      The strange thing is, that it worked with files, but as soon as I create a folder in the SVN the primaryType is missing, but not only for the folder but for the following files as well! Some bug? Or my fault? Is there some real working example with SVN and ModeShape?

       

      Thanks for any hint and cheers

      Bernd

        • 1. Re: Problems with SVN Connector
          Brian Carothers Apprentice

          Are you creating the folder directly in SVN or through the SVN connector?  (Both should work, but I'm trying to localize the problem).  Also, have you modified the cache settings for the connector?

           

          I ran a quick local test at the connector level and things were working correctly, but that's not to say that the error couldn't be above the connector level.

           

          Thanks

          • 2. Re: Problems with SVN Connector
            Bernd Ruecker Master

            I created everything in the SVN, at the moment I just try to read existing stuff.

             

            Here is my configuration, nothing really special there:

             

            <configuration xmlns:mode="http://www.modeshape.org/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0">
                <mode:sources jcr:primaryType="nt:unstructured">
                    <mode:source 
                                jcr:name="SVNStore" 
                                mode:classname="org.modeshape.connector.svn.SvnRepositorySource" 
                                mode:description="SVN repository (anonymous access)"
                                mode:repositoryRootUrl="xxx" 
                                mode:defaultWorkspaceName="trunk"
                                mode:predefinedWorkspaceNames="trunk"
                                mode:creatingWorkspaceAllowed="false"
                                mode:username="anonymous"
                                mode:password=""
                    />
                </mode:sources>    
                <mode:sequencers>
                </mode:sequencers>    
                <mode:repositories>
                      <mode:repository jcr:name="development svn" mode:source="SVNStore">          
                          <mode:options jcr:primaryType="mode:options">
                              <jaasLoginConfigName jcr:primaryType="mode:option" mode:value="modeshape-jcr"/>
                          </mode:options>
                      </mode:repository>
                </mode:repositories>
            </configuration>
            

             

            And there is not much more, the whole code looks like this (and I think you can guess what is inside the methods):

             

                    setupJaas();         
                     JcrEngine engine = setupJcrEngine();
                     Session session = setupJcrSession(engine);
            
                     print(session.getRootNode(), "");
            
                     tearDown(session, engine);
                     engine.shutdown();
            

             

            Thanks a lot for looking at it!

            • 3. Re: Problems with SVN Connector
              Bernd Ruecker Master

              And here the folder structure and the Stacktrace by the way. It seems if I debug through it, only the exception on the directory is thrown, the other stuff seems to work then, strange.

               

              dir/
                process.jpdl
              test.txt
              test.pdf
              empty.txt
              
              
              ERROR ON: dir
              javax.jcr.PathNotFoundException: No item exists at path jcr:primaryType relative to /dir in workspace "trunk"
                   at org.modeshape.jcr.AbstractJcrNode.getProperty(AbstractJcrNode.java:543)
                   at com.camunda.hemera.connect.SvnViaModeShapeTest.print(SvnViaModeShapeTest.java:163)
                   at com.camunda.hemera.connect.SvnViaModeShapeTest.print(SvnViaModeShapeTest.java:193)
                   at com.camunda.hemera.connect.SvnViaModeShapeTest.testBasicSvnAccess(SvnViaModeShapeTest.java:202)
                   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                   at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
                   at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
                   at java.lang.reflect.Method.invoke(Unknown Source)
                   at junit.framework.TestCase.runTest(TestCase.java:154)
                   at junit.framework.TestCase.runBare(TestCase.java:127)
                   at junit.framework.TestResult$1.protect(TestResult.java:106)
                   at junit.framework.TestResult.runProtected(TestResult.java:124)
                   at junit.framework.TestResult.run(TestResult.java:109)
                   at junit.framework.TestCase.run(TestCase.java:118)
                   at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
                   at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
                   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
                   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
                   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
                   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
              
                    FILE -> process.jpdl -> 
              
                 FILE -> empty.txt  IS EMPTY
              
              ERROR ON: test.txt
              javax.jcr.PathNotFoundException: No item exists at path jcr:primaryType relative to /test.txt in workspace "trunk"
                   at org.modeshape.jcr.AbstractJcrNode.getProperty(AbstractJcrNode.java:543)
                   at com.camunda.hemera.connect.SvnViaModeShapeTest.print(SvnViaModeShapeTest.java:163)
                   at com.camunda.hemera.connect.SvnViaModeShapeTest.print(SvnViaModeShapeTest.java:193)
                   at com.camunda.hemera.connect.SvnViaModeShapeTest.testBasicSvnAccess(SvnViaModeShapeTest.java:202)
                   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                   at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
                   at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
                   at java.lang.reflect.Method.invoke(Unknown Source)
                   at junit.framework.TestCase.runTest(TestCase.java:154)
                   at junit.framework.TestCase.runBare(TestCase.java:127)
                   at junit.framework.TestResult$1.protect(TestResult.java:106)
                   at junit.framework.TestResult.runProtected(TestResult.java:124)
                   at junit.framework.TestResult.run(TestResult.java:109)
                   at junit.framework.TestCase.run(TestCase.java:118)
                   at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
                   at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
                   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
                   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
                   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
                   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
                   
              ERROR ON: test.pdf
              javax.jcr.PathNotFoundException: No item exists at path jcr:primaryType relative to /test.pdf in workspace "trunk"
                   at org.modeshape.jcr.AbstractJcrNode.getProperty(AbstractJcrNode.java:543)
                   at com.camunda.hemera.connect.SvnViaModeShapeTest.print(SvnViaModeShapeTest.java:163)
                   at com.camunda.hemera.connect.SvnViaModeShapeTest.print(SvnViaModeShapeTest.java:193)
                   at com.camunda.hemera.connect.SvnViaModeShapeTest.testBasicSvnAccess(SvnViaModeShapeTest.java:202)
                   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                   at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
                   at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
                   at java.lang.reflect.Method.invoke(Unknown Source)
                   at junit.framework.TestCase.runTest(TestCase.java:154)
                   at junit.framework.TestCase.runBare(TestCase.java:127)
                   at junit.framework.TestResult$1.protect(TestResult.java:106)
                   at junit.framework.TestResult.runProtected(TestResult.java:124)
                   at junit.framework.TestResult.run(TestResult.java:109)
                   at junit.framework.TestCase.run(TestCase.java:118)
                   at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
                   at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
                   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
                   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
                   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
                   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
              
              ERROR ON: jcr:system
              javax.jcr.PathNotFoundException: No item exists at path jcr:primaryType relative to /jcr:system in workspace "trunk"
                   at org.modeshape.jcr.AbstractJcrNode.getProperty(AbstractJcrNode.java:543)
                   at com.camunda.hemera.connect.SvnViaModeShapeTest.print(SvnViaModeShapeTest.java:163)
                   at com.camunda.hemera.connect.SvnViaModeShapeTest.print(SvnViaModeShapeTest.java:193)
                   at com.camunda.hemera.connect.SvnViaModeShapeTest.testBasicSvnAccess(SvnViaModeShapeTest.java:202)
                   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                   at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
                   at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
                   at java.lang.reflect.Method.invoke(Unknown Source)
                   at junit.framework.TestCase.runTest(TestCase.java:154)
                   at junit.framework.TestCase.runBare(TestCase.java:127)
                   at junit.framework.TestResult$1.protect(TestResult.java:106)
                   at junit.framework.TestResult.runProtected(TestResult.java:124)
                   at junit.framework.TestResult.run(TestResult.java:109)
                   at junit.framework.TestCase.run(TestCase.java:118)
                   at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
                   at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
                   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
                   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
                   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
                   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
              
              
              • 4. Re: Problems with SVN Connector
                Brian Carothers Apprentice

                The strangest thing about this is that the jcr:system node doesn't have a primary type either and that has nothing to do with SVN.  I think that there may be a problem on startup.

                 

                Could you please upload your test case?  I'd like to run it locally and see what's going on.  Alternatively, could you see if your JcrEngine returns anything from getProblems() after you call start() on it?

                 

                Thanks

                • 5. Re: Problems with SVN Connector
                  Bernd Ruecker Master

                  No, there are no problems in the engine (it took me a couple of time to figure out that I need to check that, because in the beginning I had problems ;-)).

                   

                  Attached my test case, just removed the repository URL for the public available code (you can use our Repos for testing if you want, just send me an email at bernd.ruecker@camunda.com).

                   

                  Thanks

                  Bernd

                   

                  PS: Sorry for the late reply, I was on a conference yesterday. Serge can proove it, I met him there ;-)

                  • 6. Re: Problems with SVN Connector
                    Brian Carothers Apprentice

                    Thanks for posting the test case - that was very helpful.  The bug is actually in SessionCache.  It looks like have a soft reference to a cached JcrProperty (which is good) and we assume that the reference wasn't garbage collected (which is not good).  This also explains why a very similar test that we run didn't catch the bug.  It's dependent on the whims of gc scheduling.

                     

                    I will try to poke around on a fix today, but I might not be able to patch it in trunk until this weekend.

                    • 8. Re: Problems with SVN Connector
                      Bernd Ruecker Master
                      Wow, that was quick! Thank's a lot for taking care of it. Weekend would be already perfect!
                      • 9. Re: Problems with SVN Connector
                        Brian Carothers Apprentice

                        The patch has been applied to trunk.  If you get a chance, please test this against the latest snapshot.

                         

                        Thanks for catching this and please let us know if the fix works for you.

                        • 10. Re: Problems with SVN Connector
                          Bernd Ruecker Master

                          Thanks!

                           

                          But currently when I check out head it doesn't build, one test is failing (but I will try it anyway and build it with tests disabled):

                           

                          -------------------------------------------------------------------------------
                          Test set: org.modeshape.common.math.DurationTest
                          -------------------------------------------------------------------------------
                          Tests run: 4, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.01 sec <<< FAILURE!
                          shouldRepresentTimeInProperFormat(org.modeshape.common.math.DurationTest)  Time elapsed: 0.004 sec  <<< FAILURE!
                          org.junit.ComparisonFailure: expected:<00:00:02[.]000> but was:<00:00:02[,]000>
                               at org.junit.Assert.assertEquals(Assert.java:99)
                               at org.junit.Assert.assertEquals(Assert.java:117)
                               at org.modeshape.common.math.DurationTest.shouldRepresentTimeInProperFormat(DurationTest.java:65)
                               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.internal.runners.TestMethod.invoke(TestMethod.java:59)
                               at org.junit.internal.runners.MethodRoadie.runTestMethod(MethodRoadie.java:98)
                               at org.junit.internal.runners.MethodRoadie$2.run(MethodRoadie.java:79)
                               at org.junit.internal.runners.MethodRoadie.runBeforesThenTestThenAfters(MethodRoadie.java:87)
                               at org.junit.internal.runners.MethodRoadie.runTest(MethodRoadie.java:77)
                               at org.junit.internal.runners.MethodRoadie.run(MethodRoadie.java:42)
                               at org.junit.internal.runners.JUnit4ClassRunner.invokeTestMethod(JUnit4ClassRunner.java:88)
                               at org.junit.internal.runners.JUnit4ClassRunner.runMethods(JUnit4ClassRunner.java:51)
                               at org.junit.internal.runners.JUnit4ClassRunner$1.run(JUnit4ClassRunner.java:44)
                               at org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:27)
                               at org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:37)
                               at org.junit.internal.runners.JUnit4ClassRunner.run(JUnit4ClassRunner.java:42)
                               at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:62)
                               at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:140)
                               at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:127)
                               at org.apache.maven.surefire.Surefire.run(Surefire.java:177)
                               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.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:338)
                               at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:997)
                          
                          • 11. Re: Problems with SVN Connector
                            Randall Hauch Master

                            Blast! We've had problems with this test in the past, especially with different locales, but I thought we had fixed it. Apparently not. Would you mind logging a JIRA for this? The test should not be comparing strings that rely upon locale-specific formatting rules.

                             

                            You can get around it locally by just adding "@Ignore" to that whole test class.

                            • 12. Re: Problems with SVN Connector
                              Bernd Ruecker Master

                              @Brian: That fix seems to work, my test case runs perfectly fine now :-) Thanks a lot!

                               

                              @Randall: Sure, I created https://jira.jboss.org/jira/browse/MODE-656.

                              • 13. Re: Problems with SVN Connector
                                Randall Hauch Master
                                Glad that worked, and thanks for putting in that bug report! I'll get that fixed today.
                                • 14. Re: Problems with SVN Connector
                                  Randall Hauch Master

                                  Bernd, I've committed the fix for the test failure to trunk. Feel free to check my work, but I did test it locally by running with several different locales.

                                  1 2 Previous Next