Pax Web on Knopflerfish on Android

拟墨画扇 提交于 2019-12-24 12:48:22

问题


I'm planning to start OSGi on Android with Web Services, wherein I will be able to run Java Server Pages (jsp) and Java Servlets on Android Browser.

My initial step was installing Knopflerfish on Android. I have followed this tutorial from knopflerfish: http://www.knopflerfish.org/releases/5.0.0/docs/android_dalvik_tutorial.html

Knopflerfish did well, I have seen the localhost:8080 on the Android phone's browser.

My second step was to install Pax Web on Knopflerfish that was also installed on Android. I have also followed their tutorial from here: http://www.knopflerfish.org/kf_pax_web_tutorial.html

The tutorial said that:

Uninstall the KF HTTP bundles

The first step is to stop the HTTP root bundle and uninstall the JSDK and HTTP-server bundles as PaxWeb will take over this function. Normally you will most likely also want to uninstall the HTTP-root-bundle, but for this tutorial we will leave it installed. Make sure to do a refresh packages before going to the next step.

Then:

Install PaxWeb

The second step is install and start the following bundles from PaxWeb.

  • pax-web-jsp-1.0.2.jar (install)
  • pax-web-jetty-bundle-1.0.2.jar (install & start)
  • pax-web-extender-war-0.8.0.jar(install & start)

The Pax Web bundles were successfully installed.


Problem

The Pax Web bundles cannot be started.

It gives me this error messages on the console when I try to start HTTP-root-IMP which is a Knopflerfish bundle.

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

Another is when I will start the bundles from the Pax Web tutorial from Knopflerfish. Here I tried to start 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)

Lastly, when I try to run pax-web-extender-war-0.8.0.jar (OPS4J Pax Web - Extender - War) this error messages will also appear:

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

I also tried to start pax-web-jsp-1.0.2.jar (OPS4J Pax Web - Jsp Support) this error message was displayed:

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

From what I have understood from the error messages, the bundles were looking for these packages. Is there any way I can resolve this and be able to successfully run a Java Web Application on Android with OSGi framework?

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.

回答1:


First of all I strongly suggest to use the same version for all bundles of Pax-Web, second you're missing a servlet API bundle. Also it looks like you're also missing a couple of other Pax-Web bundles. You'll most likely need the following bundles:

  • pax-web-api
  • pax-web-jetty-bundle
  • pax-web-jsp
  • pax-web-runtime
  • pax-web-spi

and if you want to use wars you'll need the

  • pax-web-extender-war
  • pax-url-war
  • and a couple more ...

Latest version of Pax-Web is 3.0.2 so you should choose with care depending on what you're trying to do. You might find it helpful to check the ITests of Pax-Web (depending on the version you're going to use) for inspiration on which bundles are needed. I'd suggest to start with a minimum set. This way you start with the http-service first and enhance it to the needs you have.

Take a look at the Pax-Web project at Github and especially at the samples and itests modules for more details.



来源:https://stackoverflow.com/questions/19761188/pax-web-on-knopflerfish-on-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!