11 Replies Latest reply on Sep 13, 2012 3:41 PM by serge.st

    Examples not working (in a few releases) and no examples in Alpha 3

    tony.herstell1

      Downloaded examples for 2.8 (and 2.7) and found the run.cmd contains what appears to be mergelines from some source system.

       

      <<<<<<< HEAD java -Djava.ext.dirs=./lib -cp modeshape-example-sequencers-0.5-SNAPSHOT.jar org.modeshape.example.sequencer.SequencingClient %* ======= java -Dlogback.configurationFile=logback.xml -Djava.ext.dirs=./lib -cp modeshape-example-sequencers-0.5-SNAPSHOT.jar org.modeshape.example.sequencer.SequencingClient %* >>>>>>> 8b3f7f3... Using Logback configuration file.

       

      It also refers to modeshape-example-sequencers-0.5-SNAPSHOT.jar; but it stall ran (even when renamed to the proper jar).

       

      Hacked the file and to get the run.cmd running and ran the sequencers example.

       

      Uploaded file, but then cound not do much else as got a secuirty problem reported (stack trace).

       

       

      Please enter the file to upload: caution.gif Please enter the repository path where the file should be placed [/a/b/caution.g if]: javax.jcr.LoginException: Unable to create session for workspace default in repo sitory content: authentication failed. Check credentials.         at org.modeshape.jcr.JcrRepository.login(JcrRepository.java:1476)         at org.modeshape.example.sequencer.SequencingClient.createSession(Sequen cingClient.java:571)         at org.modeshape.example.sequencer.SequencingClient.uploadFile(Sequencin gClient.java:221)         at org.modeshape.example.sequencer.ConsoleInput$1.run(ConsoleInput.java: 69)         at java.lang.Thread.run(Unknown Source)

       

      Looked through example source code (examples\sequencers\src\main\java\org\modeshape\example\sequencer) and found hardcoded private secuirty for USERNAME (jsmith) and PASSWORD (secret) but these don't seem to be used in any of the example code.

       

      No examples for Alpha3; but it is an Alpha.

       

      ...

       

      Had problems even getting ModeShape running using the "getting started' documentation and that is why I reverted to the examples. I will persever with using the example code for 2.8.

        • 1. Re: Examples not working (in a few releases) and no examples in Alpha 3
          rhauch

          Yikes! The 'run.cmd' and 'run.sh' are both quite messed up.

           

          Try editing the run.cmd file and replacing it all with this:

           

               java -Dlogback.configurationFile=logback.xml -Djava.ext.dirs=./lib -cp modeshape-example-sequencers-2.8.1.Final.jar org.modeshape.example.sequencer.SequencingClient %*

           

          I hope that works. (I don't have windows and can't verify that it's correct.)

           

          I presume you used the examples as-is? I'll try to run them tomorrow and see what's going on.

          • 2. Re: Examples not working (in a few releases) and no examples in Alpha 3
            tony.herstell1

            I got it running with

             

            java -Dlogback.configurationFile=logback.xml -Djava.ext.dirs=./lib -cp modeshape-example-sequencers-2.8.0.Final.jar org.modeshape.example.sequencer.SequencingClient %*

             

            Looks same as yours.

             

            However, still fails with secuirty...

             

            The exmaple code does not seem to use the args.

            • 3. Re: Examples not working (in a few releases) and no examples in Alpha 3
              tony.herstell1

              I believe the documentation (getting started) refers to

               

              ... JSP page

              <%!

              static {

                  // Initialize IDTrust

                  IDTrustConfiguration idtrustConfig = new IDTrustConfiguration();

                  try {

                      idtrustConfig.config("security/jaas.conf.xml");

                  } catch (Exception ex) {

                      throw new IllegalStateException(ex);

                  }

              }

              %>

               

               

              and IDTrustConfiguration, from Picketbox, has been is not there (supercceded) in 3.0.0.Final and the exmaple code is out of date.

              • 4. Re: Examples not working (in a few releases) and no examples in Alpha 3
                tony.herstell1

                This certainly points to picketbox being the newkid on the block and the getting started doc being out of date:

                https://community.jboss.org/wiki/IDTrustSecurityForJavaApplications

                • 5. Re: Examples not working (in a few releases) and no examples in Alpha 3
                  tony.herstell1

                  I have moved to 3Alpha6, on JBoss 7.1.1.Final, and got it working quickly.

                   

                  I have setup Jboss to use 3Alpha6 and it works fine once I figured that the -c standalone-modeshape.xml option will run the standalone-modeshape.xml and thus not the normal one; so all my changes to the default standalone.xml files need to be copied into standalone-modeshape.xml (DOH!).

                   

                  I am working thriough some examples, and optomistically just added the following maven:

                          <dependency>

                              <groupId>org.modeshape</groupId>

                              <artifactId>modeshape-jcr</artifactId>

                              <version>3.0.0.Alpha6</version>

                            </dependency>       

                          <dependency>

                              <groupId>javax.jcr</groupId>

                              <artifactId>jcr</artifactId>

                              <version>2.0</version>

                          </dependency>

                   

                  I also added the maven includes and changed them to 3.0.0.Alpha6.

                  e.g.

                  <dependency>

                    <groupId>org.modeshape</groupId>

                    <artifactId>modeshape-sequencer-ddl</artifactId>

                    <version>3.0.0.Alpha6</version>

                  </dependency>

                  ...

                   

                  Now; I am after putting a file into a repository on the filesystem, and reading it back, and have looked at various examples, for various versions of the project and even JackRabbit.

                   

                  Your work is much appreciated and great to see the progress (including having WebDav back).

                   

                  Another "feature" was that if your server crashed out during runup (happens quite a lot when trying to guess modeshape setup in the server config files), it can take out the dodeploy file by replacing it with .failed for the modeshape files. This requires you to manyually rename the files back to .dodeploy

                   

                  Will there be a small piece on how to run this up under Tomcat as well as this is required...

                  • 6. Re: Examples not working (in a few releases) and no examples in Alpha 3
                    rhauch

                    Tony Herstell wrote:

                     

                    I have moved to 3Alpha6, on JBoss 7.1.1.Final, and got it working quickly.

                     

                    I have setup Jboss to use 3Alpha6 and it works fine once I figured that the -c standalone-modeshape.xml option will run the standalone-modeshape.xml and thus not the normal one; so all my changes to the default standalone.xml files need to be copied into standalone-modeshape.xml (DOH!).

                    Great. BTW, if you've not found our (still incomplete) 3.0 documentation, check out the page that talks about how to install ModeShape into AS7., where we talk about the "standalone-modeshape.xml" file.

                     

                     

                    I am working thriough some examples, and optomistically just added the following maven:

                            <dependency>

                                <groupId>org.modeshape</groupId>

                                <artifactId>modeshape-jcr</artifactId>

                                <version>3.0.0.Alpha6</version>

                              </dependency>       

                            <dependency>

                                <groupId>javax.jcr</groupId>

                                <artifactId>jcr</artifactId>

                                <version>2.0</version>

                            </dependency>

                     

                    I also added the maven includes and changed them to 3.0.0.Alpha6.

                    e.g.

                    <dependency>

                      <groupId>org.modeshape</groupId>

                      <artifactId>modeshape-sequencer-ddl</artifactId>

                      <version>3.0.0.Alpha6</version>

                    </dependency>

                    ...

                     

                    That should work just fine. We also have a Git repository with several 3.0-related examples, and the current code contains the Maven dependencies on Alpha6. See that page for instructions on how to get, build, and run the examples.

                     

                     

                    Now; I am after putting a file into a repository on the filesystem, and reading it back, and have looked at various examples, for various versions of the project and even JackRabbit.

                     

                    Your work is much appreciated and great to see the progress (including having WebDav back).

                     

                    Yes, we're getting close to having all the features finished!

                     

                     

                    Another "feature" was that if your server crashed out during runup (happens quite a lot when trying to guess modeshape setup in the server config files), it can take out the dodeploy file by replacing it with .failed for the modeshape files. This requires you to manyually rename the files back to .dodeploy

                     

                    I agree that you can easily get into a rough state if you don't start AS7 correctly, but I'm not sure how we can make this easier. Perhaps the easiest is to use the AS7 console, which should show that these failed deployment and allow you to re-deploy them. If you have any ideas, please let us know.

                     

                    Will there be a small piece on how to run this up under Tomcat as well as this is required...

                     

                    Yes, we have a mostly-empty page in our documentation right now.

                    • 7. Re: Examples not working (in a few releases) and no examples in Alpha 3
                      tony.herstell1

                      > I agree that you can easily get into a rough state if you don't start AS7 correctly, but I'm not sure how we can make this easier. Perhaps the easiest is to use the AS7 console, which should show that these failed deployment and allow you to re-deploy them. If you have any ideas, please let us know.

                       

                      Humm.. perhaps adding a file in there (.bat/.sh) that you just run to rename the files back to .dodeploy? at least its just one click!

                       

                      Its odd that AS 7 renames all the files to failed; when it was only 1 file (war) that failed to deploy so you might mention that to the AS team as they might have a good reason for doing that.


                      • 8. Re: Examples not working (in a few releases) and no examples in Alpha 3
                        tony.herstell1

                        I also cloned the modeshape-examples and used the sequencer example as template to play with.

                         

                        For a AS 7 install I had to search for /files/apiary-manager-logo-tall.png as opposed to /images/apiary-manager-logo-tall.png... and not sure why.

                         

                         

                                   try {

                                        tools.uploadFile(session, "/files/apiary-manager-logo-tall.png", getFile("apiary-manager-logo-tall.png"));

                         

                                        // Save the session ...

                                        session.save();

                         

                                        Node apng;

                                        try {

                                            apng = findNodeAndWait(session, "/files/apiary-manager-logo-tall.png", 10, TimeUnit.SECONDS);

                                            if (print) {

                                                tools.printSubgraph(apng);

                                            }

                                        }

                                        catch (InterruptedException e) {

                                            // TODO Auto-generated catch block

                                            e.printStackTrace();

                                        }

                         

                        looking in the AS 7 standalone.modeshape.xml I see:

                                            <sequencer name="cnd-sequencer" classname="cnd" path-expression="default:/files(//*.cnd[*])/jcr:content[@jcr:data] => /derived/cnd/$1"/>

                                            <sequencer name="msoffice-sequencer" classname="msoffice" path-expression="/files(//*.(xls|ppt|doc)[*])/jcr:content[@jcr:data] => /derived/msoffice/$1"/>

                                            <sequencer name="xsd-sequencer" classname="xsd" path-expression="/files(//*).xsd[*]/jcr:content[@jcr:data] => /derived/xsd/$1"/>

                                            <sequencer name="wsdl-sequencer" classname="wsdl" path-expression="/files(//)*.wsdl[*]/jcr:content[@jcr:data] => /derived/wsdl/$1"/>

                                            <sequencer name="xml-sequencer" classname="xml" path-expression="/files(//)*.xml[*]/jcr:content[@jcr:data] => /derived/xml/$1"/>

                                            <sequencer name="zip-sequencer" classname="zip" path-expression="/files(//*.zip[*])/jcr:content[@jcr:data] => /derived/zip/$1"/>

                                            <sequencer name="image-sequencer" classname="image" path-expression="/files(//*.(png|jpg|gif)[*])/jcr:content[@jcr:data] => /derived/image/$1"/>

                                            <sequencer name="mp3-sequencer" classname="mp3" path-expression="/files(//*.mp3[*])/jcr:content[@jcr:data] => /derived/mp3/$1"/>

                         

                        I was alittle confused as the sequencers above those lines have "proper" class names like org.modeshape.sequencer.classfile.ClassFileSequencer

                         

                        I wonder if this is connected to my issue above.

                         

                        I am still looking forward to an example that shows how to back onto a file system so you can go look at the filesystem files.

                         

                        I also found that when I did unzip into AS7 and then ran through all the commands in the "install in AS 7" tutorial they all said it was already done; perhaps I misunderstood as it may have been Unzip OR run all those commands from CLI. Also the examples that go with the AS7 simpel install now seem different from the modeshap-examples :/

                         

                        Great Progress though....

                        • 9. Re: Examples not working (in a few releases) and no examples in Alpha 3
                          tony.herstell1

                          I also forgot; I get this in JBoss (Note: pokeAbout is called when a timer fires, for a quick hack to my "learning" stuff on timers, but will actually be coding fully to upload a document unsing pimefaces at weekend)):

                           

                              @Timeout

                              public void programmaticTimeout(Timer timer) {

                                  this.logger.info("Programmatic timeout occurred [" + timer.getInfo() + "].");

                                  repositoryController.pokeAbout();

                                  timer.cancel();

                                  // this.emailService.sendWelcomeEmail("Tony", "tony.herstell@gmail.com",

                                  // "Test email from Jboss7 and J6EE using Timer to fire.");

                              }

                           

                           

                          10:38:51,262 WARN  [com.arjuna.ats.jta] (EJB default - 1) ARJUNA016029: SynchronizationImple.afterCompletion - failed for org.modeshape.jcr.txn.SynchronizedTransactions$SynchronizedTransaction$1@3888315a with exception: org.hibernate.search.SearchException: Wrong configuration of default similarity: class org.apache.lucene.search.DefaultSimilarity is not a subtype of org.apache.lucene.search.Similarity

                                    at org.hibernate.search.util.impl.ClassLoaderHelper.instanceFromClass(ClassLoaderHelper.java:156) [hibernate-search-engine-4.1.1.Final.jar:4.1.1.Final]

                                    at org.hibernate.search.util.impl.ClassLoaderHelper.instanceFromName(ClassLoaderHelper.java:111) [hibernate-search-engine-4.1.1.Final.jar:4.1.1.Final]

                          ...

                          10:38:51,280 WARN  [com.arjuna.ats.arjuna] (EJB default - 1) ARJUNA012127: TwoPhaseCoordinator.afterCompletion - returned failure for SynchronizationImple< 0:ffff0a46d728:-399d1eef:4ffe0067:11, org.modeshape.jcr.txn.SynchronizedTransactions$SynchronizedTransaction$1@3888315a >

                          10:38:51,282 WARN  [com.arjuna.ats.jta] (EJB default - 1) ARJUNA016029: SynchronizationImple.afterCompletion - failed for org.modeshape.jcr.txn.SynchronizedTransactions$SynchronizedTransaction$1@61b4bef1 with exception: org.hibernate.search.SearchException: Wrong configuration of default similarity: class org.apache.lucene.search.DefaultSimilarity is not a subtype of org.apache.lucene.search.Similarity

                                    at org.hibernate.search.util.impl.ClassLoaderHelper.instanceFromClass(ClassLoaderHelper.java:156) [hibernate-search-engine-4.1.1.Final.jar:4.1.1.Final]

                                    at org.hibernate.search.util.impl.ClassLoaderHelper.instanceFromName(ClassLoaderHelper.java:111) [hibernate-search-engine-4.1.1.Final.jar:4.1.1.Final]

                          ...

                          10:38:51,297 WARN  [com.arjuna.ats.arjuna] (EJB default - 1) ARJUNA012127: TwoPhaseCoordinator.afterCompletion - returned failure for SynchronizationImple< 0:ffff0a46d728:-399d1eef:4ffe0067:10, org.modeshape.jcr.txn.SynchronizedTransactions$SynchronizedTransaction$1@61b4bef1 >

                          10:38:51,299 WARN  [com.arjuna.ats.jta] (EJB default - 1) ARJUNA016029: SynchronizationImple.afterCompletion - failed for org.modeshape.jcr.txn.SynchronizedTransactions$SynchronizedTransaction$1@387e4993 with exception: org.hibernate.search.SearchException: Wrong configuration of default similarity: class org.apache.lucene.search.DefaultSimilarity is not a subtype of org.apache.lucene.search.Similarity

                                    at org.hibernate.search.util.impl.ClassLoaderHelper.instanceFromClass(ClassLoaderHelper.java:156) [hibernate-search-engine-4.1.1.Final.jar:4.1.1.Final]

                                    at org.hibernate.search.util.impl.ClassLoaderHelper.instanceFromName(ClassLoaderHelper.java:111) [hibernate-search-engine-4.1.1.Final.jar:4.1.1.Final]

                                    at org.hibernate.search.impl.ConfigContext.initSimilarity(ConfigContext.java:204) [hibernate-search-engine-4.1.1.Final.jar:4.1.1.Final]

                          ...

                          10:38:51,314 WARN  [com.arjuna.ats.arjuna] (EJB default - 1) ARJUNA012127: TwoPhaseCoordinator.afterCompletion - returned failure for SynchronizationImple< 0:ffff0a46d728:-399d1eef:4ffe0067:f, org.modeshape.jcr.txn.SynchronizedTransactions$SynchronizedTransaction$1@387e4993 >

                           

                           

                          ...

                          // Leverage EJB to get Transactional Support

                          @Singleton

                          public class RepositoryController {

                           

                           

                              private Logger logger = Logger.getLogger(RepositoryController.class.getName());

                           

                           

                              private static boolean print = true;

                           

                           

                              /*-

                               * Use JNDI to look up a repository (As shown here)

                               * OR

                               *  look up the javax.jcr.RepositoryFactory implementations, and use them to ask for a repository given a set of parameters;

                               *      the first factory to understand the parameters will return a Repository instance

                               * Map<String,String> parameters = ...

                               * Repository repository = null;

                               *  for (RepositoryFactory factory : ServiceLoader.load(RepositoryFactory.class)) {

                               *      repository = factory.getRepository(parameters);

                               *      if (repository != null) break;

                               *  }

                               */

                              @Resource(mappedName = "java:/jcr/sample")

                              private javax.jcr.Repository repository;

                           

                           

                              public void pokeAbout() {

                                  logger.info("> pokeAbout");

                           

                           

                                  JcrTools tools = new JcrTools();

                                  Session session = null;

                                  try {

                           

                           

                                      // This gets a session for using the "default" workspace.

                                      session = repository.login("default");

                                      logger.info("session: " + session + " obtained for repository "

                                              + repository.getDescriptor(repository.REP_NAME_DESC));

                           

                           

                                      Node rootNode = session.getRootNode();

                                      logger.info("[root] Identifier:" + rootNode.getIdentifier());

                                      logger.info("[root] Path:" + rootNode.getPath());

                           

                           

                                      // Cleanup

                                      Node oldFilesNode = null;

                                      NodeIterator nodeIterator = rootNode.getNodes("*files*");

                                      while (nodeIterator.hasNext()) {

                                          oldFilesNode = nodeIterator.nextNode();

                                          logger.info("Removing [files*] node:" + oldFilesNode.getPath());

                                          oldFilesNode.remove();

                                      }

                           

                           

                                      // Find or create file

                                      try {

                                          logger.info("uploading file apiary-manager-logo-tall.png into files node [/files] (i.e. to [/files/logo.png])");

                                          tools.uploadFile(session, "/files/logo.png", getFile("apiary-manager-logo-tall.png"));

                           

                           

                                          // Save the session ...

                                          session.save();

                                      }

                                      catch (IOException e) {

                                          // TODO Auto-generated catch block

                                          e.printStackTrace();

                                      }

                           

                           

                                      // Find file

                                      Node apng;

                                      try {

                                          logger.info("finding apiary-manager-logo-tall.png in [files/logo.png] node:");

                                          apng = findNodeAndWait(session, "/files/logo.png", 10, TimeUnit.SECONDS);

                                          if (print) {

                                              tools.printSubgraph(apng);

                                          }

                                          // tools.printSubgraph(rootNode);

                                      }

                                      catch (InterruptedException e) {

                                          // TODO Auto-generated catch block

                                          e.printStackTrace();

                                      }

                           

                           

                                  }

                                  catch (LoginException le) {

                                      le.printStackTrace();

                                      logger.severe(le.getMessage());

                                  }

                                  catch (RepositoryException re) {

                                      re.printStackTrace();

                                      logger.severe(re.getMessage());

                                  }

                           

                           

                                  /*

                                   * Finally logout.

                                   */

                                  if (session != null) {

                                      session.logout();

                                  }

                           

                           

                                  logger.info("< pokeAbout");

                              }

                           

                           

                              public static InputStream getFile(String path) {

                                  // First try to read from the file system ...

                                  File file = new File(path);

                                  if (file.exists() && file.canRead()) {

                                      try {

                                          return new FileInputStream(file);

                                      }

                                      catch (FileNotFoundException e) {

                                          // continue

                                      }

                                  }

                                  // If not found, try to read from the classpath ...

                                  return RepositoryController.class.getClassLoader().getResourceAsStream(path);

                              }

                           

                           

                              public static Node findNodeAndWait(Session session, String path, long maxWaitTime, TimeUnit unit)

                                      throws RepositoryException, InterruptedException {

                                  long start = System.currentTimeMillis();

                                  long maxWaitInMillis = TimeUnit.MILLISECONDS.convert(maxWaitTime, unit);

                           

                           

                                  do {

                                      try {

                                          // This method either returns a non-null Node reference, or

                                          // throws an exception ...

                                          return session.getNode(path);

                                      }

                                      catch (PathNotFoundException e) {

                                          // The node wasn't there yet, so try again ...

                                      }

                                      Thread.sleep(10L);

                                  }

                                  while ((System.currentTimeMillis() - start) <= maxWaitInMillis);

                                  throw new PathNotFoundException("Failed to find node '" + path + "' even after waiting " + maxWaitTime + " "

                                          + unit);

                              }

                           

                           

                          }

                           

                          Message was edited by: Tony Herstell

                          • 10. Re: Examples not working (in a few releases) and no examples in Alpha 3
                            tony.herstell1

                            On another note:

                            >> Configure your webdav server to use Digest Authentication. Windows 7 WILL NOT connect to webdav servers using Basic Authentication.

                             

                            It seems W7 will not connect unless we use Digest Authentication.

                             

                            Therefore, when I try to map a network drive on W7 it fails to connect and assume this is the reason.

                            • 11. Re: Examples not working (in a few releases) and no examples in Alpha 3
                              serge.st

                              edit the method createSession() of SequencingClient.java to use AnonymousCredentials:

                               

                                  protected Session createSession() throws RepositoryException {

                               

                                      Credentials credentials = new AnonymousCredentials();

                               

                                      return this.repository.login(credentials, workspaceName);

                               

                                  }

                               

                               

                              then execute mvn clean install again.