Skip navigation

CQ5

sug1981
Currently Being Moderated

How do I use JNDI to connect to CRX from an external application ?

Jul 30, 2012 5:12 AM

How do I use JNDI to connect to CRX from an external application ?

 
Replies
  • Currently Being Moderated
    Oct 12, 2012 2:08 PM   in reply to Sham HC

    I'm unable to access the Repository object via JNDI with the code from the link above.

     

    I'm running CQ5.5 on JBoss 5.1 and trying to access the Repository object via JNDI from a separate web application (separate WAR file).

     

    When the JcrUtils.getRepository() method is executed it throws the following exception:

     

    javax.jcr.RepositoryException: Unable to access a repository with the following settings:

    org.apache.jackrabbit.repository.uri: jndi://crx?org.apache.jackrabbit.repository.jndi.name=crx&java.naming .factory.initial=com.day.util.jndi.provider.MemoryInitialContextFactor y&java.naming.provider.url=http://jcr.day.com

    The following RepositoryFactory classes were consulted:

    org.apache.jackrabbit.core.RepositoryFactoryImpl: declined

    org.apache.jackrabbit.commons.JndiRepositoryFactory: failed

    because of RepositoryException: Failed to look up crx from JNDI environment {java.naming.provider.url=http://jcr.day.com, java.naming.factory.initial=com.day.util.jndi.provider.MemoryInitialC ontextFactory, org.apache.jackrabbit.repository.uri=jndi://crx}

    because of NameNotFoundException: null

    Perhaps the repository you are trying to access is not available at the moment.

    ...

     

    I tried all the approaches listed in the documentation (e.g. ServiceRegistry.lookupProviders()) without any luck. I noticed that a couple of RepositoryFactory objects are found, but when queried none of them resolves to a Repository object.

     

    Any ideas on how to make it work ?

     

    PS: I had tried this exact same scenario with CQ5.4 and used to work just fine, so I'm guessing it's a CQ5.5 issue.

     
    |
    Mark as:
  • Currently Being Moderated
    Oct 14, 2012 1:31 AM   in reply to Daniel Valencia Backhoff

    At least with CQ 5.5 GA version it is a known issue, that Remoting via RMI is not working. Might have changed with SP1 or SP2 (haven't checked the release notes regarding this aspect).

     

    Nevertheless, Remoting via WebDAV (davex) is working properly, and AFAIK its performance has been improved, so it's supposed to be faster than Remoting via RM.

     

    See http://dev.day.com/docs/en/crx/current/developing/accessing_the_crx.ht ml#Accessing%20a%20Repository%20via%20JCR%20Remoting%20based%20on%20We bDAV for docs.

     

    Jörg

     
    |
    Mark as:
  • Currently Being Moderated
    Nov 15, 2012 2:33 PM   in reply to Jörg Hoh

    I'm having the same problem Daniel was having. This problem happens when connecting via JNDI only. Might be the reason why the "crx" name cannot be resolved because it is not defined. I remember, for CQ 5.4 the JNDI name was declared in the web.xml as follows:

     

    <servlet>

    <servlet-name>JackrabbitRepositoryAccessServlet</servlet-name>

    <servlet-class>org.apache.jackrabbit.j2ee.RepositoryAccessServlet</se rvlet-class>

    <init-param>

    <param-name>repository-name</param-name>

    <param-value>crx</param-value>

    </init-param>

    <init-param>

    <param-name>java.naming.provider.url</param-name>

    <param-value>http://jcr.day.com</param-value>

    </init-param>

    <init-param>

    <param-name>java.naming.factory.initial</param-name>

    <param-value>com.day.util.jndi.provider.MemoryInitialContextFactory</ param-value>

    </init-param>

    <load-on-startup>10</load-on-startup>

    </servlet>

     
    |
    Mark as:
  • Currently Being Moderated
    May 9, 2013 4:12 PM   in reply to Jörg Hoh

    The  documentation on accessing crx remotely(http://dev.day.com/docs/en/crx/current/developing/accessing_the_crx.ht ml#Accessing%20via%20the%20CRX%20web%20application) suggests that we could use either rmi or webdav. Since 5.5 no longer supports rmi,  the only option left is webdav. I followed the documentation and when i tried the below code from the client it threw an exception. The documentation mentions that the libraries needed are available under this folder crx-quickstart/opt/examples/davex-client/lib. But i was not able to locate this folder in my installation. Is there a way to get these libraries that are needed for web dav to work? Any help in this regard would be greatly appreciated.

    // WebDAV remoting access to a CRX server

    JcrUtils.getRepository("http://localhost:7402/crx/server");

     

    Thanks

     
    |
    Mark as:
  • Currently Being Moderated
    May 10, 2013 5:39 AM   in reply to BGPW

    I got it working by including the standalone jar.

     

    Thanks,

    BGPW

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points