7 Replies Latest reply on Jul 18, 2012 9:59 AM by emiste

    Zip sequencer is not working with File System source For 2.8.1 and 2.8.2

    emiste

      Hello,

       

      I'v got an exception ( see below ) during my attemp to use the a zip sequencer within a File System source. I just adapted the tests found in modeshape-2.8.2.Final-gettingstarted-examples. to use a File System connector .

       

      11:20:03.789 [modeshape-5-thread-1] ERROR o.m.r.sequencer.SequencingService - Error finding sequencers to run against node 2012-07-17T10:20:03.633Z @ [store] - 1 changes
      org.modeshape.graph.connector.RepositorySourceException: Primary type "store" for path "nt:unstructured" in workspace "/" in default is not valid for the file system connector.  Valid primary types are nt:file, nt:folder, nt:resource, and dna:resouce. 
      
            at org.modeshape.connector.filesystem.FileSystemWorkspace.validate(FileSystemWorkspace.java:777) ~[modeshape-connector-filesystem-2.8.2.Final.jar:2.8.2.Final]
            at org.modeshape.connector.filesystem.FileSystemRepository$FileSystemTransaction.validateNode(FileSystemRepository.java:204) ~[modeshape-connector-filesystem-2.8.2.Final.jar:2.8.2.Final]
            at org.modeshape.connector.filesystem.FileSystemRepository$FileSystemTransaction.validateNode(FileSystemRepository.java:165) ~[modeshape-connector-filesystem-2.8.2.Final.jar:2.8.2.Final]
            at org.modeshape.graph.connector.base.PathTransaction$WorkspaceChanges.created(PathTransaction.java:894) ~[modeshape-graph-2.8.2.Final.jar:2.8.2.Final]
            at org.modeshape.graph.connector.base.PathTransaction.addChild(PathTransaction.java:358) ~[modeshape-graph-2.8.2.Final.jar:2.8.2.Final]
            at org.modeshape.connector.filesystem.FileSystemRepository$FileSystemTransaction.addChild(FileSystemRepository.java:221) ~[modeshape-connector-filesystem-2.8.2.Final.jar:2.8.2.Final]
            at org.modeshape.connector.filesystem.FileSystemRepository$FileSystemTransaction.addChild(FileSystemRepository.java:165) ~[modeshape-connector-filesystem-2.8.2.Final.jar:2.8.2.Final]
            at org.modeshape.graph.connector.base.Processor.process(Processor.java:306) ~[modeshape-graph-2.8.2.Final.jar:2.8.2.Final]
            at org.modeshape.graph.request.processor.RequestProcessor.process(RequestProcessor.java:250) ~[modeshape-graph-2.8.2.Final.jar:2.8.2.Final]
            at org.modeshape.graph.request.processor.RequestProcessor.process(RequestProcessor.java:363) ~[modeshape-graph-2.8.2.Final.jar:2.8.2.Final]
            at org.modeshape.graph.request.processor.RequestProcessor.process(RequestProcessor.java:235) ~[modeshape-graph-2.8.2.Final.jar:2.8.2.Final]
            at org.modeshape.graph.connector.base.Connection.execute(Connection.java:115) ~[modeshape-graph-2.8.2.Final.jar:2.8.2.Final]
            at org.modeshape.graph.Graph.execute(Graph.java:288) ~[modeshape-graph-2.8.2.Final.jar:2.8.2.Final]
            at org.modeshape.graph.Graph$Batch.execute(Graph.java:4970) ~[modeshape-graph-2.8.2.Final.jar:2.8.2.Final]
            at org.modeshape.graph.io.GraphBatchDestination.submit(GraphBatchDestination.java:197) ~[modeshape-graph-2.8.2.Final.jar:2.8.2.Final]
            at org.modeshape.repository.sequencer.StreamSequencerAdapter.execute(StreamSequencerAdapter.java:235) ~[modeshape-repository-2.8.2.Final.jar:2.8.2.Final]
            at org.modeshape.repository.sequencer.SequencingService.processChange(SequencingService.java:498) ~[modeshape-repository-2.8.2.Final.jar:2.8.2.Final]
            at org.modeshape.repository.sequencer.SequencingService$RepositoryObserver$1.run(SequencingService.java:666) [modeshape-repository-2.8.2.Final.jar:2.8.2.Final]
            at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [na:1.6.0_27]
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [na:1.6.0_27]
            at java.lang.Thread.run(Thread.java:662) [na:1.6.0_27]
      
      

       

      Is it a bug or just there is something I missed ?

       

      Best regards

        • 1. Re: Zip sequencer is not working with File System source For 2.8.1 and 2.8.2
          hchiorean

          Hi,

           

          The exception (which has a "missaranged" message) seems to indicate that the zip sequencer is trying to add a child node of type nt:unstructured to a file system source (which isn't allowed, only nt:file, nt:folder, nt:resource and dna:resouce are allowed)

          What does the sequencing configuration output path look like ? (if you're using the API and not an xml, it should be the .andOutputtingTo method)

          • 2. Re: Zip sequencer is not working with File System source For 2.8.1 and 2.8.2
            rhauch

            The basic issue is that you're configuring the sequencer to output the derived information to the node that is being sequenced, but the node being sequenced (an "nt:file" node) doesn't allow children of type "nt:folder" or "nt:file" (or the common base type "nt:hierarchyNode").

             

            The simplest solution is to change your sequencer configuration to output the derived information to a different location, by appending " => {outputPath}" to your sequencer path expression(s). See our documentation that describes the path expression format.

             

            However, if you *really* want the files/folders in the ZIP file to be output under the input "nt:file" node (that represents the ZIP file), then you can actually do that (keeping your same sequencing configuration) if you add a mixin to the ZIP file node that allows it to have children of type "nt:file" and "nt:folder". There is no such mixin defined by JCR 2.0 or by ModeShape, but you could create your own custom node type to do this, and t might look something like this:

             

            [acme:nestedFile] mixin
              + * (nt:hierarchyNode) version
            

             

            Then simply add this mixin to the "nt:file" node (before saving and thus before the sequencers are activated) using:

             

            node.addMixin("acme:nestedFile");
            

             

            Hope this helps!

            • 3. Re: Zip sequencer is not working with File System source For 2.8.1 and 2.8.2
              emiste

              Hi ,

               

              Thank you Horia and Randall for your quick replies. Actually,  I just made some changes in the modeshape-2.8.2.Final-gettingstarted-examples.  project as folows:

              I commented all the defined sequencers in file  " SequencingClientTest.java  " expect "zip sequencer" and I changed the source:

               

               

              config.repositorySource("store").usingClass(FileSystemSource.class)
                              .setDescription("The repository for our content")
                              .setProperty("defaultWorkspaceName", workspaceName)
                              .setProperty("updatesAllowed", true);
              
                config.sequencer("Zip Sequencer")
                              .usingClass(ZipSequencer.class)
                              .setDescription(
                                      "Sequences Zip, WAR, and JAR files to extract the contents")
                              .sequencingFrom("//(*.(zip|war|jar)[*])/jcr:content[@jcr:data]")
                              .andOutputtingTo("/zips/$1");
              
              
              

              With this configuration the test "shouldUploadAndSequenceZipFile" fails but with the in-memory repository the test is OK. Moreover, I think that the output path is good to receive the sequenced nodes.

               

              Best regards

              • 4. Re: Zip sequencer is not working with File System source For 2.8.1 and 2.8.2
                rhauch

                Can you share the exception that caused the failure?

                • 5. Re: Zip sequencer is not working with File System source For 2.8.1 and 2.8.2
                  emiste

                  Is the one in my first message of this discussion :

                   

                  org.modeshape.graph.connector.RepositorySourceException: Primary type "store" for path "nt:unstructured" in wo .............

                   

                   

                  BTW  I'm working on a project that needs sequencing zip files and to not be stuck with this issue I switched to Disk connector and It's work fine in the JSE environment but in a JEE container I'm facing difficulties in JEE container ( my test are done using Arquillian and Glassfish Embedded )  the sequencer not seem working after loading the zip file . Have your some recommendations about using sequencers in a container ?

                   

                  Thank you for your help

                  • 6. Re: Zip sequencer is not working with File System source For 2.8.1 and 2.8.2
                    rhauch

                    Because the FileSystem connector uses files and directories on the back-end to store the content, it can only store nodes of type "nt:file", "nt:folder", and "nt:resource", and it cannot store a node of type "nt:unstructured". The FileSystem connector is not a general purpose store for any kind of content. The DiskConnector, Infinispan, and JPA connectors can store any content.

                     

                    I just looked again at the ZIP sequencer, and it only creates "nt:file", "nt:folder" and "nt:resource" nodes. But perhaps after the ZIP sequencer extracts the files (as "nt:file" and "nt:resource" nodes), other sequencers are kicked off that attempt to create other kinds of nodes from the files that were extracted from the ZIP file.

                     

                    As for using the DiskConnector in Glassfish, there shouldn't be anything different about the two environments. There's nothing special about the DiskConnector, and it doesn't use any 3rd party libraries. Is the JRE version the same in both environments?

                    • 7. Re: Zip sequencer is not working with File System source For 2.8.1 and 2.8.2
                      emiste

                      Regarding the FileSystem connector I think there is a bug while  loaded zip is sequenced because  the exception  is thrown during the StreamSequencer processing . I'm new with modeshape so my question is what's the role of this sequencer and when it's fired.

                       

                      In the other hand, For my test of loading a zip file using a DiskConnector in an EJB, I did the test in Jboss 7.1.1.Final and I had the same issue as Glassfish embedded. The sequencer is not fired during the execution of a post construct method. I created a simple project (attached to the discussion)  that presents what I want to do and also to help everyone to reproduce the issue on their side and to help me to find the good solution to do a loading in an EJB.

                      In the attached project I used an absolute path to the resources ( sequencing.cnd and test.zip ) because I couldn't get the path using getResource () method and even after some transformations to have at the end a valide path I got a modeshape exception  like the folowing one  ( the path I got using getClass().getClassLoader().getResource("/sequencing.cnd") instruction is bad , the name of the repository is part of the returned path )

                      :

                       


                      Caused by: org.modeshape.repository.ModeShapeConfigurationException: Unable to find or read the file "C:\jboss-as-7.1.1.Final\bin\content\testEJB-2.8.2.Final.war\WEB-INF\classes\sequencing.cnd"
                                at org.modeshape.jcr.JcrConfiguration$RepositoryBuilder.addNodeTypes(JcrConfiguration.java:756)
                                at org.modeshape.jcr.JcrConfiguration$RepositoryBuilder.addNodeTypes(JcrConfiguration.java:693)
                                at modespahe.test.EjbTest.initialize(EjbTest.java:65)
                                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.6.0_27]
                                at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) [rt.jar:1.6.0_27]
                                at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) [rt.jar:1.6.0_27]
                                at java.lang.reflect.Method.invoke(Unknown Source) [rt.jar:1.6.0_27]
                                at org.jboss.as.ee.component.ManagedReferenceLifecycleMethodInterceptorFactory$ManagedReferenceLifecycleMethodInterceptor.processInvocation(ManagedReferenceLifecycleMethodInterceptorFactory.java:130)
                                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
                                at org.jboss.invocation.WeavedInterceptor.processInvocation(WeavedInterceptor.java:53)
                                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
                                at org.jboss.as.ee.component.ManagedReferenceInterceptorFactory$ManagedReferenceInterceptor.processInvocation(ManagedReferenceInterceptorFactory.java:95)
                                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
                                at org.jboss.invocation.WeavedInterceptor.processInvocation(WeavedInterceptor.java:53)
                                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
                                at org.jboss.as.ee.component.NamespaceContextInterceptor.processInvocation(NamespaceContextInterceptor.java:50)
                                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
                                at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:228)
                                ... 18 more
                      
                      
                      

                      I would appreciate any help

                      Best regards