You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jackrabbit.apache.org by Jacob Bergöö <ja...@gmail.com> on 2009/04/24 15:25:54 UTC

Connecting to different repositories

Hi,
I am working with Spring 2.5.6, spring-modules-jcr 0.8a, jcrom 1.3.2.

In my application I have the need of be able to connect to different
repositories depending on if I am in development, test or production mode.

The way it is setup now I have a repository.xml configuration in my
src/main/resources folder where I setup a local derby repository, but I want
to be able to create a "test" build that will connect to a repository that
is on another machine. Therefor I cant use the way I have configured it now
in spring.

This is my configuration:

 <bean id="jcrom" class="org.jcrom.Jcrom">
        <constructor-arg type="boolean" value="true"/>
        <constructor-arg type="boolean" value="true"/>
        <constructor-arg type="java.util.Set">
            <set>
                <value type="java.lang.Class">org.jcrom.JcrFile</value>
                <value
type="java.lang.Class">com.xxx.domain.composition.urltree.URLNode</value>
                <value
type="java.lang.Class">com.xxx.domain.composition.urltree.URLTree</value>
                <value
type="java.lang.Class">com.xxx.domain.composition.page.ViewPage</value>
                <value
type="java.lang.Class">com.xxx.domain.composition.template.TemplateNode</value>
                <value
type="java.lang.Class">com.xxx.domain.composition.template.ChildArea</value>
            </set>
        </constructor-arg>
    </bean>

    <bean id="jcrSessionFactory"
class="org.springmodules.jcr.JcrSessionFactory">
        <property name="repository" ref="repository"/>
        <property name="credentials">
            <bean class="javax.jcr.SimpleCredentials">
                <constructor-arg index="0" value="user"/>
                <constructor-arg index="1">
                    <bean factory-bean="password"
factory-method="toCharArray"/>
                </constructor-arg>
            </bean>
        </property>
    </bean>

    <bean id="password" class="java.lang.String">
        <constructor-arg index="0" value="password"/>
    </bean>

    <bean id="transactionManager"
class="org.springmodules.jcr.jackrabbit.LocalTransactionManager">
        <property name="sessionFactory" ref="jcrSessionFactory"/>
    </bean>

    <bean id="rmiRegistry"
class="org.springframework.remoting.rmi.RmiRegistryFactoryBean"/>
    <bean id="rmiServer"
class="org.springmodules.jcr.jackrabbit.RmiServerRepositoryFactoryBean">
        <property name="repository" ref="repository"/>
        <property name="remoteAdapterFactory">
            <bean
class="org.apache.jackrabbit.rmi.server.ServerAdapterFactory"/>
        </property>
        <property name="registry" ref="rmiRegistry"/>
        <property name="rmiName" value="jackrabbit"/>
    </bean>

   <bean id="jcrPropertyPlaceholder"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="location"
value="classpath:jcr-persistence-config.properties"/>
    </bean>

    <bean id="repository"
class="org.springmodules.jcr.jackrabbit.RepositoryFactoryBean">
        <property name="configuration"
value="${jcr.repository.config.file}"/>
        <property name="homeDir" value="${jcr.repository.home.dir}"/>
    </bean>

    <!-- DAO classes -->

    <bean id="urlTreeDao" class="com.xxx.persistence.urltree.URLTreeDao">
        <constructor-arg index="0" ref="jcrom"/>
    </bean>



and the property file:

jcr.repository.config.file=classpath:repository.xml
jcr.repository.home.dir=file:./target/trex_jcr_repo

So I am guessing I need to be able to connect to the other machine with some
rmi connection but when I looked on the documentation for spring-modules-jcr
is states:

<!-- rmi client -->
<bean id="rmiClientFactory"
class="org.apache.jackrabbit.rmi.client.ClientRepositoryFactory"/>

<bean id="rmiClient" factory-bean="rmiClientFactory"
factory-method="getRepository" 
                   depends-on="rmiServer">
  <constructor-arg value="rmi://localhost:1099/jackrabbit"/>
</bean>

and that means that depends-on="rmiServer" needs a rmiServer that needs a
repository that needs to read a repository.xml file.... this clearly does
not work... I would have expected that I should be able to create a
repository bean where I provide a URI and username, password...

