0 Replies Latest reply on Sep 17, 2013 9:37 AM by Jonatan Jönsson

    NoSuchElementException when using @Decorator and @Delegate without @Inject

    Jonatan Jönsson Newbie

      I tried to use @Decorator and @Delegate like this:

       

      @Decorator

      public class DecoratedThing implements MyThing {

       

          private @Delegate MyThing myThing;

       

           @Override

          public String getMyThing() {

              return myThing.getMyThing() + " decorated";

          }

      }

       

      and got:

       

      15:08:13,406 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-8) MSC00001: Failed to start service jboss.deployment.unit."simple-servlet.war".WeldService: org.jboss.msc.service.StartException in service jboss.deployment.unit."simple-servlet.war".WeldService: java.util.NoSuchElementException

              at org.jboss.as.weld.services.WeldService.start(WeldService.java:83)

              at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]

              at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]

              at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_25]

              at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_25]

              at java.lang.Thread.run(Thread.java:724) [rt.jar:1.7.0_25]

      Caused by: java.util.NoSuchElementException

              at java.util.ArrayList$Itr.next(ArrayList.java:794) [rt.jar:1.7.0_25]

              at org.jboss.weld.bean.DecoratorImpl.initDelegateInjectionPoint(DecoratorImpl.java:124)

              at org.jboss.weld.bean.DecoratorImpl.initialize(DecoratorImpl.java:106)

              at org.jboss.weld.bootstrap.AbstractBeanDeployer.deploySpecialized(AbstractBeanDeployer.java:98)

              at org.jboss.weld.bootstrap.BeanDeployment.deploySpecialized(BeanDeployment.java:198)

              at org.jboss.weld.bootstrap.WeldBootstrap.deployBeans(WeldBootstrap.java:339)

              at org.jboss.as.weld.WeldContainer.start(WeldContainer.java:82)

              at org.jboss.as.weld.services.WeldService.start(WeldService.java:76)

              ... 5 more

       

      Which is, IMHO, a rather bad message for telling me that I'm missing an @Inject annotation. I'd expect something like "Failed to inject delegate" or something similar. Btw, why isn't @Inject assumed when @Delegate is used?

       

      I'm using JBoss 7.1.1.