无法从karaf容器访问Jackrabbit存储库

时间:2015-05-27 13:04:40

标签: osgi apache-camel jackrabbit

我正试图通过karaf容器中的rmi访问jackrabbit存储库

我开发了一个将文件保存到jackrabbit存储库的骆驼路径

<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>

使用mvn camel运行路线

同样的路线在karaf容器内不起作用,我得到了:

javax.jcr.RepositoryException:找不到远程存储库:无法检索http://localhost:8020/rmi处的资源         在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]         在org.apache.jackrabbit.rmi.repository.ProxyRepository.login(ProxyRepository.java:199)[1626:org.apache.jackrabbit.jackrabbit-jcr-rmi:2.6.2]         在org.apache.jackrabbit.rmi.repository.ProxyRepository.login(ProxyRepository.java:233)[1626:org.apache.jackrabbit.jackrabbit-jcr-rmi:2.6.2]         在com.sagemcom.Content.process(Content.java:21)[1618:内容:0.0.1.SNAPSHOT]         在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]         在org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:191)[171:org.apache.camel.camel-core:2.13.2]         在org.apache.camel.processor.Pipeline.process(Pipeline.java:118)[171:org.apache.camel.camel-core:2.13.2]         在org.apache.camel.processor.Pipeline.process(Pipeline.java:80)[171:org.apache.camel.camel-core:2.13.2]         在org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:191)[171:org.apache.camel.camel-core:2.13.2]         在org.apache.camel.component.timer.TimerConsumer.sendTimerExchange(TimerConsumer.java:157)[171:org.apache.camel.camel-core:2.13.2]         在org.apache.camel.component.timer.TimerConsumer $ 1.run(TimerConsumer.java:68)[171:org.apache.camel.camel-core:2.13.2]         在java.util.TimerThread.mainLoop(Timer.java:555)[:1.7.0_75]         在java.util.TimerThread.run(Timer.java:505)[:1.7.0_75] 引起:java.io.IOException:服务器返回HTTP响应代码:503为URL:http://localhost:8020/rmi         at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1627)[:1.7.0_75]         在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个

是否有任何具体的配置应该让karaf容器看到长耳大门的网址,欢迎任何建议,谢谢。

1 个答案:

答案 0 :(得分:0)

对于测试用例,配置来自基类,可能需要将其添加到驼峰上下文中。

以下是来自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>

现在,如果您正在使用rmi,通常需要这样做。

在您刚刚描述的情况下,我们需要JndiRegistry。 您可以尝试将以下内容添加到驼峰上下文

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

对于JCR Jackrabbit,请尝试以下bean配置:

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