5 Replies Latest reply on Jul 3, 2011 11:48 AM by riboriori

    Jpa repository with jboss as 6 final

    riboriori

      Hi all, i'm new to modeshape, and i'm experimenting it with jboss as 6 (i've downloaded the jboss as kit).

      I have a seam 3 application packaged as an ear under jboss 6 as.

      Once i've downloaded modeshape, i've configured it by modifying modeshape-config.xml, located under

      $JBOSS_HOME/server/$PROFILE/deploy/modeshape-services.jar/modeshape-config.xml.

       

      My repository definition:

       

              <mode:repository jcr:name="JPA Repository" mode:source="JPA Store">

                <mode:options jcr:primaryType="mode:options">

                  <mode:option jcr:name="systemSourceName" mode:value="dev@JPA Store"/>

                  <mode:option jcr:name="jaasLoginConfigName" mode:value="modeshape-jcr"/>

                  <mode:option jcr:name="queryExecutionEnabled" mode:value="true"/>

                  <mode:option jcr:name="projectNodeTypes" mode:value="true"/>

                  <mode:option jcr:name="jaasLoginConfigName" mode:value="modeshape"/>

                  <mode:option jcr:name="anonymousUserRoles" mode:value="" />

                  <mode:initialContent mode:workspaces="dev" mode:applyToNewWorkspaces="true" mode:content="modeshape-initial-content.xml"/>

                </mode:options>

              </mode:repository>

       

       

      I dont use a datasource, i use all parameters connection on repository deinition. Follows my source:

       

              <mode:source jcr:name="JPA Store"

                         mode:classname="org.modeshape.connector.store.jpa.JpaSource"

                         mode:description="The database store for our content"

                         mode:defaultWorkspaceName="default"

                         mode:showSql="true"

                         mode:username="MODESHAPE"

                         mode:password="modeshape"

                         mode:dialect="org.hibernate.dialect.Oracle10gDialect"

                         mode:url="jdbc:oracle:thin:@localhost:1521:XE"

                         mode:maximumConnectionsInPool="15"

                         mode:minimumConnectionsInPool="1"  

                         mode:driverClassloaderName="oracle.jdbc.driver.OracleDriver"                            

                         mode:autoGenerateSchema="validate"/>

       

       

      I use oracle XE.

       

      In my seam 3 ear packaged application, in a controller i use following code:

       

              JcrConfiguration config = new JcrConfiguration();

              try {

                  URL url = ModeShapeExample.class.getClassLoader().getResource("JPA_modeshape-config.xml");

                  config.loadFrom(url);

              } catch (SAXException e) {

                  //System.err.println("Failed to read the configuration file" + e.getMessage());

                  e.printStackTrace();

              } catch (IOException e) {

                  //System.err.println("Failed to load the configuration file" + e.getMessage());

                  e.printStackTrace();

              }

              catch(Exception e){

                        e.printStackTrace();

              }

             

       

       

              // Create and start the engine ...

              JcrEngine engine = config.build();

             

              if (engine.getProblems().hasErrors()) {

                  System.err.println("Problems starting the engine.");

                  System.err.println(engine.getProblems());

                  System.exit(-1);

              }

       

              // Start the engine

              engine.start();

       

              Repository repository = null;

              Session session = null;

              try {

                  // Get the repository

                  repository = engine.getRepository("JPA Repository");

              }

              catch(RepositoryException e){

                  e.printStackTRace();

             }

       

       

       

      The problem is in the code line:

       

      repository = engine.getRepository("JPA Repository");

       

      It throws a NPE.

       

      If indeed i use a FileSystem repository all works fine. The problem appears when i get a jpa based repository.

      The schema and database tables i use, are generated by the batch script (for test i use windows) supplied by modeshape team.

       

      Can anyone help me please? i want use modeshape also on database based repositories.

      Best regards.

        • 1. Re: Jpa repository with jboss as 6 final
          rhauch

          Hi all, i'm new to modeshape, and i'm experimenting it with jboss as 6 (i've downloaded the jboss as kit).

          I presume you're using ModeShape 2.5.0.Final?

           

          Your code snippets look great, including the error handling.

          The problem is in the code line:

           

          repository = engine.getRepository("JPA Repository");

           

          It throws a NPE.

           

          If indeed i use a FileSystem repository all works fine. The problem appears when i get a jpa based repository.

          The schema and database tables i use, are generated by the batch script (for test i use windows) supplied by modeshape team.

           

          Can you share the stacktrace for the NPE - or at least the part of it that applies to the ModeShape code?

           

          It's good that you can use a different connector and it works; that probably means there's something amiss with your JPA source configuration. Nothing in your configuration stands out as being wrong, but the NPE will help greatly.

           

          Best regards

          1 of 1 people found this helpful
          • 2. Re: Jpa repository with jboss as 6 final
            riboriori

            Hi Randall, tank you much for quick reply. I reproduce entire project at my home, and recreate the source and repository definition and it works now.

            Probably it was some configuration mistake.

            I opened a repository, obtained a session and from it get the root node for creating some node with subnodes and finally i can see the MODE_SIMPLE_NODE table populated!.

            However i had to put under $JBOSS_HOME/server/$PROFILE/deploy/modeshape-services.jar exploded archive c3p0-0.9.1.2.jar and hibernate3.jar, because on first attempt i had a ClassNotFoundException. Once i've put that jars within modeshape-services.jar all works.

            Next step is to use seam-jcr in order to inject repository and session object via cdi.

            Tank you veru much.

            Best regards.

            • 3. Re: Jpa repository with jboss as 6 final
              rhauch

              I'm glad you got it working. BTW, ModeShape 2.5.0.Final only includes a kit for JBoss AS 5.x. If this is what you're using, have a look at the discussion thread that talks about how to customize the kit for AS 5.x to get it working on AS 6.x.

               

              Meanwhile, we've already created a kit for AS 6.x in our 'master' branch. We plan on issuing a 2.6.0.Beta1 release early next week, and we'll provide both kits on our downloads page. Stay tuned.

              • 4. Re: Jpa repository with jboss as 6 final
                riboriori

                It is strange: only by adding these two jars under $JBOSS_HOME/server/$PROFILE/deploy/modeshape-services.jar i got it working under jboss as 6.

                I will a look for kit as 6.

                Tank you Randall.

                Regards.

                • 5. Re: Jpa repository with jboss as 6 final
                  riboriori

                  I must correct myself: in order to modeshape 2.5 works with jboss as 6 i'm based upn this discussion, confirmed by Shane Bryzak:

                  http://community.jboss.org/message/574112.

                  Regards