[weld-issues] [JBoss JIRA] Assigned: (WELD-471) Weld SE, Instance<> and @New - NPE

Nicklas Karlsson (JIRA) jira-events at lists.jboss.org
Wed Mar 24 17:26:43 EDT 2010


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

Nicklas Karlsson reassigned WELD-471:
-------------------------------------

    Assignee: Nicklas Karlsson


> Weld SE, Instance<> and @New - NPE
> ----------------------------------
>
>                 Key: WELD-471
>                 URL: https://jira.jboss.org/jira/browse/WELD-471
>             Project: Weld
>          Issue Type: Bug
>          Components: Built-in beans
>    Affects Versions: 1.0.1.Final
>            Reporter: Wujek Srujek
>            Assignee: Nicklas Karlsson
>            Priority: Minor
>
> For a bean:
> @ApplicationScoped
> public class SomeBean {
>     private double d = Math.random();
>     public double getD() {
>         return d;
>     }
> }
> and an injection point:
> @Inject
> @New
> private Instance<SomeBean> i;
> and when I start Weld SE I get:
> Exception in thread "main" java.lang.NullPointerException
>  at org.jboss.weld.util.Beans.getInitializerMethods(Beans.java:395)
>  at org.jboss.weld.bean.AbstractClassBean.initInitializerMethods(AbstractClassBean.java:252)
>  at org.jboss.weld.bean.AbstractClassBean.<init>(AbstractClassBean.java:164)
>  at org.jboss.weld.bean.ManagedBean.<init>(ManagedBean.java:317)
>  at org.jboss.weld.bean.NewManagedBean.<init>(NewManagedBean.java:66)
>  at org.jboss.weld.bean.NewManagedBean.of(NewManagedBean.java:48)
>  at org.jboss.weld.bootstrap.AbstractBeanDeployer.createNewManagedBean(AbstractBeanDeployer.java:244)
>  at org.jboss.weld.bootstrap.BeanDeployer.createBeans(BeanDeployer.java:124)
>  at org.jboss.weld.bootstrap.BeanDeployment.deployBeans(BeanDeployment.java:151)
>  at org.jboss.weld.bootstrap.WeldBootstrap.deployBeans(WeldBootstrap.java:377)
>  at org.jboss.weld.environment.se.Weld.initialize(Weld.java:79)
>  at org.jboss.weld.environment.se.StartMain.go(StartMain.java:45)
>  at test.Test.main(Test.java:10)
> When I specify @New.value:
> @Inject
> @New(SomeBean.class)
> private Instance<SomeBean> i;
> it works. The exception is thrown from within Weld core somewhere. According to the API, @New.value is optional and "defaults the value to the declared type of the injection point", and for Instance, "the required type is the type parameter specified at the injection point". So I think it should be able to take the type parameter and not result in an error. Not sure about this.
> Anyways, NPE should be changed to some more descriptive and friendly exception, describing what is wrong.
> Please see the forum topic: http://seamframework.org/Community/WeldSEInstanceAndNewNPE

-- 
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