I have two web jsf projects which potentially could share some classes and beans, to reduce code duplicates.
One is a potential JNDI-ServiceLocator application scoped Bean. (Both web projects access RemoteBeans from same Host)
JNDI - ServiceLocator Bean:
@ManagedBean(name = "jndiServiceLocatorBean")
@ApplicationScoped
public class JndiServiceLocatorBean implements Serializable
{
// code to cache jndi references
}
Abstract class with Bean as ManagedProperty:
public abstract class AJndiServiceLocator
{
@ManagedProperty(value = "#{jndiServiceLocatorBean}")
protected JndiServiceLocatorBean jndiServiceLocatorBean = null;
public void setJndiServiceLocatorBean(final JndiServiceLocatorBean jndiServiceLocatorBean)
{
this.jndiServiceLocatorBean = jndiServiceLocatorBean;
}
}
Example Bean from one of the projects:
@ManagedBean(name = "testBean")
@ApplicationScoped
public class TestBean extends AJndiServiceLocator implements Serializable
{
// bean code - can now retrieve remote bean interfaces
// from super class
}
This code works as expected if the first classes JndiServiceLocatorBean
and AJndiServiceLocator
are in the source folder of the project.
But it does not works if I outsource those two classes into a subproject that is shared between both web projects. (Included on build path and marked as deployment entry.)
Injection Exception that occurs:
Schwerwiegend: Error Rendering View[/index.xhtml]
com.sun.faces.mgbean.ManagedBeanCreationException: Bei der Ressourcen-Einspeisung auf dem verwalteten Bean appBean ist ein Fehler aufgetreten.
at com.sun.faces.mgbean.BeanBuilder.invokePostConstruct(BeanBuilder.java:229)
at com.sun.faces.mgbean.BeanBuilder.build(BeanBuilder.java:105)
at com.sun.faces.mgbean.BeanManager.createAndPush(BeanManager.java:409)
at com.sun.faces.mgbean.BeanManager.create(BeanManager.java:269)
at com.sun.faces.el.ManagedBeanELResolver.resolveBean(ManagedBeanELResolver.java:244)
at com.sun.faces.el.ManagedBeanELResolver.getValue(ManagedBeanELResolver.java:116)
at com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.java:176)
at com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:203)