2
votes

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

1
Is the managed bean in the ejb jar, or in a jar in the ear's /lib directory?Mike Braun
Mike - The managed bean is in the ejb jar.user1575148
I think this is your problem then. The EJB archive should not contain any references to web artifacts. That's pretty much the entire idea behind those layers. If for some reason you need EJB services in your backing bean, pull it in to the war. Don't push the backing bean into the EJB jar.Mike Braun

1 Answers

1
votes

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.