大同网络上Knopflerfish在Android(Pax Web on Knopflerfish

2019-10-18 22:23发布

我打算开始OSGi在Android上的Web服务,其中我将能够在Android浏览器上运行的Java服务器页面(JSP)和Java Servlets。

我最初的步骤安装Knopflerfish在Android上。 我按照从knopflerfish本教程: http://www.knopflerfish.org/releases/5.0.0/docs/android_dalvik_tutorial.html

在Android手机的浏览器8080:Knopflerfish做的很好,我已经看到了本地主机。

我的第二个步骤是安装Pax Web上Knopflerfish这也安装在Android上。 我也跟着他们的教程从这里开始: http://www.knopflerfish.org/kf_pax_web_tutorial.html

本教程说:

卸载KF HTTP束

第一步是停止HTTP根束和卸载JSDK和HTTP服务器束作为PaxWeb将接管该功能。 通常情况下,你将最有可能也是要卸载的HTTP根束,但在本教程中,我们会离开它安装。 之前,请务必准备下一步执行刷新包。

然后:

安装PaxWeb

第二步是安装并从PaxWeb启动以下束。

  • PAX-Web的JSP-1.0.2.jar(安装)
  • PAX-Web的码头束-1.0.2.jar(安装和启动)
  • PAX-Web的扩展,战争0.8.0.jar(安装和启动)

Pax Web包已成功安装。


问题

Pax Web包无法启动。

它给我的控制台上的错误信息,当我尝试启动HTTP-root-IMP这是一个Knopflerfish包。

[stderr] ## DEBUG: errors - FrameworkErrorEvent bundle #20
[stderr] ## DEBUG: errors - FrameworkErrorEvent throwable:
Couldn't start bundle: HTTP-root-IMPL (#20) (due to: org.osgi.framework.BundleException: Bundle#20, unable to resolve: Missing package(s) or can not resolve all of the them:
org.osgi.service.http;version=[1.1.0,2.0.0) -- Could not resolve exporting bundle - org.osgi.service.http;version=1.2.0 Bundle[id=16,gen=0].
javax.servlet.http;version=[2.5.0,3.0.0) -- Could not resolve exporting bundle - javax.servlet.http;version=2.5.0 Bundle[id=16,gen=0].
javax.servlet;version=[2.5.0,3.0.0) -- Could not resolve exporting bundle - javax.servlet;version=2.5.0 Bundle[id=16,gen=0].)
org.osgi.framework.BundleException: Bundle#20, unable to resolve: Missing package(s) or can not resolve all of the them:
org.osgi.service.http;version=[1.1.0,2.0.0) -- Could not resolve exporting bundle - org.osgi.service.http;version=1.2.0 Bundle[id=16,gen=0].
javax.servlet.http;version=[2.5.0,3.0.0) -- Could not resolve exporting bundle - javax.servlet.http;version=2.5.0 Bundle[id=16,gen=0].
javax.servlet;version=[2.5.0,3.0.0) -- Could not resolve exporting bundle - javax.servlet;version=2.5.0 Bundle[id=16,gen=0].
        at org.knopflerfish.framework.BundleImpl.getUpdatedState(BundleImpl.java:1259)
        at org.knopflerfish.framework.BundleImpl.finalizeActivation(BundleImpl.java:312)
        at org.knopflerfish.framework.PermissionOps.callFinalizeActivation(PermissionOps.java:265)
        at org.knopflerfish.framework.BundleImpl.start(BundleImpl.java:295)
        at org.knopflerfish.bundle.frameworkcommands.FrameworkCommandGroup.cmdStart(FrameworkCommandGroup.java:1634)
        at java.lang.reflect.Method.invokeNative(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:511)
        at org.knopflerfish.service.console.CommandGroupAdapter.execute(CommandGroupAdapter.java:256)
        at org.knopflerfish.bundle.console.Command$2.run(Command.java:239)
        at java.security.AccessController.doPrivileged(AccessController.java:45)
        at org.knopflerfish.bundle.console.Command.run(Command.java:226)
        at java.lang.Thread.run(Thread.java:856)

另一种是当我将开始从束Pax Web从Knopflerfish教程。 在这里,我试图启动pax-web-jetty-bundle-1.0.2.jar (OPS4J Pax Web - Jetty Bundle)

