6 Replies Latest reply on Aug 6, 2014 3:09 AM by Harald Wellmann

    Concurrency issues

    Harald Wellmann Novice

      My application sporadically fails to deploy with Weld complaining about "unsatisfied dependencies". After two or three retries the error is gone.

       

      I don't see this behaviour when setting the system property concurrentDeployment = true.

       

      Now my question is, what does concurrent deployment really mean? What is a likely cause for the errors I'm seeing, and what would be a strategy for isolating the issue?

       

      Regards,

      Harald

        • 1. Re: Concurrency issues
          Martin Kouba Master

          Hi Harald,

          it means that the Weld is processing some of the deployment tasks in parallel (e.g. loading annotated types, creation and validation of beans). However, the different types of tasks do not overlap (this is clearly defined by the spec), i.e. all annotated types are loaded first, then all beans are registered. If the deployment fails randomly due to "unsatisfied dependencies", there is probably something which makes the deployment nondeterministic (e.g. the dependency is a bean created conditionally by some extension).

           

          As to strategy - I would inspect the failing dependency first (what's the required type/target bean, from which bean archive, etc.).

           

          Also what environment/container do you use?

          • 2. Re: Re: Concurrency issues
            Harald Wellmann Novice

            I'm using WildFly 8.1.0.Final.

             

            The injection target and the missing dependency are both in the same BDA, the target is an EJB, the "missing" dependency comes from a producer method, roughly like this:

             

            @Stateless
            public class FooServiceClient {
            
                @Inject
                @Foo
                private Client client;
            }
            
            @ApplicationScoped
            public class FooClientProducer {
            
                @Produces
                @Foo
                @ApplicationScoped
                Client fooClient(FooClientRequestTransformer requestTransformer) {
            
                    ResteasyClient client = new ResteasyClientBuilder().connectionPoolSize(20).build();
                    client.register(requestTransformer);
                    return client;
                }
            }
            

            Looks rather harmless, I think. Correct me if I'm wrong...

            • 3. Re: Re: Concurrency issues
              Martin Kouba Master

              Yep, this looks correct. So the unsatisfied injection point is FooServiceClient#client, right? I suppose there are no alternatives or specializing beans in game. If possible, please post the full stack trace...

              • 4. Re: Re: Re: Concurrency issues
                Harald Wellmann Novice

                Yes, that's the one. And here's the stacktrace, if it helps:

                 

                 

                Caused by: org.jboss.weld.exceptions.DeploymentException: WELD-001408: Unsatisfied dependencies for type Client with qualifiers @Foo
                  at injection point [BackedAnnotatedField] @Inject @Foo private com.example.FooServiceClient.client
                  at com.example.FooServiceClient.client(FooServiceClient.java:0)
                
                        at org.jboss.weld.bootstrap.Validator.validateInjectionPointForDeploymentProblems(Validator.java:368)
                        at org.jboss.weld.bootstrap.Validator.validateInjectionPoint(Validator.java:289)
                        at org.jboss.weld.bootstrap.Validator.validateGeneralBean(Validator.java:135)
                        at org.jboss.weld.bootstrap.Validator.validateRIBean(Validator.java:166)
                        at org.jboss.weld.bootstrap.Validator.validateBean(Validator.java:514)
                        at org.jboss.weld.bootstrap.ConcurrentValidator$1.doWork(ConcurrentValidator.java:68)
                        at org.jboss.weld.bootstrap.ConcurrentValidator$1.doWork(ConcurrentValidator.java:66)
                        at org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:60)
                        at org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:53)
                        at java.util.concurrent.FutureTask.run(FutureTask.java:266) [rt.jar:1.8.0]
                        ... 3 more
                
                • 5. Re: Re: Re: Concurrency issues
                  Martin Kouba Master

                  Ok, could you try to enable the debug logging for Weld (see http://weld.cdi-spec.org/documentation/#7) and verify that the producer method is registered correctly (you should see something like "Bean: Producer Method [Client] with qualifiers [@Any @Foo]..." before "Weld initialized. Validating beans" message) when the deployment fails.

                  • 6. Re: Re: Re: Re: Concurrency issues
                    Harald Wellmann Novice

                    Took some for the bug to occur again, but here it is, this time with debug output, see below. The "duplicate class" is the argument to the producer method.

                     

                    2014-08-06 08:57:56,808 INFO [org.jboss.weld.Bootstrap] (weld-worker-4) WELD-000119: Not generating any bean definitions from com.example.FooClientProducer because of underlying class loading error: Type [unknown] not found. If this is unexpected, enable DEBUG logging to see the full error.
                    2014-08-06 08:57:56,809 DEBUG [org.jboss.weld.Bootstrap] (weld-worker-4) Catching: org.jboss.weld.resources.spi.ResourceLoadingException: Error while loading class com.example.FooClientProducer
                    at org.jboss.weld.resources.ClassTransformer.getBackedAnnotatedType(ClassTransformer.java:186) [weld-core-impl-2.1.2.Final.jar:2014-01-09 09:23]
                    at org.jboss.weld.resources.ClassTransformer.getBackedAnnotatedType(ClassTransformer.java:194) [weld-core-impl-2.1.2.Final.jar:2014-01-09 09:23]
                    at org.jboss.weld.bootstrap.BeanDeployer.loadAnnotatedType(BeanDeployer.java:119) [weld-core-impl-2.1.2.Final.jar:2014-01-09 09:23]
                    at org.jboss.weld.bootstrap.BeanDeployer.addClass(BeanDeployer.java:96) [weld-core-impl-2.1.2.Final.jar:2014-01-09 09:23]
                    at org.jboss.weld.bootstrap.ConcurrentBeanDeployer$1.doWork(ConcurrentBeanDeployer.java:62) [weld-core-impl-2.1.2.Final.jar:2014-01-09 09:23]
                    at org.jboss.weld.bootstrap.ConcurrentBeanDeployer$1.doWork(ConcurrentBeanDeployer.java:60) [weld-core-impl-2.1.2.Final.jar:2014-01-09 09:23]
                    at org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:60) [weld-core-impl-2.1.2.Final.jar:2014-01-09 09:23]
                    at org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:53) [weld-core-impl-2.1.2.Final.jar:2014-01-09 09:23]
                    at java.util.concurrent.FutureTask.run(FutureTask.java:266) [rt.jar:1.8.0_05]
                    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [rt.jar:1.8.0_05]
                    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [rt.jar:1.8.0_05]
                    at java.lang.Thread.run(Thread.java:745) [rt.jar:1.8.0_05]
                    Caused by: java.lang.LinkageError: loader (instance of org/jboss/modules/ModuleClassLoader): attempted duplicate class definition for name: "com/example/FooClientRequestTransformer"
                    at java.lang.Class.getDeclaredMethods0(Native Method) [rt.jar:1.8.0_05]
                    at java.lang.Class.privateGetDeclaredMethods(Class.java:2688) [rt.jar:1.8.0_05]
                    at java.lang.Class.getDeclaredMethods(Class.java:1962) [rt.jar:1.8.0_05]
                    at org.jboss.weld.security.GetDeclaredMethodsAction.run(GetDeclaredMethodsAction.java:30) [weld-core-impl-2.1.2.Final.jar:2014-01-09 09:23]
                    at org.jboss.weld.security.GetDeclaredMethodsAction.run(GetDeclaredMethodsAction.java:22) [weld-core-impl-2.1.2.Final.jar:2014-01-09 09:23]
                    at java.security.AccessController.doPrivileged(Native Method) [rt.jar:1.8.0_05]
                    at org.jboss.weld.annotated.slim.backed.BackedAnnotatedType$BackedAnnotatedMethods.computeValue(BackedAnnotatedType.java:192) [weld-core-impl-2.1.2.Final.jar:2014-01-09 09:23]
                    at org.jboss.weld.annotated.slim.backed.BackedAnnotatedType$BackedAnnotatedMethods.computeValue(BackedAnnotatedType.java:186) [weld-core-impl-2.1.2.Final.jar:2014-01-09 09:23]
                    at org.jboss.weld.util.LazyValueHolder.get(LazyValueHolder.java:35) [weld-core-impl-2.1.2.Final.jar:2014-01-09 09:23]
                    at org.jboss.weld.annotated.slim.backed.BackedAnnotatedType$EagerlyInitializedLazyValueHolder.<init>(BackedAnnotatedType.java:154) [weld-core-impl-2.1.2.Final.jar:2014-01-09 09:23]
                    at org.jboss.weld.annotated.slim.backed.BackedAnnotatedType$BackedAnnotatedMethods.<init>(BackedAnnotatedType.java:186) [weld-core-impl-2.1.2.Final.jar:2014-01-09 09:23]
                    at org.jboss.weld.annotated.slim.backed.BackedAnnotatedType$BackedAnnotatedMethods.<init>(BackedAnnotatedType.java:186) [weld-core-impl-2.1.2.Final.jar:2014-01-09 09:23]
                    at org.jboss.weld.annotated.slim.backed.BackedAnnotatedType.<init>(BackedAnnotatedType.java:66) [weld-core-impl-2.1.2.Final.jar:2014-01-09 09:23]
                    at org.jboss.weld.annotated.slim.backed.BackedAnnotatedType.of(BackedAnnotatedType.java:47) [weld-core-impl-2.1.2.Final.jar:2014-01-09 09:23]
                    at org.jboss.weld.resources.ClassTransformer$TransformClassToBackedAnnotatedType.load(ClassTransformer.java:83) [weld-core-impl-2.1.2.Final.jar:2014-01-09 09:23]
                    at org.jboss.weld.resources.ClassTransformer$TransformClassToBackedAnnotatedType.load(ClassTransformer.java:80) [weld-core-impl-2.1.2.Final.jar:2014-01-09 09:23]
                    at com.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3524)
                    at com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2317)
                    at com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2280)
                    at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2195)
                    at com.google.common.cache.LocalCache.get(LocalCache.java:3934)
                    at com.google.common.cache.LocalCache.getOrLoad(LocalCache.java:3938)
                    at com.google.common.cache.LocalCache$LocalLoadingCache.get(LocalCache.java:4821)
                    at org.jboss.weld.util.cache.LoadingCacheUtils.getCacheValue(LoadingCacheUtils.java:52) [weld-core-impl-2.1.2.Final.jar:2014-01-09 09:23]
                    at org.jboss.weld.util.cache.LoadingCacheUtils.getCastCacheValue(LoadingCacheUtils.java:80) [weld-core-impl-2.1.2.Final.jar:2014-01-09 09:23]
                    at org.jboss.weld.resources.ClassTransformer.getBackedAnnotatedType(ClassTransformer.java:175) [weld-core-impl-2.1.2.Final.jar:2014-01-09 09:23]
                    ... 11 more