我打算在Android上使用Web服務啓動OSGi
,其中我將能夠在Android Browser上運行Java Server Pages(jsp)和Java Servlets。Android上的Knopflerfish上的Pax Web
我的第一步是在Android上安裝Knopflerfish
。我遵循這個來自knopflerfish的教程:http://www.knopflerfish.org/releases/5.0.0/docs/android_dalvik_tutorial.html
Knopflerfish做得很好,我在Android手機的瀏覽器上看到了localhost:8080。
我的第二步是在Knopflerfish上安裝Pax Web
,它也安裝在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的extender-戰爭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)
另一個是當我會從Knopflerfish的Pax Web
教程啓動束。在這裏,我試圖啓動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.
我已經在這裏成功下載了pax-web jar文件:http://repo1.maven.org/maven2/org/ops4j/pax/web/。但是,在我正在執行的當前項目中添加這些jar的步驟之一是將其「dexify」,但我無法創建'pax-web-jetty-bundle-3.0.2.jar'的dex文件。在將它們包含到當前項目之前,我需要一個jar文件的dex文件。 –
你能推薦什麼servlet API包? @Achim –
您可以在https://github.com/ops4j/org.ops4j.pax.web/blob/master/pax-web-features/src/main找到karaf功能文件(需要的軟件包列表) /resources/features.xml#L4,這會讓你更進一步,我希望。 –