1. 程式人生 > >基於OSGi的JSF Web元件開發問題求解

基於OSGi的JSF Web元件開發問題求解

最近一直在研究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組建開發都至關重要,因此無法刪除。

[b]注[/b]: 關於程式碼詳情,見附件。

下面是相關用到的約束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