WELD-001408 Unsatisfied dependencies for type ... with qualifiers [@Default] at injection point
Asked Answered
D

3

6

I got a stupid problem when deploying my Java Application on JBoss. Before I changed my source code using an interface class everything was fine. So here is my problem:

public interface FWInterface {
   public FWResult process(FWRequest fwRequest, FWResult fwResult,
                           Integer commitRows) throws Exception;
}

...

@Stateless
public class FWHandlerSqrMind extends FWHandlerDefault implements FWInterface {

   public FWResult process(FWRequest fwRequest, FWResult fwResult, Integer commitRows)
                   throws Exception {
                ... some JavaCode here
   }
}

This ends up with the following Error at deployment on JBoss 7.1:

10:05:34,838 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-6) MSC00001: Failed to start service jboss.deployment.unit."mdk-exchange-1.1.0.war".WeldService: org.jboss.msc.service.StartException in service jboss.deployment.unit."mdk-exchange-1.1.0.war".WeldService: org.jboss.weld.exceptions.DeploymentException: WELD-001408 Unsatisfied dependencies for type [FWHandlerAufTracking] with qualifiers [@Default] at injection point [[field] @Inject de.mdkbw.exchange.filewatcher.FWMain.fwhAufTracking] 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(Unknown Source) [rt.jar:1.7.0_15] at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [rt.jar:1.7.0_15] at java.lang.Thread.run(Unknown Source) [rt.jar:1.7.0_15] Caused by: org.jboss.weld.exceptions.DeploymentException: WELD-001408 Unsatisfied dependencies for type [FWHandlerAufTracking] with qualifiers [@Default] at injection point [[field] @Inject de.mdkbw.exchange.filewatcher.FWMain.fwhAufTracking] at org.jboss.weld.bootstrap.Validator.validateInjectionPoint(Validator.java:311) at org.jboss.weld.bootstrap.Validator.validateInjectionPoint(Validator.java:280) at org.jboss.weld.bootstrap.Validator.validateBean(Validator.java:143) at org.jboss.weld.bootstrap.Validator.validateRIBean(Validator.java:163) at org.jboss.weld.bootstrap.Validator.validateBeans(Validator.java:382) at org.jboss.weld.bootstrap.Validator.validateDeployment(Validator.java:367) at org.jboss.weld.bootstrap.WeldBootstrap.validateBeans(WeldBootstrap.java:379) at org.jboss.as.weld.WeldContainer.start(WeldContainer.java:83) at org.jboss.as.weld.services.WeldService.start(WeldService.java:76)

If I remove the implementation everything is ok. Could anybody tell me what the problem is? Am I too stupid?? Thanks in advance!

Deutero answered 9/5, 2014 at 10:4 Comment(0)
B
8

How do you inject your bean? Like that?

@Inject
private FWHandlerSqrMind handler;

If so could you try to inject it like that:

@Inject
private FWInterface handler;
Briar answered 1/9, 2014 at 10:39 Comment(1)
In general it's better to inject the interface, as it allwows the dependency injection framework to return a different implementation, for example using proxies. I haven't worked with JBoss in a long time so I'm afraid I don't have a deeper explanation. As a rule of thumb always use the least specific interface for injectionBriar
S
7

Do you have META-INF/beans.xml or WEB-INF/beans.xml file in your class path?

Selfstyled answered 26/11, 2014 at 23:27 Comment(0)
F
6

Missing beans.xml was the problem in my case (WildFly 8.2.0).
Just placing a simple beans.xml like the following solved this problem:

    <?xml version="1.0"?>
    <beans xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://jboss.org/schema/cdi/beans_1_0.xsd" />
Friday answered 2/2, 2015 at 17:53 Comment(1)
In my case as well, adding bean.xml solved the unsatisfied dependencies issue.Haemostatic

© 2022 - 2024 — McMap. All rights reserved.