《OSGI实战 》中的eclipse可能比较老,练习其中的用户登录例子的时候会遇到如下问题:
1. 找不到org.eclipse.equinox.servlet.api
2. 无法访问http://localhost/demo/page/login.htm
如果是eclipse 3.4这样解决:
对于第一个问题,用javax.servlet包替代;
http://lggege.iteye.com/blog/327187
org.eclipse.equinox.servlet.api_1.0.0.v20060601.jar
在Eclipse3.4中为什么找不到,其实这中间藏着一个小秘密,
Eclipse3.2中的org.eclipse.equinox.servlet.api.jar
其实就是直接从Tomcat 4.1.30中拿的servlet.jar
你可以见org.eclipse.equinox.servlet.api.jar中的about.html
而在Eclipse3.4中,已经直接用回了原来的名字:
javax.servlet_2.4.0.v200806031604.jar
你可以见javax.servlet.jar中的about.html
对于第二个问题增加org.eclipse.equinox.http和org.eclipse.equinox.http.servlet
id State Bundle
0 ACTIVE org.eclipse.osgi_3.4.2.R34x_v20080826-1230
1 ACTIVE ConfigFileValidatorBundle_1.0.0
2 ACTIVE DBValidatorBundle_1.0.0
4 ACTIVE UserValidatorBundle_1.0.0
5 ACTIVE LDAPValidatorBundle_1.0.0
9 ACTIVE UserValidatorWebBundle_1.0.0
10 ACTIVE org.eclipse.equinox.util_1.0.0.v20080414
11 ACTIVE org.eclipse.equinox.ds_1.0.0.v20080427-0830
12 ACTIVE javax.servlet_2.4.0.v200806031604
13 ACTIVE org.eclipse.osgi.services_3.1.200.v20071203
14 ACTIVE org.eclipse.equinox.http.servlet_1.0.100.v20080427-0830
15 ACTIVE org.eclipse.equinox.http_1.0.200.v20080421-2006
17 ACTIVE org.eclipse.osgi.util_3.1.300.v20080303
如果是eclipse galileo这样解决:
1. 用javax.servlet替代org.eclipse.equinox.servlet.api
2. 由于找不到org.eclipse.equinox.http,所以改为增加:org.eclipse.equinox.http.jetty;org.mortbay.jetty.util;org.mortbay.jetty.server三个包,就可以了。
Framework is launched.
id State Bundle
0 ACTIVE org.eclipse.osgi_3.5.0.v20090520
1 ACTIVE ConfigFileValidatorBundle_1.0.0
2 ACTIVE org.eclipse.osgi.services_3.2.0.v20090520-1800
4 ACTIVE UserValidatorBundle_1.0.0
6 ACTIVE UserValidatorWebBundle_1.0.0
7 ACTIVE javax.servlet_2.5.0.v200806031605
9 ACTIVE LDAPValidatorBundle_1.0.0
10 ACTIVE DBValidatorBundle_1.0.0
11 ACTIVE org.eclipse.equinox.http.servlet_1.0.200.v20090520-1800
20 ACTIVE org.mortbay.jetty.util_6.1.15.v200905182336
21 ACTIVE org.mortbay.jetty.server_6.1.15.v200905151201
22 ACTIVE org.eclipse.equinox.http.jetty_2.0.0.v20090520-1800