OSGi 中的 JSP:如何从捆绑包加载 TLD?
我们正在构建一个 JSP Web 应用程序,它在 Apache Felix OSGi 容器内运行(Web 应用程序本身是一个 OSGi Bundle)。现在,我们面临以下问题:
根据 JSP 2.0 规范,TLD(taglib 描述符)不再需要驻留在 Web 应用程序的 WEB-INF 文件夹中,而是直接从 taglib 的 jar META-INF 文件夹中加载。该 taglib jar 通常驻留在 Web 应用程序的 WEB-INF/lib 文件夹中,但由于它们是 OSGi 捆绑包,因此由 Felix 加载。
在 taglib 的 OSGi 信息中,我们导入了所有需要的包。有人知道如何告诉 servlet 在加载的 OSGi 捆绑包中搜索 TLD 吗?
感谢您的帮助!
We're building a JSP web application, which runs inside the Apache Felix OSGi container (the web app itself is a OSGi Bundle). Now, we're facing the following problem:
According to the JSP 2.0 Spec, TLD (taglib descriptors) no longer need to reside inside the web apps WEB-INF folder, but are loaded directly from the taglib's jar META-INF folder. This taglib jars usually reside inside the web apps WEB-INF/lib folder, but because they're OSGi bundles, they're loaded by Felix.
In the taglib's OSGi info, we do import all the needed packages. Anyone out there how knows how to tell the servlet, to search for TLDs also inside the loaded OSGi Bundles?
Thanks for your help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您的 TLD 与您的网络应用程序位于不同的捆绑包中,Pax 将找不到您的 TLD :
我在基于 Struts 的系统,我在多个 Web 应用程序包之间共享 OSGi-fied Struts 包。 Web 应用程序具有需要 Struts 标记库的 JSP。
一个稍微有点 hackish(因为它会复制 TLD 到各处)的解决方法是将 TLD 放入 web 应用程序的 META-INF 目录中,并使 web 应用程序包导入所需的 Struts 包(或者,如果您不这样做)使用 Struts,任何处理标签的类)。这可以使用 Maven 自动化,如下所示:
Pax won't find your TLDs, if they are in a bundle different from your webapp:
I'm having this problem in a Struts-based system where I share an OSGi-fied Struts bundle between multiple webapp bundles. The webapps have JSPs that need the Struts taglib.
A slightly hackish (because it copies the TLD all over the place) workaround is putting the TLD in your webapp's
META-INF
directory and make the webapp bundle import required Struts packages (or, if you don't use Struts, whatever classes process the tags). This can be automated with Maven like so:一般来说,集成 OSGi 和 Java EE 库是很困难的。 Nuxeo CMS 的人成功地集成了 Seam Framework 和 OSGi,所以我认为使用他们的想法,您也可以更轻松地集成 JSP TLD 和 OSGi。只需下载 Nuxeo 并分析其源代码: http://www.nuxeo.org/xwiki /bin/view/Main/
然而,集成 OSGi 和 Java EE 通常很困难。您真的需要 OSGi 运行时集成吗?也许 Maven 编译时集成对您来说就足够了?许多人只是将 Maven 和类似工具视为编译时 OSGi。
In general, it's hard to integrate OSGi and Java EE libraries. People from Nuxeo CMS managed to integrate Seam Framework and OSGi, so I think that using their ideas, you can integrate JSP TLD and OSGi as well, even more easily. Just download Nuxeo and analyze its source code: http://www.nuxeo.org/xwiki/bin/view/Main/
However integrating OSGi and Java EE is in general hard. Do you really need OSGi runtime integration. Perhaps Maven compile-time integration will be enough for you? Many people just see Maven and similar tools as compile-time OSGi.