Uploaded image for project: 'Weld'
  1. Weld
  2. WELD-588

RunnableDecorator incorrectly assumes >0 Runnable beans

    Details

    • Type: Bug
    • Status: Resolved (View Workflow)
    • Priority: Major
    • Resolution: Won't Fix
    • Affects Version/s: 1.0.1.Final
    • Fix Version/s: TBC
    • Component/s: Java SE Support
    • Labels:
      None
    • Environment:
      Java 6 + WeldSE
    • Steps to Reproduce:
      Hide

      Not sure about a simple way, but in my case I got it when I tried to use WeldSE features inside a glassfish 3 web project (my unit tests inside the web project use WeldSE so in essense my web project can work as WAR in glassfish and as an app outside glassfish). I guess the mix of weld jars may cause this problem to surface? Problem seemed to go away if I added the dummy class as described in the workaround.

      Show
      Not sure about a simple way, but in my case I got it when I tried to use WeldSE features inside a glassfish 3 web project (my unit tests inside the web project use WeldSE so in essense my web project can work as WAR in glassfish and as an app outside glassfish). I guess the mix of weld jars may cause this problem to surface? Problem seemed to go away if I added the dummy class as described in the workaround.
    • Workaround Description:
      Hide

      As a workaround I declared this class in my app and it worked again:
      @Singleton
      public class DummyRunnable implements Runnable {
      @Override
      public void run() {}
      }}

      Show
      As a workaround I declared this class in my app and it worked again: @Singleton public class DummyRunnable implements Runnable { @Override public void run() {} }}

      Description

      The class org.jboss.weld.environment.se.threading.RunnableDecorator incorrectly assumes that there will be at least one bean that implements Runnable.

      If there are no beans that implements Runnable then an error like this will happen:
      org.jboss.weld.DeploymentException: Injection point has unstatisfied dependencies. Injection point: field org.jboss.weld.environment.se.threading.RunnableDecorator.runnable; Qualifiers: [@javax.enterprise.inject.Default()]
      at org.jboss.weld.Validator.validateInjectionPoint(Validator.java:232)
      at org.jboss.weld.Validator.validateBean(Validator.java:80)
      at org.jboss.weld.Validator.validateRIBean(Validator.java:100)
      at org.jboss.weld.Validator.validateBeans(Validator.java:282)
      at org.jboss.weld.Validator.validateDeployment(Validator.java:267)
      at org.jboss.weld.bootstrap.WeldBootstrap.validateBeans(WeldBootstrap.java:389)
      at org.jboss.weld.environment.se.Weld.initialize(Weld.java:81)
      at org.jboss.weld.environment.se.StartMain.go(StartMain.java:45)
      at org.jboss.weld.environment.se.StartMain.main(StartMain.java:57)

      I guess the field "runnable" inside this class should be changed to use Instance<Runnable> instead.

        Gliffy Diagrams

          Activity

          Hide
          peteroyle Peter Royle added a comment -

          Hi Morten,

          I like your suggestion to use Instance<Runnable>, and will likely end up taking that on board as an additional barrier against users experiencing this exception. However I first want to understand why you are experiencing this exception at all.

          In my experience, since RunnableDecorator is a decorator, then unless it is enabled as a decorator in beans.xml it shouldn't be a target for injection at all, unless you are instantiating it some other way. I've just done a test which demonstrates this, which I'll attach. Try running the project (most easily done in NetBeans since that's where it was created, but also possible from the command line with some maven building and manual classpath wizardry) with the decorator enabled versus commented out.

          I don't suppose you have the decorator enabled in your beans.xml?

          Are you causing RunnableDecorator to be instantiated any other way? Injecting it somewhere perhaps?

          Otherwise, what am I missing?

          Thanks for your feedback.

          Show
          peteroyle Peter Royle added a comment - Hi Morten, I like your suggestion to use Instance<Runnable>, and will likely end up taking that on board as an additional barrier against users experiencing this exception. However I first want to understand why you are experiencing this exception at all. In my experience, since RunnableDecorator is a decorator, then unless it is enabled as a decorator in beans.xml it shouldn't be a target for injection at all, unless you are instantiating it some other way. I've just done a test which demonstrates this, which I'll attach. Try running the project (most easily done in NetBeans since that's where it was created, but also possible from the command line with some maven building and manual classpath wizardry) with the decorator enabled versus commented out. I don't suppose you have the decorator enabled in your beans.xml? Are you causing RunnableDecorator to be instantiated any other way? Injecting it somewhere perhaps? Otherwise, what am I missing? Thanks for your feedback.
          Hide
          peteroyle Peter Royle added a comment -

          Demonstrates that without the decorator enabled, the unsatisfied dependency exception does not occur.

          Show
          peteroyle Peter Royle added a comment - Demonstrates that without the decorator enabled, the unsatisfied dependency exception does not occur.
          Hide
          mmc41 Morten Christensen added a comment -

          I did not have the decorator enabled in my beans.xml and I do use RunnableDecorator at all but I am using a lot of 3rd party jars and one of them might do something that causes this (see the recently logged bug about performance that I created - it lists the jars I use under java SE and it is mostly the same I use under java EE). Note also, that this bug only happens under glassfish in a WAR - it does not happen when I use Weld in a Java SE app.

          So I am sorry, I have no more idea then you why this happen but I am sure that you DO need to use Instance<Runnable> because even if you have the decorator enabled in beans.xml you should be able to handle the case where there are 0 Runnables.

          Show
          mmc41 Morten Christensen added a comment - I did not have the decorator enabled in my beans.xml and I do use RunnableDecorator at all but I am using a lot of 3rd party jars and one of them might do something that causes this (see the recently logged bug about performance that I created - it lists the jars I use under java SE and it is mostly the same I use under java EE). Note also, that this bug only happens under glassfish in a WAR - it does not happen when I use Weld in a Java SE app. So I am sorry, I have no more idea then you why this happen but I am sure that you DO need to use Instance<Runnable> because even if you have the decorator enabled in beans.xml you should be able to handle the case where there are 0 Runnables.
          Hide
          mmc41 Morten Christensen added a comment -

          correction: I did not have the decorator enabled in my beans.xml and I do NOT use RunnableDecorator at all ...

          Show
          mmc41 Morten Christensen added a comment - correction: I did not have the decorator enabled in my beans.xml and I do NOT use RunnableDecorator at all ...
          Hide
          logician Manuel Bernhardt added a comment -

          Hi,

          +1 on this issue. In my case this happens when I run a SE environment and also do have other Weld JARs on the classpath.

          It would come handy to have this working without the workaround. In my case I need to be able to run my application both inside a container and parts of it outside, in a SE environment. Arguably I could separate the JARs / define fitting classpaths, nonetheless a fix (or at least a notice in the doc saying that the weld-se.jar can't be used in combination with other Weld JARs on the classpath) would be nice to have.

          Thanks,

          Manuel

          Show
          logician Manuel Bernhardt added a comment - Hi, +1 on this issue. In my case this happens when I run a SE environment and also do have other Weld JARs on the classpath. It would come handy to have this working without the workaround. In my case I need to be able to run my application both inside a container and parts of it outside, in a SE environment. Arguably I could separate the JARs / define fitting classpaths, nonetheless a fix (or at least a notice in the doc saying that the weld-se.jar can't be used in combination with other Weld JARs on the classpath) would be nice to have. Thanks, Manuel
          Hide
          alesj Ales Justin added a comment -

          >> Demonstrates that without the decorator enabled, the unsatisfied dependency exception does not occur.

          With this, I don't see this as an issue.
          Can it be closed?

          Unless someone can come up with non-enabled RunnableDecorator test still resulting in error.

          Show
          alesj Ales Justin added a comment - >> Demonstrates that without the decorator enabled, the unsatisfied dependency exception does not occur. With this, I don't see this as an issue. Can it be closed? Unless someone can come up with non-enabled RunnableDecorator test still resulting in error.

            People

            • Assignee:
              Unassigned
              Reporter:
              mmc41 Morten Christensen
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development