简体   繁体   中英

Strange issues with OSGI web bundle,completely lost right now

I've been learning OSGI recently, and I'm having this problem when using STS 3.1 + virgo tomcat server 3.6 to build a web bundle , the task is simple, just need to deploy my bundle and display a jsp page, there are some good tutorials out there, but they basically all use spring to do this, I had some difficulties configuring spring MVC for OSGI, the jsp file I tried to access kept giving me 404 error,so I decide to rebuild things from scratch and hopefully find the reason for the failed experiment,first thing to do should be displaying a jsp page without spring, but if I simply import some javaweb-related packages ,set the Web-ContextPath , put a jsp file under web-info folder,the 404 error is still there , and I don't know what else to do, could someone tell me what might have caused it? shouldn't a OSGI web bundle be able to access a web page directly instead of importing a bunch of special packages?

I've appended this script into my web.xml like one of those examples shows(can someone tell me what does it do?)

    <context-param>
    <param-name>contextClass</param-name>
    <param-value>org.eclipse.virgo.web.dm.
    ServerOsgiBundleXmlWebApplicationContext
    </param-value>
    </context-param>

and My manifest.MF looks something like this:

Manifest-Version: 1.0
Bundle-ClassPath: WEB-INF/classes
Web-ContextPath: /osgitest
Import-Package: 
javax.servlet;version="[3.0.0,3.0.0]",
javax.servlet.http;version="[3.0.0,3.0.0]",
javax.servlet.jsp;version="[2.2.0,2.2.0]",
javax.servlet.jsp.el;version="[2.2.0,2.2.0]",
javax.servlet.jsp.jstl.core;version="[1.2.0.v20110728,1.2.0.v20110728]",
org.eclipse.virgo.web.dm;version="[3.6.0.RELEASE,3.6.0.RELEASE]",
org.slf4j;version="[1.7.2,1.7.2]"
Bundle-SymbolicName: c2c.osgitest.web
Bundle-Version: 1.0.0

and i'm using

http://localhost:8080/osgitest/login.jsp

Any suggestion would be appreciated!

so I decided to rebuild things from scratch and hopefully find the reason for the failed experiment. The first thing to do should be displaying a JSP page without Spring.

If Spring is a mere option (and other solutions are acceptable), I'd recommend to use Eclipse IDE, WebSphere Developer Tools and WebSphere Liberty Profile .

In Eclipse IDE, create OSGi Bundle Project with Web 3.0 support and then add a JSP page. When you run it, it's supposed to work. You may want to compare the bundle's configuration (mostly META-INF/MANIFEST.MF) with yours (and then decide to leverage Spring perhaps).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM