jetty-equinox 中的 JSF,无法在其他包中找到 Bean 类

发布于 2024-08-24 15:06:09 字数 1129 浏览 9 评论 0原文

我在 OSGi 环境中运行 JSF 时遇到问题。我正在使用 jetty Web 容器和 Equinox 来提供 OSGi 功能。我的应用程序的结构如下: 第一个包包含所有 JSF 库、web.xmlconfig.xml。如下所示:

bundle1
----src/main/java
-------de/package
----------Activator.java
----------JSFResolver.java
----src/main/resource
------ WebContent
----------META-INF
-------------face-config.xml
-------------web.xhtml
----------start.xhtml
-----------include.xhtml
----libs (containing all JSF required Jars)

第二个bundle 的结构如下:

bundle2
---src/main/java
------de/package
----------Bean.java
---src/main/resource
------META-INF
---------face-config.xml
------WebContent
---------index.xhtml

当运行equinox 应用程序时,bundle1 是所有浏览器请求发送到的主bundle。在第二个包中,可以根据请求由第一个包检索 index.xhtml 文件。捆绑包 2 中的 index.xhtml 从捆绑包 2 中的“Bean.java”获取其值和属性。当我请求“index.xhtml”时,问题就出现了,Bean.java 类不是成立。我认为这是因为bundle1的类加载器找不到它,它不知道它。所以想请教一下有没有人知道如何解决这个问题。如果是这样,请帮助我,我已经尝试了所有的可能性。

实际上是否可以使用相同的 FaceletsContex 让 JSF 在多个包上运行?我是否可以在每个包中拥有单独的 faces-config.xml 文件,这些文件都可以连接其他包中的其他 faces-config.xml ?任何人都可以为我提供解决方案。示例代码会有帮助。

I have problems running JSF in an OSGi environment. I am using jetty web container and equinox to provide the OSGi functionality. The structure of my application is as follows:
The first bundle has all the JSF libs, web.xml and a config.xml. It looks as the following:

bundle1
----src/main/java
-------de/package
----------Activator.java
----------JSFResolver.java
----src/main/resource
------ WebContent
----------META-INF
-------------face-config.xml
-------------web.xhtml
----------start.xhtml
-----------include.xhtml
----libs (containing all JSF required Jars)

The structure of the second bundle is as follows:

bundle2
---src/main/java
------de/package
----------Bean.java
---src/main/resource
------META-INF
---------face-config.xml
------WebContent
---------index.xhtml

When running the application of equinox, the bundle1 is the main bundle where all the browser requests are sent to. In the second bundle, the index.xhtml file can be retrieved the by first bundle upon request. The index.xhtml in bundle 2 gets its values and properties from the 'Bean.java' in bundle 2. The problem comes when i request the 'index.xhtml', the Bean.java class is not found. I think this is because the class loader of bundle1 cannot find it, it has no knowledge of it. So i would like to ask if anyone knows how to solve this problem. If so please do assist me, i have tried all the possibilities i had..

Is it in fact possible to have JSF run on multiple bundles using the same FaceletsContex? Can i be able to have seperate faces-config.xml files in each bundle, which can all be connected other faces-config.xml in other bundles? Can anyone please provide me a solution. Sample code would help.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

┾廆蒐ゝ 2024-08-31 15:06:09

如果有人对答案感兴趣,在这种情况下,faces-config.xml 是没有用的。所以我必须使用plug-in.xml 文件来注册所有插件项目中的所有bean。我在主插件中创建了一个扩展点,其他插件可以将其 Bean 注册为扩展。我必须重写 JSF 的 ManagedBean 类,以便它能够从扩展点而不是从 faces-config.xml 读取 bean 属性。
因此,在运行时,应用程序会读取在 ManagedBeans 扩展点中注册的所有扩展,然后从所有插件创建所有必需的 bean 实例。因此,错误将不再存在。如果有人想以这种结构实现 JSF,您应该知道 faces-config.xml 中的几乎所有功能都必须移动到插件的plugin.xml 中,这也包括导航规则。人们必须进行大量的定制,但最终,您会得到一个在 equinox 上运行的漂亮的模块化 JSF 应用程序,而无需将其嵌入到 .WAR 文件中......这似乎非常有利。

If any one is interested in the answer, in this case, the faces-config.xml is of no use. So i had to use the plug-in.xml file to register all my beans across all plug-in projects. I created an extension point in the main plug-in, which other plug-ins could register their Beans as extension. I had to override the managedBean class of JSF for it to be able to read the bean properties from extension point rather than from the faces-config.xml.
So during runtime, the application reads all extensions registered in the managedBeans extension point, and then creates all the required bean instances from all plug-ins. Therefore the error will no longer be there. If anyone wants to implement JSF in such a structure, you should know that almost all the functionality in the faces-config.xml will have to be moved to the plug-in.xml of the plug-ins, this includes the navigation rules aswell. One has to do alot of customizations but at the end, you get a nice modular JSF application running on equinox, without having to embed it in a .WAR file.. which seems to be very advantageoous.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文