OSGi中的Restlet HTTP问题

OSGi中的Restlet HTTP问题,http,proxy,network-programming,osgi,restlet,Http,Proxy,Network Programming,Osgi,Restlet,我是Restlet框架(版本2.08)的一名痴迷用户。这就是为什么我目前试图在OSGi环境中使用Restlet来完成我论文的实际部分。最后,我创建了一个服务器包(由我的Felix OSGi环境中的Activator启动),并显示一条消息作为对一个简单调用的响应,如http://localhost:8888/ 但是我没有成功地从Restlet接收到另一个资源。想象一下,我需要http://localhost:808​0/tripleStore/triple​s/5以计算http://localho

我是Restlet框架(版本2.08)的一名痴迷用户。这就是为什么我目前试图在OSGi环境中使用Restlet来完成我论文的实际部分。最后,我创建了一个服务器包(由我的Felix OSGi环境中的Activator启动),并显示一条消息作为对一个简单调用的响应,如
http://localhost:8888/

但是我没有成功地从Restlet接收到另一个资源。想象一下,我需要
http://localhost:808​0/tripleStore/triple​s/5
以计算
http://localhost:8888/test
。(下面是代码片段…)

目前,我收到一个“错误的请求”-我打电话时出错
http://localhost:808​0/tripleStore/triple​我的restlet中有s/5
,调用
http://127.0.0.1:808​0/tripleStore/triple​s/5
来自我的Restlet

进一步的研究表明,这种错误的原因很简单。restlet尝试直接从网络代理获取结果,网络代理不知道任何
localhost
,并且禁止调用
127.0.0.1

另一个关键点是,除了一次尝试之外,错误总是可以复制的。在这种情况下,一切正常。这就是为什么我假设与OSGi启动顺序有关。(这不是固定的,取决于Sonatype乙醚框架。)

您是否已经意识到这样的错误?你能给我建议一些避免手动尝试所有OSGi启动命令的错误修复方法吗?当我尝试在OSGi之外做这些事情时,一切都很好

提前谢谢!
马库斯你的问题提醒了我一个问题。您必须记住的是,客户机连接器是根据Restlet引擎自动注册的。这里的问题是捆绑装载的顺序

我的问题是关于HTTPS连接器的。在尝试添加客户端连接器时,必须确保已加载提供连接器的捆绑包。否则我会在跟踪中看到类似的内容:

Internal Connector Error (1002) - No available client connector supports the required
protocol: 'HTTPS'. Please add the JAR of a matching connector to your classpath.
也许在添加客户机连接器之前,您可以检查已加载的捆绑包,在执行REST请求之前,检查已注册的客户机连接器吗

以下是查看已注册客户端连接器的代码:

List<ConnectorHelper<Client>> clients = Engine.getInstance().getRegisteredClients();
System.out.println("Connectors - "+clients.size());
for (ConnectorHelper<Client> connectorHelper : clients) {
    System.out.println("connector = "+connectorHelper.getClass());
}
registerClientConnector方法只是执行类似的操作:component.getClients().add(Protocol.HTTPS)

希望对你有帮助。不要犹豫,给我一个最小的项目来重现这个问题,这样我可以更准确地帮助你。 蒂埃里

List<ConnectorHelper<Client>> clients = Engine.getInstance().getRegisteredClients();
System.out.println("Connectors - "+clients.size());
for (ConnectorHelper<Client> connectorHelper : clients) {
    System.out.println("connector = "+connectorHelper.getClass());
}
// Checking the bundle loading in the future
bundleContext.addBundleListener(new BundleListener() {
    public void bundleChanged(BundleEvent event) {
        if (event.getBundle().getSymbolicName().equals("org.restlet.ext.ssl")
                       & event.getBundle().getState()==BundleEvent.RESOLVED) {
            registerClientConnector();
        }
    }
});

// Checking if the bundle is already present
Bundle[] bundles = bundleContext.getBundles();
for (Bundle bundle : bundles) {
    if (bundle.getSymbolicName().equals("org.restlet.ext.ssl")
              && bundle.getState()==BundleEvent.RESOLVED) {
        registerClientConnector();
    }
}