1 Reply Latest reply on Mar 29, 2013 8:42 PM by Marc Gagnon

    Accessing resource adapter archive ( RAR ) services from a web archive.

    Peter Fry Newbie

      I am working with JBoss AS 7.1 Final

       

      I have a resource adapter archive (in fact it is the Jackrabbit RAR file with some JBoss 7 tweaks).

       

      the structure of this rar file is:

       

      /META-INF/MANIFEST.MF

      /jackrabbit-jcr-commons-2.4.0.jar

      plus lots of other jar files in the root directory

       

      In the jackrabbit-jcr-commons-2.4.0.jar file there is a

       

      /META-INF/services/javax.jcr.RepositoryFactory

       

      I then have a WAR file (in fact the JCR bridge war file from the chemistry project).

       

      When I deploy it beside the RAR file (after adding

       

      Dependencies: javax.jcr,deployment.jackrabbit-jca-2.4.0.rar export services

       

      in the META-INF/MANIFEST.MF of the WAR file I get

       

       

      Exception sending context initialized event to listener instance of class org.apache.chemistry.opencmis.server.impl.CmisRepositoryContextListener: org.apache.chemistry.opencmis.commons.exceptions.CmisConnectionException: No JCR repository factory for configured parameters

      at org.apache.chemistry.opencmis.jcr.JcrServiceFactory.acquireJcrRepository(JcrServiceFactory.java:119) [chemistry-opencmis-server-jcr-0.6.0.jar:0.6.0]

      at org.apache.chemistry.opencmis.jcr.JcrServiceFactory.init(JcrServiceFactory.java:72) [chemistry-opencmis-server-jcr-0.6.0.jar:0.6.0]

      at org.apache.chemistry.opencmis.server.impl.CmisRepositoryContextListener.createServiceFactory(CmisRepositoryContextListener.java:126) [chemistry-opencmis-server-bindings-0.6.0.jar:0.6.0]

      at org.apache.chemistry.opencmis.server.impl.CmisRepositoryContextListener.contextInitialized(CmisRepositoryContextListener.java:56) [chemistry-opencmis-server-bindings-0.6.0.jar:0.6.0]

      at org.apache.catalina.core.StandardContext.contextListenerStart(StandardContext.java:3392) [jbossweb-7.0.10.Final.jar:]

      at org.apache.catalina.core.StandardContext.start(StandardContext.java:3850) [jbossweb-7.0.10.Final.jar:]

      at org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:90) [jboss-as-web-7.1.0.Final.jar:7.1.0.Final]

      at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811)

      at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746)

      at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [rt.jar:1.6.0_13]

      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [rt.jar:1.6.0_13]

      at java.lang.Thread.run(Thread.java:619) [rt.jar:1.6.0_13]

       

      This is an exception from a jar file in the WAR file. The pertinent code from the Apache Chemistry class is

       

          /**

           * Acquire the JCR repository given a configuration. This implementation used

           * {@link javax.imageio.spi.ServiceRegistry#lookupProviders(Class)} for

           * locating <code>RepositoryFactory</code> instances. The first instance

           * which can handle the <code>jcrConfig</code> parameters is used to

           * acquire the repository.

           *

           * @param jcrConfig  configuration determining the JCR repository to be returned

           * @return

           * @throws RepositoryException

           */

          protected Repository acquireJcrRepository(Map<String, String> jcrConfig) {

              try {

                  Iterator<RepositoryFactory> factories = ServiceRegistry.lookupProviders(RepositoryFactory.class);

                  while (factories.hasNext()) {

                      RepositoryFactory factory = factories.next();

                      log.debug("Trying to acquire JCR repository from factory " + factory);

                      Repository repository = factory.getRepository(jcrConfig);

                      if (repository != null) {

                          log.debug("Successfully acquired JCR repository from factory " + factory);

                          return repository;

                      }

                      else {

                          log.debug("Could not acquire JCR repository from factory " + factory);

                      }

                  }

                  throw new CmisConnectionException("No JCR repository factory for configured parameters");

              }

              catch (RepositoryException e) {

                  log.debug(e.getMessage(), e);

                  throw new CmisConnectionException(e.getMessage(), e);

              }

          }

       

      So even though I created a dependency from the WAR file deployment to the RAR file deployment unit and added services it still can't find the service via the javax.imageio.spi.ServiceRegistry.lookupProviders(...) mechanism.

       

      Is WAR file to RAR file dependency supported?

       

      Peter.

        • 1. Re: Accessing resource adapter archive ( RAR ) services from a web archive.
          Marc Gagnon Newbie

          Yes, this is supported, here is the chemistry-opencmis-server-jcr pom.xml modified:

          ...

                      <plugin>

                          <groupId>org.apache.maven.plugins</groupId>

                          <artifactId>maven-war-plugin</artifactId>

                          <configuration>

                              <archive>

                                  <!--

                                      OSGi Bundle Support

                                  -->

                                  <manifestEntries>

                                      <Bundle-Name>org.apache.chemistry.opencmis.server.jcr</Bundle-Name>

                                      <Bundle-SymbolicName>org.apache.chemistry.opencmis.server.jcr</Bundle-SymbolicName>

                                      <Bundle-Version>${project.version}</Bundle-Version>

                                      <Import-Package>javax.servlet,javax.servlet.http,javax.servlet.resources</Import-Package>

                                      <Bundle-Classpath>.</Bundle-Classpath>

                                      <Web-ContextPath>cmis-jcr</Web-ContextPath>

                                      <Dependencies>javax.jcr,deployment.jackrabbit-jca-2.6.0.rar export services</Dependencies>

                                  </manifestEntries>

                              </archive>

          ...

          Also, chemistry-opencmis-server-jcr looks for a JNDI name at runtime.

          This sample repository.properties must be modified accordingly:

          First, make sure the jackrabbit rar is successfully deployed and identify the JNDI name, here is my output:

          ...

          JBAS010406: Registered connection factory java:/jca/DocumentStore

          ...

           

          Now, update the repository.properties like this:

          ...

          class=org.apache.chemistry.opencmis.jcr.JcrServiceFactory

           

           

          mount-path=/

           

           

          # Properties prefixed by 'jcr.' are passed to the repository factory verbatim

          # after removing the 'jcr.' prefix.

          #jcr.org.apache.jackrabbit.repository.uri=file:///{user.home}/jcr-repository

          jcr.org.apache.jackrabbit.repository.jndi.name=java:/jca/DocumentStore

           

          If there is no other configuration issue, you should be able to connect to the repository (try with the open CMIS workbench).