How have this been solve for you guys?

Thanks in advance,
Jacob


-- 
View this message in context: http://www.nabble.com/Connecting-to-different-repositories-tp23216439p23216439.html
Sent from the Jackrabbit - Users mailing list archive at Nabble.com.


Re: Connecting to different repositories

Posted by Jacob Bergöö <ja...@gmail.com>.
Hi again,
Now, I am building my own factory that, depending on a property, are
connection to either a local repository or a remote repository. The Problem
now is that I get
"org.springframework.transaction.CannotCreateTransactionException: Could not
open JCR session for transaction;" 

My configuration looks like this:


    <bean id="jcrPropertyPlaceholder"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="location"
value="classpath:jcr-persistence-config.properties"/>
    </bean>

    <bean id="devRepository"
class="org.springmodules.jcr.jackrabbit.RepositoryFactoryBean">
        <property name="configuration"
value="${jcr.repository.config.file}"/>
        <property name="homeDir" value="${jcr.repository.home.dir}"/>
    </bean>
	

    <bean id="repository"
class="com.xxxx.persistence.repository.RepositoryResolver">
        <property name="repositoryUrl" value="${rmi.path}"/>
        <property name="buildForDevelopment"
value="${build.For.Development}"/>
    </bean>

    <tx:annotation-driven transaction-manager="transactionManager"/>

    <bean id="jcrSessionFactory"
class="org.springmodules.jcr.JcrSessionFactory">
        <property name="repository" ref="repository"/>

        <property name="credentials">
            <bean class="javax.jcr.SimpleCredentials">
                <constructor-arg index="0" value="username"/>
                <constructor-arg index="1">
                    <bean factory-bean="password"
factory-method="toCharArray"/>
                </constructor-arg>
            </bean>
        </property>
    </bean>

   <bean id="jcrTemplate" class="org.springmodules.jcr.JcrTemplate">
        <property name="sessionFactory" ref="jcrSessionFactory"/>
        <property name="allowCreate" value="true"/>
    </bean>

    <bean id="password" class="java.lang.String">
        <constructor-arg index="0" value="password"/>
    </bean>

    <bean id="transactionManager"
class="org.springmodules.jcr.jackrabbit.LocalTransactionManager">
        <property name="sessionFactory" ref="jcrSessionFactory"/>
    </bean>

    <!-- rmi server -->
    <!-- use Spring's RMI classes to retrieve the RMI registry -->
    <bean id="rmiRegistry"
class="org.springframework.remoting.rmi.RmiRegistryFactoryBean"/>
    <bean id="rmiServer"
class="org.springmodules.jcr.jackrabbit.RmiServerRepositoryFactoryBean">
        <property name="repository" ref="repository"/>
        <property name="remoteAdapterFactory">
            <bean
class="org.apache.jackrabbit.rmi.server.ServerAdapterFactory"/>
        </property>
        <property name="registry" ref="rmiRegistry"/>
        <property name="rmiName" value="jackrabbit"/>
    </bean>



The Java class:

import javax.jcr.Repository;

import org.apache.jackrabbit.rmi.client.ClientRepositoryFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.FactoryBean;
import org.springframework.beans.factory.annotation.Autowired;

public class RepositoryResolver implements FactoryBean {
	
	private static final Logger logger =
LoggerFactory.getLogger(RepositoryResolver.class);
	
	@Autowired
	private Repository devRepository;

	private String repositoryUrl;
	private boolean buildForDevelopment;
	
	private Repository currentRepository;
	
	public RepositoryResolver() {
		super();
	}

	public void setRepositoryUrl(String repositoryUrl) {
		this.repositoryUrl = repositoryUrl;
	}

	public void setBuildForDevelopment(boolean buildForDevelopment) {
		this.buildForDevelopment = buildForDevelopment;
	} 
	
	public Repository createRepository(){
		return null;
	}

	@Override
	public Object getObject() throws Exception {
		if (currentRepository == null) {
			if (buildForDevelopment) {
				currentRepository = devRepository;
			} else {
				ClientRepositoryFactory factory = new ClientRepositoryFactory();
				try {
					currentRepository = factory.getRepository(repositoryUrl);
					logger.info("Connecting to repository = " +
currentRepository.getDescriptor(currentRepository.REP_NAME_DESC));
					//currentRepository = new
org.apache.jackrabbit.rmi.repository.RMIRemoteRepository(repositoryUrl);
				} catch (Exception e) {
					e.printStackTrace();
				} 
			}
		}
		return currentRepository;
	}