[stderr] ## DEBUG: errors - FrameworkErrorEvent bundle #16
[stderr] ## DEBUG: errors - FrameworkErrorEvent throwable:
Couldn't start bundle: OPS4J Pax Web - Jetty Bundle (#16) (due to: org.osgi.framework.BundleException: Bundle#16, unable to resolve: Missing package(s) or can not resolve all of the them:
javax.security.sasl -- No providers found.
javax.management.remote -- No providers found.
javax.management.modelmbean -- No providers found.
javax.management -- No providers found.)
org.osgi.framework.BundleException: Bundle#16, unable to resolve: Missing package(s) or can not resolve all of the them:
javax.security.sasl -- No providers found.
javax.management.remote -- No providers found.
javax.management.modelmbean -- No providers found.
javax.management -- No providers found.
        at org.knopflerfish.framework.BundleImpl.getUpdatedState(BundleImpl.java:1259)
        at org.knopflerfish.framework.BundleImpl.finalizeActivation(BundleImpl.java:312)
        at org.knopflerfish.framework.PermissionOps.callFinalizeActivation(PermissionOps.java:265)
        at org.knopflerfish.framework.BundleImpl.start(BundleImpl.java:295)
        at org.knopflerfish.bundle.frameworkcommands.FrameworkCommandGroup.cmdStart(FrameworkCommandGroup.java:1634)
        at java.lang.reflect.Method.invokeNative(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:511)
        at org.knopflerfish.service.console.CommandGroupAdapter.execute(CommandGroupAdapter.java:256)
        at org.knopflerfish.bundle.console.Command$2.run(Command.java:239)
        at java.security.AccessController.doPrivileged(AccessController.java:45)
        at org.knopflerfish.bundle.console.Command.run(Command.java:226)
        at java.lang.Thread.run(Thread.java:856)

最后,当我尝试运行pax-web-extender-war-0.8.0.jar (OPS4J Pax Web - Extender - War)这个错误信息也将出现:

[stderr] ## DEBUG: errors - FrameworkErrorEvent bundle #17
[stderr] ## DEBUG: errors - FrameworkErrorEvent throwable:
Couldn't start bundle: OPS4J Pax Web - Extender - WAR (#17) (due to: org.osgi.framework.BundleException: Bundle#17, unable to resolve: Missing package(s) or can not resolve all of the them:
org.osgi.service.http;version=[1.0.0,2.0.0) -- Could not resolve exporting bundle - org.osgi.service.http;version=1.2.0 Bundle[id=16,gen=0].
javax.servlet.http;version=2.1.0 -- Could not resolve exporting bundle - javax.servlet.http;version=2.5.0 Bundle[id=16,gen=0].
javax.servlet;version=2.1.0 -- Could not resolve exporting bundle - javax.servlet;version=2.5.0 Bundle[id=16,gen=0].)
org.osgi.framework.BundleException: Bundle#17, unable to resolve: Missing package(s) or can not resolve all of the them:
org.osgi.service.http;version=[1.0.0,2.0.0) -- Could not resolve exporting bundle - org.osgi.service.http;version=1.2.0 Bundle[id=16,gen=0].
javax.servlet.http;version=2.1.0 -- Could not resolve exporting bundle - javax.servlet.http;version=2.5.0 Bundle[id=16,gen=0].
javax.servlet;version=2.1.0 -- Could not resolve exporting bundle - javax.servlet;version=2.5.0 Bundle[id=16,gen=0].
        at org.knopflerfish.framework.BundleImpl.getUpdatedState(BundleImpl.java:1259)
        at org.knopflerfish.framework.BundleImpl.finalizeActivation(BundleImpl.java:312)
        at org.knopflerfish.framework.PermissionOps.callFinalizeActivation(PermissionOps.java:265)
        at org.knopflerfish.framework.BundleImpl.start(BundleImpl.java:295)
        at org.knopflerfish.bundle.frameworkcommands.FrameworkCommandGroup.cmdStart(FrameworkCommandGroup.java:1634)
        at java.lang.reflect.Method.invokeNative(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:511)
        at org.knopflerfish.service.console.CommandGroupAdapter.execute(CommandGroupAdapter.java:256)
        at org.knopflerfish.bundle.console.Command$2.run(Command.java:239)
        at java.security.AccessController.doPrivileged(AccessController.java:45)
        at org.knopflerfish.bundle.console.Command.run(Command.java:226)
        at java.lang.Thread.run(Thread.java:856)

我也试着开始pax-web-jsp-1.0.2.jar (OPS4J Pax Web - Jsp Support)中显示此错误消息:

