[weld-issues] [JBoss JIRA] Work started: (WELD-632) EMF Resource declaration in a static producer field of a Singleton EJB results in a null instance exception

Pete Muir (JIRA) jira-events at lists.jboss.org
Mon Aug 23 18:00:12 EDT 2010


     [ https://jira.jboss.org/browse/WELD-632?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Work on WELD-632 started by Pete Muir.

> EMF Resource declaration in a static producer field of a Singleton EJB results in a null instance exception
> -----------------------------------------------------------------------------------------------------------
>
>                 Key: WELD-632
>                 URL: https://jira.jboss.org/browse/WELD-632
>             Project: Weld
>          Issue Type: Bug
>          Components: Producers (Methods, Fields and Disposers)
>    Affects Versions: 1.0.1.Final
>         Environment: GlassFish 3.1-trunk (integrates 1.1.0-01-glassfish branch of weld)
>            Reporter: Sivakumar Thyagarajan
>            Assignee: Pete Muir
>             Fix For: 1.1.0.BETA1
>
>         Attachments: beans-related-to-weld-632.tar
>
>
> I have a developer test that thests the following scenario:
> - Injection of an EMF into a Servlet. This EMF is produced through a producer field in a Singleton EJB in that war.
> If the resource(JPA EMF) is declared by making a static field in a singleton EJB as a  producer field [1] 
> and this EMF is injected in a servlet in the war, a null instance exception when the injected reference to the EMF is used [2].
> I have attached the relevant beans with this bug report. 
> [1]
> A sample bean and a test case to reproduce is at https://svn.dev.java.net/svn/glassfish-svn/trunk/v2/appserv-tests/devtests/cdi/javaee-component-resources/jpa-resource-injection-with-singleton-ejb-producer/ 
> Bean snippet:
> > @javax.ejb.Singleton
> > public class JPAResourceProducerSingletonEJB_StaticField {
> >    @Produces @PersistenceUnit(unitName="pu1") @ProducedViaStaticField
> >    public static EntityManagerFactory customerDatabasePersistenceUnit1;
> > }
> > 
> > and I inject this EMF in the servlet as
> >    @Inject
> >    @ProducedViaStaticField
> >    private EntityManagerFactory emf_static;
> > 
> > 
> > [2]
> > ---- server log snippet ----
> > [#|2010-08-20T15:53:52.613+0530|WARNING|glassfish3.1|javax.enterprise.system.container.web.com.sun.enterprise.web|_ThreadID=14;_ThreadName=Thread-1;|StandardWrapperValve[mytest]: PWC1406: Servlet.service() for servlet mytest threw exception
> > org.jboss.weld.exceptions.NullInstanceException: WELD-000044 Unable to obtain instance from org.jboss.weld.bean-/export/work/workspaces/gfv3/v3/distributions/glassfish/target/stage/glassfishv3/glassfish/domains/domain1/applications/cdi-jpa-resource-injection-in-singleton-ejb-web/-ProducerField-test.ejb.JPAResourceProducerSingletonEJB_StaticField.customerDatabasePersistenceUnit1
> >    at org.jboss.weld.bean.builtin.CallableMethodHandler.invoke(CallableMethodHandler.java:55)
> >    at org.jboss.weld.bean.proxy.EnterpriseTargetBeanInstance.invoke(EnterpriseTargetBeanInstance.java:62)
> >    at org.jboss.weldx.persistence.EntityManagerFactory_$$_WeldProxy.toString(EntityManagerFactory_$$_WeldProxy.java)
> >    at java.lang.String.valueOf(String.java:2826)
> >    at java.lang.StringBuilder.append(StringBuilder.java:115)
> >    at test.servlet.JPAResourceInjectionServletFromSingletonEJB.doGet(JPAResourceInjectionServletFromSingletonEJB.java:105)
> > ---- server log snippet ---

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

        


More information about the weld-issues mailing list