	@Override
	public Class getObjectType() {
		if (currentRepository != null) {
			return currentRepository.getClass();
		} else {
			return null;
		}
	}

	@Override
	public boolean isSingleton() {
		return true;
	}
	
}

And finally the property file:

# PROJECT TYPE (DEV or TEST/PRODUCTION
build.For.Development=false

# DEV REPOSITORY SETUP 
jcr.repository.config.file=classpath:jcr-repository-config.xml
jcr.repository.home.dir=file:./target/trex_jcr_repo

# RMI CONNECTION STRING
rmi.path=rmi://[some.ip.number]:[some.port.number]/jackrabbit.repository

the Exception I get is this:

 
WARN  DefaultRemoter - Method execution failed:
org.springframework.transaction.CannotCreateTransactionException: Could not
open JCR session for transaction; nested exc
eption is java.lang.IllegalArgumentException: transactions are not supported
by your Jcr Repository
        at
org.springmodules.jcr.jackrabbit.LocalTransactionManager.doBegin(LocalTransactionManager.java:163)
        at
org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTra
nsactionManager.java:374)
        at
org.springframework.transaction.interceptor.TransactionAspectSupport.createTransactionIfNecessary(Transaction
AspectSupport.java:263)
        at
org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:101)
        at
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
        at
org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
        at $Proxy14.getTemplateTree(Unknown Source)
        at
com.teliasonera.ct.t2.service.impl.T2ServiceImpl.getTemplateTree(T2ServiceImpl.java:55)
        at
com.teliasonera.ct.t2.trex.TrexService.getTemplateTree(TrexService.java:58)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at
org.directwebremoting.impl.ExecuteAjaxFilter.doFilter(ExecuteAjaxFilter.java:34)
        at
org.directwebremoting.impl.DefaultRemoter$1.doFilter(DefaultRemoter.java:428)
        at
org.directwebremoting.impl.DefaultRemoter.execute(DefaultRemoter.java:431)
        at
org.directwebremoting.impl.DefaultRemoter.execute(DefaultRemoter.java:283)
        at
org.directwebremoting.servlet.PlainCallHandler.handle(PlainCallHandler.java:52)
        at
org.directwebremoting.servlet.UrlProcessor.handle(UrlProcessor.java:101)
        at
org.directwebremoting.servlet.DwrServlet.doPost(DwrServlet.java:146)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:713)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:806)
        at
org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:502)
        at
org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:365)
        at
org.mortbay.jetty.security.ConstraintsSecurityHandler.handle(ConstraintsSecurityHandler.java:220)
        at
org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
        at
org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:822)
        at
org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:305)
        at
org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:229)
        at
org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:113)
        at
org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
        at org.mortbay.jetty.Server.handle(Server.java:324)
        at
org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:550)
        at
org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:890)
        at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:743)
        at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:215)
        at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:407)
        at
org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:421)
        at
org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:520)
Caused by: java.lang.IllegalArgumentException: transactions are not
supported by your Jcr Repository
        at
org.springmodules.jcr.jackrabbit.LocalTransactionManager.doBegin(LocalTransactionManager.java:120)
        ... 38 more


Is there no support for transactions over RMI? And in that case, can I use
JNDI or something else? does anyone know how to solve this?

Thanks in advance
Jacob




Alexander Klimetschek wrote:
> 
> On Fri, Apr 24, 2009 at 4:01 PM, Jacob Bergöö <ja...@gmail.com>
> wrote:
>>
>> Thanks for the quick reply,
>> have you heard that this has been done before or does everybody else only
>> work with one repository? How do you switch between different states in
>> your
>> development process (dev, test, prod)?
> 
> I've done it some time ago with Spring as well, but not for different
> stages, but for switching the backend depending on the requesting user
> account of the webapplication. It's not that hard to write custom
> factories in spring and wiring them together. But nowadays I am no
> longer working with Spring ;-)
> 
>> do you have any more code examples on how to do the rmi connection?
> 
> See the page for the jcr-rmi component:
> http://jackrabbit.apache.org/jackrabbit-jcr-rmi.html
> 
> Regards,
> Alex
> 
> -- 
> Alexander Klimetschek
> alexander.klimetschek@day.com
> 
> 

