Hi Brian,

If I were you, I would try to avoid using a Repository provided via JNDI
unless you are expecting reuse the same configuration in multiple webapps
in your container.

I would recommend that you first get the JCR remoting client working in a
simple standalone java application, and then once that is working you can
move the code and all the jars that were required for that into your war
file.

For a standalone JCR remoting java application, I believe the minimum
dependencies (for a maven project) would be something like this:

    <!-- JCR API -->
    <dependency>
      <groupId>javax.jcr</groupId>
      <artifactId>jcr</artifactId>
      <version>2.0</version>
    </dependency>
    <!-- All the Jackrabbit libraries needed for DavEx, plus JcrUtils -->
    <dependency>
      <groupId>org.apache.jackrabbit</groupId>
      <artifactId>jackrabbit-jcr2dav</artifactId>
      <version>2.20.3</version>
    </dependency>


And then from java code you can connect to the remote server with client
code that looks something like this:

import javax.jcr.Node;
import javax.jcr.Repository;
import javax.jcr.RepositoryException;
import javax.jcr.Session;
import javax.jcr.SimpleCredentials;

import org.apache.jackrabbit.commons.JcrUtils;

public class TestJcrRemoting {

    public static void main(String[] args) {
        Session jcrSession = null;
        try {
            Repository repo = JcrUtils.getRepository("
http://localhost:8080/server";);

            jcrSession = repo.login(new SimpleCredentials("your_username",
"your_password".toCharArray()));

            Node rootNode = jcrSession.getRootNode();
            System.out.println("root node is: " + rootNode);
        } catch (RepositoryException e) {
            e.printStackTrace();
        } finally {
            if (jcrSession != null) {
                jcrSession.logout();
            }
        }
    }
}

I created a simple test project locally to verify the JCR remoting over
davex worked as I remembered, and with the minimal test project, the "mvn
dependency:tree" output for that client project reported the following set
of required jar files that gets you an idea of what you would have to
include in your war file:

[INFO] sample:jcr-remoting-test:jar:0.0.1-SNAPSHOT
[INFO] +- javax.jcr:jcr:jar:2.0:compile
[INFO] \- org.apache.jackrabbit:jackrabbit-jcr2dav:jar:2.20.3:compile
[INFO]    +- org.apache.jackrabbit:jackrabbit-jcr2spi:jar:2.20.3:compile
[INFO]    |  +- org.apache.jackrabbit:oak-jackrabbit-api:jar:1.40.0:compile
[INFO]    |  +- org.apache.jackrabbit:jackrabbit-spi:jar:2.20.3:compile
[INFO]    |  +-
org.apache.jackrabbit:jackrabbit-spi-commons:jar:2.20.3:compile
[INFO]    |  +-
org.apache.jackrabbit:jackrabbit-jcr-commons:jar:2.20.3:compile
[INFO]    |  +- org.slf4j:slf4j-api:jar:1.7.30:compile
[INFO]    |  +- commons-collections:commons-collections:jar:3.2.2:compile
[INFO]    |  \- commons-io:commons-io:jar:2.8.0:compile
[INFO]    \- org.apache.jackrabbit:jackrabbit-spi2dav:jar:2.20.3:compile
[INFO]       +- org.apache.jackrabbit:jackrabbit-webdav:jar:2.20.3:compile
[INFO]       |  +- org.apache.httpcomponents:httpcore:jar:4.4.14:compile
[INFO]       |  +- org.apache.httpcomponents:httpclient:jar:4.5.13:compile
[INFO]       |  |  +- commons-logging:commons-logging:jar:1.2:compile
[INFO]       |  |  \- commons-codec:commons-codec:jar:1.11:compile
[INFO]       |  \- org.slf4j:jcl-over-slf4j:jar:1.7.30:compile
[INFO]       \- org.apache.httpcomponents:httpmime:jar:4.5.13:compile


Hope that helps get you further..

Regards
-Eric

On Tue, Aug 31, 2021 at 9:24 AM Brian E. Lavender <[email protected]> wrote:

> On Tue, Aug 31, 2021 at 08:04:53AM +0200, Julian Reschke wrote:
> > Am 31.08.2021 um 02:09 schrieb Brian E. Lavender:
> > > I am still attempting to connect my webapp to a remote repository
> > > I still keep getting a null reference. :( And, the log
> > > messages doesn't seem to indicate what I am missing.
> > >
> > > I am thinking that I need to copy the jars into the Tomcat lib folder
> > > for my application to connect to a remote repository based upon the
> > > following. What jars do I need besides the following?
> > >
> > > jackrabbit-jcr-rmi-2.20.3.jar
> > >
> > > https://jackrabbit.apache.org/jcr/repository-server-howto.html
> > >
> > > The instructions state the following.
> > >
> > > Place the JCR-RMI jar file and its dependencies (including the JCR API
> > > jar) under $CATALINA_HOME/webapps/_your app_/WEB-INF/lib.
> > >
> > > Any ideas on this?
> > >
> > > Does someone have a sample project that has a context.xml that connects
> > > to a remote repository?
> >
> > I can't help you with RMI, I have never used it. What I know though is
> > that it hasn't got any attention for many years, and is known not to
> > support certain operations.
> >
> > I would recommend connecting using WebDAV.
>
> How would I do that?
>
> Is there a jndi connection binding or something?
>
> Brian
> --
> Brian Lavender
> http://www.brie.com/brian/
>
> "There are two ways of constructing a software design. One way is to
> make it so simple that there are obviously no deficiencies. And the other
> way is to make it so complicated that there are no obvious deficiencies."
>
> Professor C. A. R. Hoare
> The 1980 Turing award lecture
>

Reply via email to