[英]How to connect JSF page in war file to managed bean in jar file in Enterprise Application
My JSF Java Enterprise application is not able to reach the backing bean; 我的JSF Java Enterprise应用程序无法访问支持bean。 the error message being - 错误消息是-
/master/currency/addCurrency.xhtml @19,94 value="#{addCurrencyController.code}": Target Unreachable, identifier 'addCurrencyController' resolved to null
I have scanned previous question here, and the solution (question #7663818) is to have a blank faces-config.xml in META-INF folder of the jar file. 我在这里扫描了上一个问题,解决方案(问题#7663818)是在jar文件的META-INF文件夹中包含一个空白的faces-config.xml。 In that case, the jar file was part of the war file. 在这种情况下,jar文件是war文件的一部分。 I am not able to make it work as my xhtml is in war, the AddCurrencyController request-scoped managed bean is in jar and both are packaged in an ear. 我无法使它正常工作,因为我的xhtml处于战争状态,AddCurrencyController请求范围的托管Bean在jar中,并且都包装在耳朵中。
My application.xml is Maven generated and is given below. 我的application.xml是Maven生成的,下面给出。
<?xml version="1.0" encoding="UTF-8"?>
<application xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/application_6.xsd" version="6">
<display-name>ruwi-app</display-name>
<module>
<web>
<web-uri>ruwi-web-1.0.war</web-uri>
<context-root>/ruwi</context-root>
</web>
</module>
<module>
<ejb>ruwi-ejb-1.0.jar</ejb>
</module>
<library-directory>lib</library-directory>
</application>
I'm using Netbeans 7.3 Beta 2 IDE, server is the bundled GlassFish. 我正在使用Netbeans 7.3 Beta 2 IDE,服务器是捆绑的GlassFish。
Thanks 谢谢
-- MH -MH
It works only if the JAR containing the managed bean is in WAR's /WEB-INF/lib
folder (and thus not when the JAR is in EAR's /lib
!) and that the JAR has a JSF 2.0 compatible /META-INF/faces-config.xml
(and thus not a blank one!) 仅当包含受管bean的JAR位于WAR的/WEB-INF/lib
文件夹中(因此,而当JAR位于EAR的/lib
时则无效),并且JAR具有与JSF 2.0兼容的/META-INF/faces-config.xml
(因此不是空白!)
<?xml version="1.0" encoding="UTF-8"?>
<faces-config
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd"
version="2.0">
</faces-config>
You should also ensure that your webapp's /WEB-INF/faces-config.xml
does not have the metadata-complete="true"
attribute set. 您还应该确保您的/WEB-INF/faces-config.xml
应用程序的/WEB-INF/faces-config.xml
中没有设置/WEB-INF/faces-config.xml
metadata-complete="true"
属性。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.