1
votes

I am trying to access a jackrabbit repository through rmi from karaf container

I developped a camel route which save a file into jackrabbit repository

<bean id="repository"
    class="org.apache.jackrabbit.rmi.repository.URLRemoteRepository">
    <argument value="http://localhost:8020/rmi" />
</bean>


<camelContext id="blueprintContext" trace="false"
    xmlns="http://camel.apache.org/schema/blueprint">
    <route id="depotfichiersurjcr">


        <from uri="file:/C:/data?recursive=false&amp;noop=true" />
        <!-- log message="message1 ${body}"/ -->
        <setHeader headerName="CamelJcrNodeName">
            <constant>node</constant>
        </setHeader>
        <setHeader headerName="my.contents.property">
            <simple>${bodyAs(String)}</simple>
            <!-- constant>content</constant -->
        </setHeader>
        <setBody>
            <constant></constant>
        </setBody>
        <to  uri="jcr://admin:admin@repository/default?deep=true&eventTypes=3&noLocal=false" />
        <to uri="direct:a" />
    </route>

</camelContext>

the route works fine with mvn camel:run

the same route doesnt work inside the karaf container , i got :


javax.jcr.RepositoryException: Remote repository not found: The resource at http://localhost:8020/rmi could not be retrieved at org.apache.jackrabbit.rmi.repository.URLRemoteRepositoryFactory.getRemoteRepository(URLRemoteRepositoryFactory.java:84)[1626:org.apache.jackrabbit.jackrabbit-jcr-rmi:2.6.2] at org.apache.jackrabbit.rmi.repository.AbstractRemoteRepositoryFactory.getRepository(AbstractRemoteRepositoryFactory.java:57)[1626:org.apache.jackrabbit.jackrabbit-jcr-rmi:2.6.2] at org.apache.jackrabbit.rmi.repository.ProxyRepository.login(ProxyRepository.java:199)[1626:org.apache.jackrabbit.jackrabbit-jcr-rmi:2.6.2] at org.apache.jackrabbit.rmi.repository.ProxyRepository.login(ProxyRepository.java:233)[1626:org.apache.jackrabbit.jackrabbit-jcr-rmi:2.6.2] at com.sagemcom.Content.process(Content.java:21)[1618:content:0.0.1.SNAPSHOT] at org.apache.camel.processor.DelegateSyncProcessor.process(DelegateSyncProcessor.java:63)[171:org.apache.camel.camel-core:2.13.2] at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:72)[171:org.apache.camel.camel-core:2.13.2] at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:398)[171:org.apache.camel.camel-core:2.13.2] at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:191)[171:org.apache.camel.camel-core:2.13.2] at org.apache.camel.processor.Pipeline.process(Pipeline.java:118)[171:org.apache.camel.camel-core:2.13.2] at org.apache.camel.processor.Pipeline.process(Pipeline.java:80)[171:org.apache.camel.camel-core:2.13.2] at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:191)[171:org.apache.camel.camel-core:2.13.2] at org.apache.camel.component.timer.TimerConsumer.sendTimerExchange(TimerConsumer.java:157)[171:org.apache.camel.camel-core:2.13.2] at org.apache.camel.component.timer.TimerConsumer$1.run(TimerConsumer.java:68)[171:org.apache.camel.camel-core:2.13.2] at java.util.TimerThread.mainLoop(Timer.java:555)[:1.7.0_75] at java.util.TimerThread.run(Timer.java:505)[:1.7.0_75] Caused by: java.io.IOException: Server returned HTTP response code: 503 for URL: http://localhost:8020/rmi at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1627)[:1.7.0_75] at java.net.URL.openStream(URL.java:1037)[:1.7.0_75] at org.apache.jackrabbit.rmi.repository.URLRemoteRepositoryFactory.getRemoteRepository(URLRemoteRepositoryFactory.java:61)[1626:org.apache.jackrabbit.jackrabbit-jcr-rmi:2.6.2] ... 15 more

is there any specific configurations that should be done to let the karaf container see the jackrabbit url, any suggestion will be welcome , Thanks .

1
I believe the issue is similar to this thread:stackoverflow.com/questions/15233420/…Ashoka
Actually , the camel jcr component works fine inside the unit test and I can get connection to jackrabbit repository over rmi , the issue show up when I deploy the route under the karaf container and I do not understand why the karaf container could not resolve the repository rmi URLTarek Chaouali

1 Answers

0
votes

In the case of the testcase the configuration is from the baseclass, which may need to be added to camel context.

Here's an example configuration from a camel example for the rmi:

    <bean id="rmiServer" class="java.rmi.registry.LocateRegistry"     factory-method="createRegistry">
        <constructor-arg index="0" value="${port}"/>

  </bean>

<camelContext xmlns="http://camel.apache.org/schema/spring" depends-on="rmiServer">
<endpoint id="rmiService" 
uri="rmi://localhost:${port}/helloServiceBean?remoteInterfaces=org.apache.camel.example.osgi.HelloService"/> 
<!-- expose a RMI service as a Camel route -->
<camel:route> 
<from ref="rmiService"/> 
<to uri="log:Incoming request on RMI"/> 
<to uri="bean:helloServiceBean"/> 
</camel:route> </camelContext>

Now this is typically needed if you're using rmi.

In the case that you have just described, we need the JndiRegistry. Can you try adding the following to the camel context

<bean id="registry" class="org.apache.camel.impl.JndiRegistry"/>

In the case of the JCR Jackrabbit try the following bean configuration:

    <bean id="repository"                    class="org.apache.jackrabbit.rmi.repository.URLRemoteRepository">
                <argument value="http://localhost:8020/rmi" />
  </bean>