-- 
View this message in context: http://www.nabble.com/Connecting-to-different-repositories-tp23216439p23277490.html
Sent from the Jackrabbit - Users mailing list archive at Nabble.com.


Re: Connecting to different repositories

Posted by Alexander Klimetschek <ak...@day.com>.
On Fri, Apr 24, 2009 at 4:01 PM, Jacob Bergöö <ja...@gmail.com> wrote:
>
> Thanks for the quick reply,
> have you heard that this has been done before or does everybody else only
> work with one repository? How do you switch between different states in your
> development process (dev, test, prod)?

I've done it some time ago with Spring as well, but not for different
stages, but for switching the backend depending on the requesting user
account of the webapplication. It's not that hard to write custom
factories in spring and wiring them together. But nowadays I am no
longer working with Spring ;-)

> do you have any more code examples on how to do the rmi connection?

See the page for the jcr-rmi component:
http://jackrabbit.apache.org/jackrabbit-jcr-rmi.html

Regards,
Alex

-- 
Alexander Klimetschek
alexander.klimetschek@day.com

Re: Connecting to different repositories

Posted by Jacob Bergöö <ja...@gmail.com>.
Thanks for the quick reply,
have you heard that this has been done before or does everybody else only
work with one repository? How do you switch between different states in your
development process (dev, test, prod)?

do you have any more code examples on how to do the rmi connection?


thanks for the help,
Jacob


