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

夙愿已清 提交于 2019-11-30 11:39:08

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.

nettie

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!