地铁+码头+ OSGi =痛苦 [英] Metro + Jetty + OSGi = pain

查看:113
本文介绍了地铁+码头+ OSGi =痛苦的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将Sun的HTTPServer换成OSGi捆绑包中运行在Equinox上更好的Jetty服务器.

I am trying to swap out Sun's HTTPServer for the much better Jetty server, within an OSGi bundle, running on Equinox.

我已经尝试过了:

System.setProperty("com.sun.net.httpserver.HttpServerProvider","org.mortbay.jetty.j2se6.JettyHttpServerProvider");

但是当调用endpoint.publish(url)并生成服务器时,它抱怨org.mortbay.jetty.j2se6.JettyHttpServerProvider的ClassNotFoundException.

but when endpoint.publish(url) is called, and the server is spawned, it complains of a ClassNotFoundException for org.mortbay.jetty.j2se6.JettyHttpServerProvider.

但是,捆绑包中包含正确的jar,实际上在Activator中,我可以实例化org.mortbay.jetty.j2se6.JettyHttpServerProvider.

However, the correct jars are in the bundle, and indeed in the Activator I can instantiate a org.mortbay.jetty.j2se6.JettyHttpServerProvider.

我认为这是某种类路径问题-生成的服务器可能在不同的类路径中?我尝试在JDK级别添加JAR,但这没有任何区别.

I think that this is a some kind of classpath issue - the spawned server is in a different classpath maybe? I have tried adding the JARs in at the JDK level, but this doesn't make any difference.

有人能说明一切如何使它正常工作吗?

Can oanyone shed any light how on earth to get this working?

P.S.也许有一天,可怕的System.setProperty调用将从世界上消失.希望:)

P.S. Maybe hideous System.setProperty calls will vanish from the world one day. Hopefully :)

推荐答案

问题是工厂不了解OSGi,并且加载工厂的类没有引用Jetty实现.并不是它是否在您的捆绑软件中(您似乎已合并到一个捆绑软件中),而是工厂方法在某些核心代码中,并且无法解析Jetty.

The problem is that the factory is not OSGi aware, and the class that loads the factory has no reference to the Jetty implementation. It's not whether it's in your bundle (which you seem to have combined in one bundle) but rather that the factory method is in some core code, and that fails to be able to resolve Jetty.

实例化HttpServer的调用不是Java6 API的一部分,而是Sun的内部类之一-因此,此调用在非Sun JVM上运行时将失败.最好找出如何使用Metro来完成除使用此工厂方法之外的其他操作以使类聚在一起的方法.

The call to instantiate an HttpServer is not part of the Java6 API, bur rather one of Sun's internal classes - so this call will fail when running on non-Sun JVMs. It would be better to find out how to use Metro to do something other than use this factory method in order to get the class together.

这篇关于地铁+码头+ OSGi =痛苦的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