我计划从OSGi
带有 Web 服务的 Android 开始,其中我将能够在 Android 浏览器上运行 Java Server Pages (jsp) 和 Java Servlet。
我的第一步是Knopflerfish
在 Android 上安装。我从 knopflerfish 遵循了本教程:http ://www.knopflerfish.org/releases/5.0.0/docs/android_dalvik_tutorial.html
Knopflerfish 做得很好,我在 Android 手机的浏览器上看到了 localhost:8080。
我的第二步是安装Pax Web
在也安装在 Android 上的 Knopflerfish 上。我也从这里遵循了他们的教程:http ://www.knopflerfish.org/kf_pax_web_tutorial.html
教程说:
卸载 KF HTTP 包
第一步是停止 HTTP 根包并卸载 JSDK 和 HTTP-server 包,因为 PaxWeb 将接管此功能。通常,您很可能还想卸载 HTTP-root-bundle,但在本教程中,我们将保留它的安装状态。确保在进行下一步之前刷新包。
然后:
安装 PaxWeb
第二步是从 PaxWeb 安装并启动以下包。
- pax-web-jsp-1.0.2.jar(安装)
- pax-web-jetty-bundle-1.0.2.jar(安装和启动)
- pax-web-extender-war-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.