[stderr] ## DEBUG: errors - FrameworkErrorEvent bundle #15
[stderr] ## DEBUG: errors - FrameworkErrorEvent throwable:
Couldn't start bundle: OPS4J Pax Web - Jsp Support (#15) (due to: org.osgi.framework.BundleException: Bundle#15, unable to resolve: Missing package(s) or can not resolve all of the them:
javax.tools -- No providers found.
javax.servlet.resources;version=[2.3.0,3.0.0) -- Could not resolve exporting bundle - javax.servlet.resources;version=2.5.0 Bundle[id=16,gen=0].
javax.servlet.http;version=[2.3.0,3.0.0) -- Could not resolve exporting bundle - javax.servlet.http;version=2.5.0 Bundle[id=16,gen=0].
javax.servlet;version=[2.3.0,3.0.0) -- Could not resolve exporting bundle - javax.servlet;version=2.5.0 Bundle[id=16,gen=0].
javax.lang.model.util -- No providers found.
javax.lang.model.type -- No providers found.
javax.lang.model.element -- No providers found.
javax.lang.model -- No providers found.
javax.annotation.processing -- No providers found.)
org.osgi.framework.BundleException: Bundle#15, unable to resolve: Missing package(s) or can not resolve all of the them:
javax.tools -- No providers found.
javax.servlet.resources;version=[2.3.0,3.0.0) -- Could not resolve exporting bundle - javax.servlet.resources;version=2.5.0 Bundle[id=16,gen=0].
javax.servlet.http;version=[2.3.0,3.0.0) -- Could not resolve exporting bundle - javax.servlet.http;version=2.5.0 Bundle[id=16,gen=0].
javax.servlet;version=[2.3.0,3.0.0) -- Could not resolve exporting bundle - javax.servlet;version=2.5.0 Bundle[id=16,gen=0].
javax.lang.model.util -- No providers found.
javax.lang.model.type -- No providers found.
javax.lang.model.element -- No providers found.
javax.lang.model -- No providers found.
javax.annotation.processing -- No providers found.
        at org.knopflerfish.framework.BundleImpl.getUpdatedState(BundleImpl.java:1259)
        at org.knopflerfish.framework.BundleImpl.finalizeActivation(BundleImpl.java:312)
        at org.knopflerfish.framework.PermissionOps.callFinalizeActivation(PermissionOps.java:265)
        at org.knopflerfish.framework.BundleImpl.start(BundleImpl.java:295)
        at org.knopflerfish.bundle.frameworkcommands.FrameworkCommandGroup.cmdStart(FrameworkCommandGroup.java:1634)
        at java.lang.reflect.Method.invokeNative(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:511)
        at org.knopflerfish.service.console.CommandGroupAdapter.execute(CommandGroupAdapter.java:256)
        at org.knopflerfish.bundle.console.Command$2.run(Command.java:239)
        at java.security.AccessController.doPrivileged(AccessController.java:45)
        at org.knopflerfish.bundle.console.Command.run(Command.java:226)
        at java.lang.Thread.run(Thread.java:856)

从我已经从错误消息了解,束在寻找这些软件包。 有没有什么办法可以解决这一点,并能够成功地运行与OSGi框架Android上的Java Web应用程序?

org.osgi.service.http;version=[1.1.0,2.0.0) -- Could not resolve exporting bundle - org.osgi.service.http;version=1.2.0 Bundle[id=16,gen=0].
javax.servlet.http;version=[2.5.0,3.0.0) -- Could not resolve exporting bundle - javax.servlet.http;version=2.5.0 Bundle[id=16,gen=0].
javax.servlet;version=[2.5.0,3.0.0) -- Could not resolve exporting bundle - javax.servlet;version=2.5.0 Bundle[id=16,gen=0].

javax.security.sasl -- No providers found.
javax.management.remote -- No providers found.
javax.management.modelmbean -- No providers found.
javax.management -- No providers found.

Answer 1:

首先,我强烈建议使用相同版本的PAX-网络的所有包,第二次你错过了一个Servlet API包。 此外,它看起来像你也错过了几个其他大同的Web束。 你最有可能需要以下包:

  • PAX-Web的API
  • PAX-Web的码头束
  • PAX-Web的JSP
  • PAX-网络运行
  • PAX-Web的SPI

如果你想用战争,你需要的

  • PAX-Web的扩展,战争
  • PAX-URL战
  • 和一对夫妇更多...

大同的Web的最新版本是3.0.2,所以你应该根据你想要做什么护理选择。 你可能会发现,检查大同的Web(取决于你要使用的版本)的ITests对需要哪些包的灵感。 我建议先从一组最小。 这样,您就开始与HTTP的服务第一,它增强你的需求。

看看在在Github上PAX-Web项目 ,特别是在样品和itests模块的更多细节。



文章来源: Pax Web on Knopflerfish on Android