com.sun.faces.mgbean.ManagedBeanCreationException: An error occurred performing resource injection on managed bean

后端 未结 2 1244
予麋鹿
予麋鹿 2021-01-02 00:03

I have a JSF managedbean

I am getting the error when a managed bean is referred from from JSF page in WebSphere AppServer.



        
相关标签:
2条回答
  • 2021-01-02 00:39

    I recently got a similar error on a Java EE 6/JSF application running on Weblogic 12c.

    Whenever I try to edit the JSF backing bean, "UsersController", and then rebuild using maven, I would get this:

    com.sun.faces.mgbean.ManagedBeanCreationException: An error occurred performing resource injection on managed bean usersController
        at com.sun.faces.mgbean.BeanBuilder.injectResources(BeanBuilder.java:211)
        at com.sun.faces.mgbean.BeanBuilder.build(BeanBuilder.java:103)
        at com.sun.faces.mgbean.BeanManager.createAndPush(BeanManager.java:408)
    
    ...
    
    weblogic.servlet.internal.WebComponentContributor.inject(WebComponentContributor.java:299)
        at com.bea.faces.WeblogicInjectionProvider.inject(WeblogicInjectionProvider.java:29)
        ... 62 more
    **Caused by**: com.bea.core.repackaged.springframework.beans.factory.NoSuchBeanDefinitionException: No unique bean of type [jpa.session.UsersFacade] is defined: No beans of type jpa.session.UsersFacade; 
    

    My solution was this: After building the application in Netbeans, I had to go into the Weblogic console and update the web application. That seemed to eliminate the error.

    I've posted the symptoms and the cure. If anyone knows the "why" to this problem, feel free to chime in.

    0 讨论(0)
  • 2021-01-02 00:49

    com.sun.faces.mgbean.ManagedBeanCreationException: An error occurred performing resource injection on managed bean

    This exception just means that the managed bean creation has failed because an error occurred during resource injection of the managed bean. Oh wait, that is what the exception is already telling.

    Well, imagine that you've a @Resource, @EJB, ManagedProperty, etc annotation on the bean which is to be injected during bean's construction. When an exception occurs during construction of that resource, then you will get this exception.

    However, at the bottom of the stacktrace you should find the details of the cause of the exception which occurred during creation of that resource. Fix that cause accordingly and it should work properly.


    Update: finally, here is the answer, the bottommost part of the trace:

    Caused by: java.lang.NullPointerException
         at java.lang.String.valueOf(String.java:1511)
         at com.ibm.ws.webcontainer.annotation.WASAnnotationHelper.inject(WASAnnotationHelper.java:261)
         at com.ibm.ws.webcontainer.annotation.WASAnnotationHelper.inject(WASAnnotationHelper.java:248)
         at com.sun.faces.vendor.WebSphereInjectionProvider.inject(WebSphereInjectionProvider.java:49)
         ... 169 more
    

    This is clearly a bug in com.ibm.ws.webcontainer.annotation.WASAnnotationHelper class. This is however outside your control, so you need to consult IBM for the fix. Digging in Google gives some hits on this exception, among others an official IBM bug report. You can download fix packs here.

    0 讨论(0)
提交回复
热议问题