user1575148
user1575148

Reputation: 589

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; 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. In that case, the jar file was part of the war file. 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.

My application.xml is Maven generated and is given below.

<?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.

Thanks

-- MH

Upvotes: 2

Views: 1953

Answers (1)

BalusC
BalusC

Reputation: 1109292

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!)

<?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.

Upvotes: 1

Related Questions