---
title: "基于OSGi的JSF Web组件开发问题求解"
author: "danlley"
date: "2008-07-04T12:46:40Z"
tags: []
categories: ["企业架构"]
slug: "osgi-jsf-web"
draft: false
lastmod: "2008-07-04T12:46:40Z"
id: 211477
url: "https://danlley.iteye.com/blog/211477"
---

最近一直在研究OSGi Web组建开发，跑了一些小程序中间出现了不少问题，其中很多是由于对OSGi理解不够深入，当然还有些问题，目前也没有解决的办法，因此贴出来想让大伙帮帮忙。


具体情况如下：
1.拿纯Java代码编写的JSP页面进行测试，结果一切正常，说明JspServlet已经成功加载。
2.编写简单的JSF页面进行测试，结果出现错误提示，具体如下：

osgi> Jul 4, 2008 11:58:22 AM org.mortbay.jetty.servlet.ServletHandler handle
WARNING: EXCEPTION 
org.apache.jasper.JasperException: Unable to read TLD "META-INF/jsf_core.tld" from JAR file "bundleentry://136/src/main/java/webapp/WEB-INF/lib/jsf-impl-1.2_04-p02.jar": org.apache.jasper.JasperException: Failed to load or instantiate TagLibraryValidator class: com.sun.faces.taglib.jsf_core.CoreValidator
	at org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:510)
	at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:375)
	at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
	at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
	at org.eclipse.equinox.jsp.jasper.JspServlet.service(JspServlet.java:112)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
	at org.eclipse.equinox.http.servlet.internal.ServletRegistration.handleRequest(ServletRegistration.java:90)
	at org.eclipse.equinox.http.servlet.internal.ProxyServlet.processAlias(ProxyServlet.java:111)
	at org.eclipse.equinox.http.servlet.internal.ProxyServlet.service(ProxyServlet.java:67)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
	at org.eclipse.equinox.http.jetty.internal.HttpServerManager$InternalHttpServiceServlet.service(HttpServerManager.java:288)
	at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:428)
	at org.mortbay.jetty.servlet.ServletHandler.dispatch(ServletHandler.java:677)
	at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:568)
	at org.mortbay.http.HttpContext.handle(HttpContext.java:1530)
	at org.mortbay.http.HttpContext.handle(HttpContext.java:1482)
	at org.mortbay.http.HttpServer.service(HttpServer.java:909)
	at org.mortbay.http.HttpConnection.service(HttpConnection.java:820)
	at org.mortbay.http.HttpConnection.handleNext(HttpConnection.java:986)
	at org.mortbay.http.HttpConnection.handle(HttpConnection.java:837)
	at org.mortbay.http.SocketListener.handleConnection(SocketListener.java:245)
	at org.mortbay.util.ThreadedServer.handle(ThreadedServer.java:357)
	at org.mortbay.util.ThreadPool$PoolThread.run(ThreadPool.java:534)

起初我怀疑可能是不是那个tld文件已经损毁了，但是当我将整个工程转换成普通Web工程在Tomcat下运行一切正常，因此，我判断，首先可以保证tld文件是正常的。

后来在网上查阅了很多这方面的资料（相关资料确实很少，而且问多答少），有些人说需要在servlet-api-2.5.jar和jsp-api.jar之间做出选择，删掉其中一个jar就可以了，而事实上是这两个jar对我进行OSGi组建开发都至关重要，因此无法删除。

**注**： 关于代码详情，见附件。

下面是相关用到的约束bundle：
id	State       Bundle
0	ACTIVE      org.eclipse.osgi_3.3.2.R33x_v20080105
1	ACTIVE      org.eclipse.equinox.common_3.3.0.v20070426
3	ACTIVE      javax.servlet_2.4.0.v200706111738
4	ACTIVE      org.apache.commons.logging_1.0.4.v200706111724
5	ACTIVE      org.apache.commons.el_1.0.0.v200706111724
6	ACTIVE      org.apache.commons.logging_1.0.4
7	ACTIVE      javax.servlet.jsp_2.0.0.v200706191603
10	ACTIVE      org.eclipse.osgi.services_3.1.200.v20070605
11	ACTIVE      org.eclipse.equinox.launcher_1.0.1.R33x_v20080118
12	ACTIVE      org.eclipse.equinox.jsp.jasper.registry_1.0.0.v20070607
15	ACTIVE      org.eclipse.equinox.http.helper_1.0.0.qualifier
16	ACTIVE      org.mortbay.jetty_5.1.11.v200706111724
20	ACTIVE      org.eclipse.equinox.http.registry_1.0.1.R33x_v20071231
21	ACTIVE      org.eclipse.equinox.http.jetty_1.0.1.R33x_v20070816
22	ACTIVE      org.eclipse.equinox.registry_3.3.1.R33x_v20070802
23	ACTIVE      org.eclipse.equinox.http.servlet_1.0.1.R33x_v20070816
24	ACTIVE      org.eclipse.core.jobs_3.3.1.R33x_v20070709
58	ACTIVE      org.eclipse.equinox.jsp.jasper_1.0.100.qualifier
76	ACTIVE      org.apache.jasper_5.5.17.v200806031609
136	ACTIVE      MyJSFBundle_1.0.0