You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openwebbeans.apache.org by "Markus Frisch (JIRA)" <ji...@apache.org> on 2014/05/13 16:53:15 UTC

[jira] [Created] (OWB-956) DefinitionException when iterateing over instance of org.apache.webbeans.inject.instance.InstanceImpl

Markus Frisch created OWB-956:
---------------------------------

             Summary: DefinitionException when iterateing over instance of org.apache.webbeans.inject.instance.InstanceImpl 
                 Key: OWB-956
                 URL: https://issues.apache.org/jira/browse/OWB-956
             Project: OpenWebBeans
          Issue Type: Bug
            Reporter: Markus Frisch


I get a DefinitionException when trying to iterate over an instance of org.apache.webbeans.inject.instance.InstanceImpl in the current snapshot of TomEE+ (i.e. in own 1.2.4).

What I am trying to do is:

————————8<————————>8————————
@Stateless
public class JobOperator {

    @Inject
    private Instance<MyBatchJob> batchJobs;

…

    private MyBatchJob findMatchingJob(String jobName) {
        MyBatchJob batchJob = null;
        for (MyBatchJob job : batchJobs) {
            if (job.getName().equalsIgnoreCase(jobName)) {
                batchJob = job;
                break;
            }
        }
        if (batchJob == null)
            throw new RuntimeException("There ain’t no Job named '" + jobName + "'.");
        return batchJob;
    }
————————8<————————>8————————
MyBatchJob is a common interface implemented by all my BatchJobs.

When this code is running I get the following Exception:

————————8<————————>8————————
org.apache.webbeans.exception.inject.DefinitionException: Unsupported type null
	at org.apache.webbeans.util.ClassUtil.getClazz(ClassUtil.java:950)
	at org.apache.webbeans.container.BeanManagerImpl.getEjbOrJmsProxyReference(BeanManagerImpl.java:804)
	at org.apache.webbeans.container.BeanManagerImpl.getReference(BeanManagerImpl.java:740)
	at org.apache.webbeans.inject.instance.InstanceImpl.iterator(InstanceImpl.java:270)
	at de.nobiscum.rs7030.batch.boundary.JobOperator.findMatchingJob(JobOperator.java:162)
————————8<————————>8————————

I took a look at org.apache.webbeans.inject.instance.InstanceImpl<T> and found the following:

————————8<————————>8————————
    public Iterator<T> iterator()
    {
        Set<Bean<?>> beans = resolveBeans();
        List<T> instances = new ArrayList<T>();
        parentCreationalContext.putInjectionPoint(injectionPoint);
        try
        {
            for(Bean<?> bean : beans)
            {
                T instance = (T) webBeansContext.getBeanManagerImpl().getReference(bean,null, parentCreationalContext);
————————8<————————>8————————

It looks like this function is passing null as the beanType to getReference() which in gets handed down to ClassUtil.getClazz() which chokes on that.




--
This message was sent by Atlassian JIRA
(v6.2#6252)