Alexander Klimetschek wrote:
> 
> On Fri, Apr 24, 2009 at 3:25 PM, Jacob Bergöö <ja...@gmail.com>
> wrote:
>>
>> Hi,
>> I am working with Spring 2.5.6, spring-modules-jcr 0.8a, jcrom 1.3.2.
>>
>> In my application I have the need of be able to connect to different
>> repositories depending on if I am in development, test or production
>> mode.
>>
>> The way it is setup now I have a repository.xml configuration in my
>> src/main/resources folder where I setup a local derby repository, but I
>> want
>> to be able to create a "test" build that will connect to a repository
>> that
>> is on another machine. Therefor I cant use the way I have configured it
>> now
>> in spring.
>>
>> This is my configuration:
>>
>>  <bean id="jcrom" class="org.jcrom.Jcrom">
>>        <constructor-arg type="boolean" value="true"/>
>>        <constructor-arg type="boolean" value="true"/>
>>        <constructor-arg type="java.util.Set">
>>            <set>
>>                <value type="java.lang.Class">org.jcrom.JcrFile</value>
>>                <value
>> type="java.lang.Class">com.xxx.domain.composition.urltree.URLNode</value>
>>                <value
>> type="java.lang.Class">com.xxx.domain.composition.urltree.URLTree</value>
>>                <value
>> type="java.lang.Class">com.xxx.domain.composition.page.ViewPage</value>
>>                <value
>> type="java.lang.Class">com.xxx.domain.composition.template.TemplateNode</value>
>>                <value
>> type="java.lang.Class">com.xxx.domain.composition.template.ChildArea</value>
>>            </set>
>>        </constructor-arg>
>>    </bean>
>>
>>    <bean id="jcrSessionFactory"
>> class="org.springmodules.jcr.JcrSessionFactory">
>>        <property name="repository" ref="repository"/>
>>        <property name="credentials">
>>            <bean class="javax.jcr.SimpleCredentials">
>>                <constructor-arg index="0" value="user"/>
>>                <constructor-arg index="1">
>>                    <bean factory-bean="password"
>> factory-method="toCharArray"/>
>>                </constructor-arg>
>>            </bean>
>>        </property>
>>    </bean>
>>
>>    <bean id="password" class="java.lang.String">
>>        <constructor-arg index="0" value="password"/>
>>    </bean>
>>
>>    <bean id="transactionManager"
>> class="org.springmodules.jcr.jackrabbit.LocalTransactionManager">
>>        <property name="sessionFactory" ref="jcrSessionFactory"/>
>>    </bean>
>>
>>    <bean id="rmiRegistry"
>> class="org.springframework.remoting.rmi.RmiRegistryFactoryBean"/>
>>    <bean id="rmiServer"
>> class="org.springmodules.jcr.jackrabbit.RmiServerRepositoryFactoryBean">
>>        <property name="repository" ref="repository"/>
>>        <property name="remoteAdapterFactory">
>>            <bean
>> class="org.apache.jackrabbit.rmi.server.ServerAdapterFactory"/>
>>        </property>
>>        <property name="registry" ref="rmiRegistry"/>
>>        <property name="rmiName" value="jackrabbit"/>
>>    </bean>
>>
>>   <bean id="jcrPropertyPlaceholder"
>> class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
>>        <property name="location"
>> value="classpath:jcr-persistence-config.properties"/>
>>    </bean>
>>
>>    <bean id="repository"
>> class="org.springmodules.jcr.jackrabbit.RepositoryFactoryBean">
>>        <property name="configuration"
>> value="${jcr.repository.config.file}"/>
>>        <property name="homeDir" value="${jcr.repository.home.dir}"/>
>>    </bean>
>>
>>    <!-- DAO classes -->
>>
>>    <bean id="urlTreeDao" class="com.xxx.persistence.urltree.URLTreeDao">
>>        <constructor-arg index="0" ref="jcrom"/>
>>    </bean>
>>
>>
>>
>> and the property file:
>>
>> jcr.repository.config.file=classpath:repository.xml
>> jcr.repository.home.dir=file:./target/trex_jcr_repo
>>
>> So I am guessing I need to be able to connect to the other machine with
>> some
>> rmi connection but when I looked on the documentation for
>> spring-modules-jcr
>> is states:
>>
>> <!-- rmi client -->
>> <bean id="rmiClientFactory"
>> class="org.apache.jackrabbit.rmi.client.ClientRepositoryFactory"/>
>>
>> <bean id="rmiClient" factory-bean="rmiClientFactory"
>> factory-method="getRepository"
>>                   depends-on="rmiServer">
>>  <constructor-arg value="rmi://localhost:1099/jackrabbit"/>
>> </bean>
>>
>> and that means that depends-on="rmiServer" needs a rmiServer that needs a
>> repository that needs to read a repository.xml file.... this clearly does
>> not work... I would have expected that I should be able to create a
>> repository bean where I provide a URI and username, password...
> 
> In JCR/Jackrabbit, you use a JCR session to log in. In case of an RMI
> connection to the repository, the publicly available interface via RMI
> is javax.jcr.Repository (eg. "rmi://localhost:1099/jackrabbit"). You
> cannot specify credentials here. These are used when doing a
> Repository.login() to get a session.
> 
> You have to change your bean config / factories to allow multiple
> repositories, depending on some parameter or context information,
> which contains the rmi url. AFAIK the standard spring-jcr module isn't
> built for that.
> 
> Regards,
> Alex
> 
> -- 
> Alexander Klimetschek
> alexander.klimetschek@day.com
> 
> 

-- 
View this message in context: http://www.nabble.com/Connecting-to-different-repositories-tp23216439p23217033.html
Sent from the Jackrabbit - Users mailing list archive at Nabble.com.


Re: Connecting to different repositories

