OSGi web应用程序未运行
我试图弄清楚如何实现web应用程序包。为了做到这一点,我按照教程中的说明创建了一个小样本。war文件可以部署和启动,但我无法调用任何url。OSGi web应用程序未运行,web,osgi,wab,Web,Osgi,Wab,我试图弄清楚如何实现web应用程序包。为了做到这一点,我按照教程中的说明创建了一个小样本。war文件可以部署和启动,但我无法调用任何url。 战争档案的结构; +META-INF MANIFEST.MF +WEB-INF 类别/ fancyfoods/web/SayHello.class web.xml index.html 我试着打电话给 本地主机:8080/ localhost:8080/fancyfoods.web/index.html localhost:8080/fancy
战争档案的结构;
+META-INF
MANIFEST.MF
+WEB-INF
类别/
fancyfoods/web/SayHello.class
web.xml
index.html
我试着打电话给
本地主机:8080/
localhost:8080/fancyfoods.web/index.html
localhost:8080/fancyfoods.web/SayHello
但我总是收到“HTTP错误404”
我不知道怎么了。运行web应用程序是否需要更多捆绑包 致意
削减
您好 谢谢你的回复,很抱歉我的回答有误(我是新来的堆栈溢出)。 我从头开始了一个新的WAB示例,但它仍然不起作用。为了测试http服务是否正常工作,我首先实现了另一个包(不是WAB),其中包含一个servlet和一个OSGi组件,该组件注册servlet和静态资源。而且它有效!我能够调用html和servlet 现在回到我的WAB问题。由于非WAB示例有效,我假设war文件不正常。我投入了更多的时间为您提供必要的信息(我希望如此) 我的war文件的结构是:
¦---index.html
¦
+---META-INF
¦-------MANIFEST.MF
¦
+---WEB-INF
¦ web.xml
¦
+---classes
+---org
+---osgi
+---helloworld
+---wab
HelloWorldWab.class
HelloWorldWabActivator.class
HelloWorldWabComponent.class
HelloWorldWabServlet.class
MANIFEST.MF文件:
Manifest-Version: 1.0
Ant-Version: Apache Ant 1.8.3
Created-By: 1.7.0_09-b05 (Oracle Corporation)
Bundle-ManifestVersion: 2
Bundle-Name: org.osgi.helloworld.wab
Bundle-SymbolicName: org.osgi.helloworld.wab
Bundle-Version: 1.0.0.qualifier
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Bundle-Activator: org.osgi.helloworld.wab.HelloWorldWabActivator
Bundle-ClassPath: WEB-INF/classes
Import-Package: javax.servlet, javax.servlet.http, org.osgi.framework,
org.osgi.service.component, org.osgi.service.http, org.osgi.util.tra
cker
Export-Package: org.osgi.helloworld.wab
Web-ContextPath: /helloworld
Webapp-Context: /helloworld
当我启动和停止bundle时,HelloWorldWabActivator的方法将作为aspected调用。
web.xml文件:
<web-app>
<!-- welcome file mapping -->
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>HelloWorldWabServlet</servlet-name>
<servlet-class>org.osgi.helloworld.wab.HelloWorldWabServletXXX</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>HelloWorldWabServlet</servlet-name>
<url-pattern>/HelloWorldWabServlet</url-pattern>
</servlet-mapping>
</web-app>
感谢您的支持您是否也在清单文件中指定了Web ContextPath
理想情况下,您还应该在web-INF文件夹中指定一个web.xml文件。关于如何在pax web项目提供的OSGi web容器上运行web应用程序,有几个不同的示例,这些示例可能有助于您解决问题并快速开始OSGi战争。
哦,确保你已经设置了WebApp上下文 我必须添加pax web extender war捆绑包(可能还有pax url)和依赖项,以使war样式的WAB与web.xml一起工作。为了在eclipse中的bndTools felix运行时中实现这一点,我从最新的ApacheServiceMix系统/目录中提取了所有JAR/bundle;将它们全部导入我的bndTools本地存储库;并将所有pax和jetty捆绑包添加到我的bndTools运行配置中。(您可能需要跟踪一些其他依赖项) 如果您查看fancyfoods.web捆绑包正在使用的服务,是否显示“org.osgi.service.http.HttpService”作为正在使用的服务?
START LEVEL 1
ID|State |Level|Name
0|Active | 0|System Bundle (4.2.1)
1|Active | 1|Apache Commons FileUpload (1.2.2.v20111214-1400)
2|Active | 1|Apache Commons IO (1.4.0.v20081110-1000)
3|Active | 1|Apache Felix Bundle Repository (1.6.6)
4|Active | 1|Apache Felix Configuration Admin Service (1.6.0)
5|Active | 1|Apache Felix EventAdmin (1.3.2)
6|Active | 1|Apache Felix File Install (3.2.6)
7|Active | 1|Apache Felix Gogo Command (0.12.0)
8|Active | 1|Apache Felix Gogo Runtime (0.10.0)
9|Active | 1|Apache Felix Gogo Shell (0.10.0)
10|Active | 1|Apache Felix Http Api (2.2.0)
11|Active | 1|Apache Felix Http Base (2.2.0)
12|Active | 1|Apache Felix Http Bridge (2.2.0)
13|Active | 1|Apache Felix Http Bundle (2.2.0)
14|Active | 1|Apache Felix Http Jetty (2.2.0)
15|Active | 1|Apache Felix Http Proxy (2.2.0)
16|Active | 1|Apache Felix Http Whiteboard (2.2.0)
17|Active | 1|Apache Felix Log Service (1.0.1)
18|Active | 1|Apache Felix Preferences Service (1.0.4)
19|Active | 1|Apache Felix Declarative Services (1.6.2)
20|Active | 1|Apache Felix Web Management Console (4.0.0)
21|Active | 1|JSON Implementation for Java (1.0.0.v201011060100)
22|Active | 1|org.osgi.helloworld.wab (1.0.0.qualifier)
23|Active | 1|org.osgi.helloworld.servlet (1.0.0.qualifier)