JSF 2 ManagedProperty injection of bean from dependency jar
I'm trying to get a ManagedProperty injection working, where the injected bean resides in a jar included in my web application.
Bean to be injected:
@ManagedBean(name="messages")
@SessionScoped
public class Messages implements Serializable
{
Receiving bean:
@ManagedPrope开发者_JAVA百科rty(value="#{messages}")
private Messages messages;
public void setMessages(Messages messages)
{
this.messages = messages;
}
However, this doesn't work and I'm just getting the message "Unable to set property messages for managed bean". If I put the Messages class in the same package as the receiving bean instead of having it in it's own jar, it works just fine.
The JAR must contain a JSF 2.0 compliant /META-INF/faces-config.xml
file to trigger JSF 2.0 annotation scans in JAR files.
<?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>
精彩评论