Posted by Alexander Klimetschek <ak...@day.com>.
On Fri, Apr 24, 2009 at 3:25 PM, Jacob Bergöö <ja...@gmail.com> wrote:
>
> Hi,
> I am working with Spring 2.5.6, spring-modules-jcr 0.8a, jcrom 1.3.2.
>
> In my application I have the need of be able to connect to different
> repositories depending on if I am in development, test or production mode.
>
> The way it is setup now I have a repository.xml configuration in my
> src/main/resources folder where I setup a local derby repository, but I want
> to be able to create a "test" build that will connect to a repository that
> is on another machine. Therefor I cant use the way I have configured it now
> in spring.
>
> This is my configuration:
>
>  <bean id="jcrom" class="org.jcrom.Jcrom">
>        <constructor-arg type="boolean" value="true"/>
>        <constructor-arg type="boolean" value="true"/>
>        <constructor-arg type="java.util.Set">
>            <set>
>                <value type="java.lang.Class">org.jcrom.JcrFile</value>
>                <value
> type="java.lang.Class">com.xxx.domain.composition.urltree.URLNode</value>
>                <value
> type="java.lang.Class">com.xxx.domain.composition.urltree.URLTree</value>
>                <value
> type="java.lang.Class">com.xxx.domain.composition.page.ViewPage</value>
>                <value
> type="java.lang.Class">com.xxx.domain.composition.template.TemplateNode</value>
>                <value
> type="java.lang.Class">com.xxx.domain.composition.template.ChildArea</value>
>            </set>
>        </constructor-arg>
>    </bean>
>
>    <bean id="jcrSessionFactory"
> class="org.springmodules.jcr.JcrSessionFactory">
>        <property name="repository" ref="repository"/>
>        <property name="credentials">
>            <bean class="javax.jcr.SimpleCredentials">
>                <constructor-arg index="0" value="user"/>
>                <constructor-arg index="1">
>                    <bean factory-bean="password"
> factory-method="toCharArray"/>
>                </constructor-arg>
>            </bean>
>        </property>
>    </bean>
>
>    <bean id="password" class="java.lang.String">
>        <constructor-arg index="0" value="password"/>
>    </bean>
>
>    <bean id="transactionManager"
> class="org.springmodules.jcr.jackrabbit.LocalTransactionManager">
>        <property name="sessionFactory" ref="jcrSessionFactory"/>
>    </bean>
>
>    <bean id="rmiRegistry"
> class="org.springframework.remoting.rmi.RmiRegistryFactoryBean"/>
>    <bean id="rmiServer"
> class="org.springmodules.jcr.jackrabbit.RmiServerRepositoryFactoryBean">
>        <property name="repository" ref="repository"/>
>        <property name="remoteAdapterFactory">
>            <bean
> class="org.apache.jackrabbit.rmi.server.ServerAdapterFactory"/>
>        </property>
>        <property name="registry" ref="rmiRegistry"/>
>        <property name="rmiName" value="jackrabbit"/>
>    </bean>
>
>   <bean id="jcrPropertyPlaceholder"
> class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
>        <property name="location"
> value="classpath:jcr-persistence-config.properties"/>
>    </bean>
>
>    <bean id="repository"
> class="org.springmodules.jcr.jackrabbit.RepositoryFactoryBean">
>        <property name="configuration"
> value="${jcr.repository.config.file}"/>
>        <property name="homeDir" value="${jcr.repository.home.dir}"/>
>    </bean>
>
>    <!-- DAO classes -->
>
>    <bean id="urlTreeDao" class="com.xxx.persistence.urltree.URLTreeDao">
>        <constructor-arg index="0" ref="jcrom"/>
>    </bean>
>
>
>
> and the property file:
>
> jcr.repository.config.file=classpath:repository.xml
> jcr.repository.home.dir=file:./target/trex_jcr_repo
>
> So I am guessing I need to be able to connect to the other machine with some
> rmi connection but when I looked on the documentation for spring-modules-jcr
> is states:
>
> <!-- rmi client -->
> <bean id="rmiClientFactory"
> class="org.apache.jackrabbit.rmi.client.ClientRepositoryFactory"/>
>
> <bean id="rmiClient" factory-bean="rmiClientFactory"
> factory-method="getRepository"
>                   depends-on="rmiServer">
>  <constructor-arg value="rmi://localhost:1099/jackrabbit"/>
> </bean>
>
> and that means that depends-on="rmiServer" needs a rmiServer that needs a
> repository that needs to read a repository.xml file.... this clearly does
> not work... I would have expected that I should be able to create a
> repository bean where I provide a URI and username, password...

In JCR/Jackrabbit, you use a JCR session to log in. In case of an RMI
connection to the repository, the publicly available interface via RMI
is javax.jcr.Repository (eg. "rmi://localhost:1099/jackrabbit"). You
cannot specify credentials here. These are used when doing a
Repository.login() to get a session.

You have to change your bean config / factories to allow multiple
repositories, depending on some parameter or context information,
which contains the rmi url. AFAIK the standard spring-jcr module isn't
built for that.

Regards,
Alex

-- 
Alexander Klimetschek
alexander.klimetschek@day.com