This discussion is archived
5 Replies Latest reply: Dec 24, 2012 1:19 AM by gimbal2 RSS

Dependency injection nightmare

800701 Newbie
Currently Being Moderated
I can't get it what is wrong...given this faces-config.xml
<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_1_2.xsd"
     version="1.2">
     <application>
          <view-handler>com.icesoft.faces.facelets.D2DFaceletViewHandler</view-handler>
          ...
     </application>
     <managed-bean>
          <managed-bean-name>persistenceManager</managed-bean-name>
          <managed-bean-class>ro.sinoptix.controller.PersistenceManager</managed-bean-class>
          <managed-bean-scope>application</managed-bean-scope>
     </managed-bean>
     <managed-bean>
          <managed-bean-name>tipCerereCtrl</managed-bean-name>
          <managed-bean-class>ro.sinoptix.controller.TipCerereCtrl</managed-bean-class>
          <managed-bean-scope>session</managed-bean-scope>
          <managed-property>
               <property-name>persistenceManager</property-name>
               <property-class>ro.sinoptix.controller.PersistenceManager</property-class>
               <value>#{persistenceManager}</value>
          </managed-property>
     </managed-bean>
...
     <managed-bean>
          <description>tine pagina TipuriCerere</description>
          <managed-bean-name>tipuriCerere</managed-bean-name>
          <managed-bean-class>ro.sinoptix.view.TipuriCerere</managed-bean-class>
          <managed-bean-scope>request</managed-bean-scope>
          <managed-property>
               <property-name>tcl</property-name>
               <property-class>ro.sinoptix.controller.TipCerereCtrl</property-class>
               <value>#{tipCerereCtrl}</value>
          </managed-property>
     </managed-bean>

</faces-config>
i get this error
SEVERE: JSF1054: (Phase ID: RENDER_RESPONSE 6, View ID: /TipuriCerere.xhtml) Exception thrown during phase execution: javax.faces.event.PhaseEvent[source=com.sun.faces.lifecycle.LifecycleImpl@7a36a2]
SEVERE: Exception occured during rendering on http://localhost:8080/SOConfigManager/TipuriCerere.jsf [/TipuriCerere.xhtml]
javax.faces.FacesException: Problem in renderResponse: com.sun.faces.mgbean.ManagedBeanPreProcessingException: Unexpected error processing managed bean tipuriCerere
Caused by: com.sun.faces.mgbean.ManagedBeanPreProcessingException: Unexpected error processing managed bean tipuriCerere
     at com.sun.faces.mgbean.BeanManager.preProcessBean(BeanManager.java:356)
     at com.sun.faces.mgbean.BeanManager.create(BeanManager.java:201)
     at com.sun.faces.el.ManagedBeanELResolver.getValue(ManagedBeanELResolver.java:86)
     at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:54)
     at com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:72)
     at org.apache.el.parser.AstIdentifier.getValue(AstIdentifier.java:61)
     at org.apache.el.parser.AstValue.getValue(AstValue.java:107)
     at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186)
     at com.sun.facelets.el.TagValueExpression.getValue(TagValueExpression.java:71)
     at javax.faces.component.UIData.getValue(UIData.java:609)
     at com.icesoft.faces.component.panelseries.UISeries.getValue(UISeries.java:572)
     ... 65 more
Caused by: com.sun.faces.mgbean.ManagedBeanPreProcessingException: Unexpected error processing managed property tcl
     at com.sun.faces.mgbean.ManagedBeanBuilder.bake(ManagedBeanBuilder.java:117)
     at com.sun.faces.mgbean.BeanManager.preProcessBean(BeanManager.java:311)
     ... 75 more
Caused by: java.lang.NullPointerException
     at com.sun.faces.mgbean.ManagedBeanBuilder.bakeBeanProperty(ManagedBeanBuilder.java:350)
     at com.sun.faces.mgbean.ManagedBeanBuilder.bake(ManagedBeanBuilder.java:107)
     ... 76 more
i cant figure out what is wrong ... my classes are
public class TipuriCerere {

     // dependency injection
     private TipCerereCtrl tcl;

        public TipCerereCtrl getTcl() {
          return tcl;
     }
}
public class TipCerereCtrl {
     private PersistenceManager persistenceManager;

     public PersistenceManager getPersistenceManager() {
          return persistenceManager;
     }
...
}
Any help is valueble to me

Edited by: kquizak on Jan 8, 2010 1:54 AM
  • 1. Re: Dependency injection nightmare
    800701 Newbie
    Currently Being Moderated
    [SOLVED]... i was missing the setters in my classes
  • 2. Re: Dependency injection nightmare
    gimbal2 Guru
    Currently Being Moderated
    hm, you miss a setter and that results in a NullPointerException. I'd suspect that this is some missing error handling in JSF, and thus could be considered a bug... Anybody else have an opinion about this?
  • 3. Re: Dependency injection nightmare
    r035198x Pro
    Currently Being Moderated
    gimbal2 wrote:
    .... Anybody else have an opinion about this?
    Definitely odd. Would have expected something like property not accessible.
    What JSF implementation and version is this?
  • 4. Re: Dependency injection nightmare
    jmsjr Newbie
    Currently Being Moderated
    r035198x wrote:
    gimbal2 wrote:
    .... Anybody else have an opinion about this?
    Definitely odd. Would have expected something like property not accessible.
    What JSF implementation and version is this?
    I just had this happen to me as well today. Added a ManagedProperty to a ViewScoped bean, like so:
         @ManagedProperty(value="#{actionStateMachine}")
         private ActionStateMachine     actionStateMachine;
    .. and only provided a getter, no setter, ... and I got the same exception shown by the OP.
    After I added a setter, the exception does not happen.

    Environment:
    JBoss 7.1.1
    Mojarra 2.1.7-jbossorg-1 (20120227-1401)
  • 5. Re: Dependency injection nightmare
    gimbal2 Guru
    Currently Being Moderated
    Great, but you're:

    - resurrecting a very old thread that was on JSF 1.2, not JSF 2.1 (two different products)
    - reporting a bug where it won't help anyone. Report it to the JSF jira in stead so it will be seen by people who can fix it.

    Note that it should be the other way around; you can get away with only providing a setter for injected resources. I wish you didn't have to provide any though :/