[weld-issues] [JBoss JIRA] Created: (WELD-445) NullPointerException

Ian (JIRA) jira-events at lists.jboss.org
Thu Feb 18 19:49:10 EST 2010


NullPointerException 
---------------------

                 Key: WELD-445
                 URL: https://jira.jboss.org/jira/browse/WELD-445
             Project: Weld
          Issue Type: Bug
    Affects Versions: 1.0.1.CR2
         Environment: JBoss 6.0.0 M2 updated with Weld 1.0.1 CR2, Windows XP
            Reporter: Ian


I get a NullPointerException when trying to inject a logger into my code. It happens in two circumstances - once when injection is done by the container, once when I manually inject (using the SPI of course!).

The top of the stack trace is exactly the same in both instances:

java.lang.NullPointerException org.jboss.weld.util.Beans.isPassivatingScope(Beans.java:132) org.jboss.weld.bean.AbstractProducerBean.checkReturnValue(AbstractProducerBean.java:263) org.jboss.weld.bean.AbstractProducerBean.create(AbstractProducerBean.java:349) org.jboss.weld.context.DependentContext.get(DependentContext.java:62) org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:788) org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:850) org.jboss.weld.manager.BeanManagerImpl.getInjectableReference(BeanManagerImpl.java:874) org.jboss.weld.injection.FieldInjectionPoint.inject(FieldInjectionPoint.java:108) org.jboss.weld.util.Beans.injectBoundFields(Beans.java:775) org.jboss.weld.util.Beans.injectFieldsAndInitializers(Beans.java:787) org.jboss.weld.manager.SimpleInjectionTarget$1.proceed(SimpleInjectionTarget.java:122) org.jboss.weld.injection.InjectionContextImpl.run(InjectionContextImpl.java:51) org.jboss.weld.manager.SimpleInjectionTarget.inject(SimpleInjectionTarget.java:116) 

The code fragment for the item being injected is the following: (the logger is a log4j logger)

public class LoggingFactory {
    @Produces
    Logger createLogger(InjectionPoint injectionPoint) {
	return Logger.getLogger(injectionPoint.getMember().getDeclaringClass().getName());
    }
}

The servletContextListener code fragment is as follows:

public class ApplicationInitialisation
	implements ServletContextListener {

    @Inject
    private Logger log;

    /**
     * @see ServletContextListener#contextInitialized(ServletContextEvent)
     */
    public void contextInitialized(ServletContextEvent event) {
        // Never gets into the method because of the stack trace
    }




-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

       



More information about the weld-issues mailing list