14 Replies Latest reply on Jul 8, 2015 8:55 AM by lakshmi_097091

    Famous error WELD-001408 Unsatisfied dependencies

    ivandasilva

      Hi for all !!

       

      I'm developing an app with maven + weld. And I don't inject bean on my Servlet. Below follows the exception:

       

      org.jboss.weld.exceptions.DeploymentException: WELD-001408 Unsatisfied dependencies for type [Teste] with qualifiers [@Default] at injection point [[field] @Inject private br.com.controle.se.controller.LoginController.usuario]
                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.validateInjectionTarget(Validator.java:338)
                at org.jboss.weld.manager.InjectionTargetValidator.addInjectionTarget(InjectionTargetValidator.java:29)
                at org.jboss.weld.manager.BeanManagerImpl.createInjectionTarget(BeanManagerImpl.java:923)
                at org.jboss.weld.environment.servlet.inject.AbstractInjector.inject(AbstractInjector.java:50)
                at org.jboss.weld.environment.tomcat7.WeldInstanceManager.newInstance(WeldInstanceManager.java:24)
                at org.jboss.weld.environment.tomcat7.WeldForwardingInstanceManager.newInstance(WeldForwardingInstanceManager.java:63)
                at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1136)
                at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:857)
                at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:136)
                at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
                at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
                at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
                at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
                at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929)
                at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
                at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
                at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1002)
                at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:585)
                at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
                at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
                at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
                at java.lang.Thread.run(Thread.java:722)
      
      

       

      Follow my config. files:

       

       

      web.xml

       

      <web-app version="3.0" 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://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
                metadata-complete="false">
      
      
                <welcome-file-list>
                          <welcome-file>login.jsp</welcome-file>
                          <welcome-file>index.jsp</welcome-file>
                </welcome-file-list>
      
      
      
      
                <listener>
                          <listener-class>org.jboss.weld.environment.servlet.Listener</listener-class>
                </listener>
      
      
                <servlet>
                          <servlet-name>Jersey REST Service</servlet-name>
                          <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
      
      
                          <init-param>
                                    <param-name>com.sun.jersey.spi.container.ContainerResponseFilters</param-name>
                                    <param-value>com.sun.jersey.server.linking.LinkFilter</param-value>
                          </init-param>
      
      
                          <init-param>
                                    <param-name>com.sun.jersey.config.property.packages</param-name>
                                    <param-value>br.com.controle.se.resource</param-value>
                          </init-param>
        
                          <init-param>
                                    <param-name>com.sun.jersey.spi.container.ContainerRequestFilters</param-name>
                                    <param-value>com.sun.jersey.api.container.filter.LoggingFilter</param-value>
                          </init-param>
        
                          <init-param>
                                    <param-name>com.sun.jersey.spi.container.ContainerResponseFilters</param-name>
                                    <param-value>com.sun.jersey.api.container.filter.LoggingFilter</param-value>
                          </init-param>
      
      
                          <init-param>
                                    <param-name>com.jayway.jaxrs.hateoas.HateoasLinkInjector</param-name>
                                    <param-value>com.jayway.jaxrs.hateoas.support.StrategyBasedLinkInjector</param-value>
                          </init-param>
        
                          <init-param>
                                    <param-name>com.jayway.jaxrs.hateoas.CollectionWrapperStrategy</param-name>
                                    <param-value>com.jayway.jaxrs.hateoas.support.DefaultCollectionWrapperStrategy</param-value>
                          </init-param>
        
                          <load-on-startup>1</load-on-startup>
      
      
                </servlet>
                <servlet-mapping>
                          <servlet-name>Jersey REST Service</servlet-name>
                          <url-pattern>/rest/*</url-pattern>
                </servlet-mapping>
      
      
      
      
        
                <resource-env-ref>
                          <resource-env-ref-name>BeanManager</resource-env-ref-name>
                          <resource-env-ref-type>javax.enterprise.inject.spi.BeanManager</resource-env-ref-type>
                </resource-env-ref>
      </web-app>
      
      

       

       

      context.xml


      <?xml version="1.0" encoding="UTF-8"?>
      <Context>
          <Resource name="BeanManager"
                    auth="Container"
                    type="javax.enterprise.inject.spi.BeanManager"
                    factory="org.jboss.weld.resources.ManagerObjectFactory"/>
      </Context>
      
      

       

       

      beans.xml


      <?xml version="1.0" encoding="UTF-8"?>
      <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://java.sun.com/xml/ns/javaee/beans_1_0.xsd">
      </beans>
      
      

       

       

      I tried inject a simple class without any attributes and which implements Serializable but this doesn't works for me.

       

      What I did until now.

      • Put beans.xml inside WEB-INF
      • put context.xml inside of META-INF
      • register BeanManager into my web.xml
      • I tried to create a @Qualifier to the class but the message changes only in this point "with qualifiers [@MyQualifier] " instead of with qualifiers [@Default]

       

       

      Tks a lot everyone

        • 1. Re: Famous error WELD-001408 Unsatisfied dependencies
          mkouba

          Hi Ivan,

           

          you should provide some relevant sample code and deployment info at least.

           

          The stacktrace only states: there's a CDI bean LoginController, which has "usuario" field injection point defined. And Weld is unable to inject it. In other words: there's no available CDI bean with given bean type (Teste) and qualifiers (@Default).

          1 of 1 people found this helpful
          • 2. Re: Famous error WELD-001408 Unsatisfied dependencies
            ivandasilva

            Martin Kouba, first of all tks for reply !!

             

             

            Follow my pom.xml / Servlet and class that I would inject

             

            I don't know if this helps you, but the exception is thrown because Validator.resolvedBeans is 0.

             

             

            Teste class

            package br.com.controle.se.controller;
            
            
            import java.io.Serializable;
            
            public class Teste implements Serializable {
            
              public Teste(){
              super();
              }
            }
            

             

            Servlet where I do IoC

             

            package br.com.controle.se.controller;
            
            
            import java.io.Serializable;
            import java.util.Set;
            
            
            import javax.el.ELResolver;
            import javax.enterprise.context.RequestScoped;
            import javax.enterprise.inject.spi.BeanManager;
            import javax.inject.Inject;
            import javax.inject.Named;
            import javax.naming.Context;
            import javax.naming.InitialContext;
            import javax.naming.NamingException;
            import javax.servlet.annotation.WebServlet;
            import javax.servlet.http.HttpServlet;
            import javax.servlet.http.HttpServletRequest;
            import javax.servlet.http.HttpServletResponse;
            
            
            import org.apache.log4j.Logger;
            import org.jboss.weld.manager.BeanManagerImpl;
            import org.jboss.weld.resolution.NameBasedResolver;
            
            
            @RequestScoped
            @Named
            @WebServlet(urlPatterns = "/pages/home")
            public class LoginController extends HttpServlet implements Serializable {
            
            
            
                      @Inject
                      private Teste usuario;
            
            
                      private Logger logger = Logger.getLogger(LoginController.class);
            
            
                      @Override
                      public void doPost(HttpServletRequest request, HttpServletResponse response) {
            
            
                                Context initContext = null;
                                try {
                                          initContext = new InitialContext();
                                          Context envContext = (Context) initContext.lookup("java:/comp/env");
                                          BeanManager beanManager = (BeanManager) envContext.lookup("BeanManager");
                                          ELResolver elResolver = beanManager.getELResolver();
                                          javax.enterprise.context.spi.Context ctx = beanManager.getContext(RequestScoped.class);
                                          Set<?> bean = beanManager.getBeans("CDIExtension");
            
            
                                          System.out.println(beanManager.getBeans(""));
                                          System.out.println(beanManager.getBeans("BeanManager"));
            
                                          NameBasedResolver resolver = new NameBasedResolver((BeanManagerImpl) beanManager, null);
                                          System.out.println(resolver.resolve("usuario"));
            
            
                                } catch (NamingException e) {
                                          // TODO Auto-generated catch block
                                          e.printStackTrace();
                                }
            
            
            
            
            
                                logger.info("LOGGGGGGEEEERRR: " + usuario);
                      }
            }
            
            

             

             

             

            pom.xml

             

            <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                      xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
                      <modelVersion>4.0.0</modelVersion>
                      <groupId>controle</groupId>
                      <artifactId>se</artifactId>
                      <packaging>war</packaging>
                      <version>0.0.1-SNAPSHOT</version>
            
            
                      <properties>
                                <project.build.sourceEncoding>ISO-8859-1</project.build.sourceEncoding>
                                <maven.compiler.source>1.6</maven.compiler.source>
                                <maven.compiler.target>1.6</maven.compiler.target>
                      </properties>
            
            
                      <dependencies>
                                <!-- JERSEY -->
                                <dependency>
                                          <groupId>com.sun.jersey</groupId>
                                          <artifactId>jersey-server</artifactId>
                                          <version>1.8</version>
                                          <scope>compile</scope>
                                </dependency>
                                <dependency>
                                          <groupId>com.sun.jersey</groupId>
                                          <artifactId>jersey-grizzly2</artifactId>
                                          <version>1.17</version>
                                          <scope>compile</scope>
                                </dependency>
                                <dependency>
                                          <groupId>com.sun.jersey</groupId>
                                          <artifactId>jersey-server-linking</artifactId>
                                          <version>1.17</version>
                                          <scope>compile</scope>
                                          <exclusions>
                                                    <exclusion>
                                                              <groupId>javax.el</groupId>
                                                              <artifactId>el-api</artifactId>
                                                    </exclusion>
                                          </exclusions>
                                </dependency>
                                <dependency>
                                          <groupId>com.jayway.jax-rs-hateoas</groupId>
                                          <artifactId>jax-rs-hateoas-core</artifactId>
                                          <version>0.4.5</version>
                                          <scope>compile</scope>
                                </dependency>
                                <dependency>
                                          <groupId>com.jayway.jax-rs-hateoas</groupId>
                                          <artifactId>demo-domain</artifactId>
                                          <version>0.4.5</version>
                                          <scope>compile</scope>
                                </dependency>
            
            
            
            
            
            
                                <!-- HIBERNATE -->
                                <dependency>
                                          <groupId>org.hibernate</groupId>
                                          <artifactId>hibernate-core</artifactId>
                                          <version>4.2.0.Final</version>
                                          <scope>compile</scope>
                                </dependency>
            
            
            
            
                                <!-- OUTROS -->
                                <dependency>
                                          <groupId>log4j</groupId>
                                          <artifactId>log4j</artifactId>
                                          <version>1.2.16</version>
                                          <scope>compile</scope>
                                </dependency>
                                <dependency>
                                          <groupId>org.hsqldb</groupId>
                                          <artifactId>hsqldb-j5</artifactId>
                                          <version>2.2.4</version>
                                          <scope>compile</scope>
                                </dependency>
                                <dependency>
                                          <groupId>javax.servlet</groupId>
                                          <artifactId>javax.servlet-api</artifactId>
                                          <version>3.0.1</version>
                                          <scope>provided</scope>
                                </dependency>
                                <dependency>
                                          <groupId>org.jboss.weld.servlet</groupId>
                                          <artifactId>weld-servlet</artifactId>
                                          <version>1.1.11.Final</version>
                                          <scope>compile</scope>
                                </dependency>
                                <dependency>
                                          <groupId>javax.el</groupId>
                                          <artifactId>el-api</artifactId>
                                          <version>2.2</version>
                                          <scope>provided</scope>
                                </dependency>
            
            
                                <dependency>
                                          <groupId>junit</groupId>
                                          <artifactId>junit</artifactId>
                                          <version>4.10</version>
                                          <scope>test</scope>
                                </dependency>
                                <dependency>
                                          <groupId>org.openid4java</groupId>
                                          <artifactId>openid4java</artifactId>
                                          <version>0.9.7</version>
                                          <scope>test</scope>
                                </dependency>
            
            
                                <dependency>
                                          <groupId>org.jboss.weld.se</groupId>
                                          <artifactId>weld-se</artifactId>
                                          <version>1.1.8.Final</version>
                                          <scope>test</scope>
                                </dependency>
            
            
            
            
                      </dependencies>
            
            
                      <repositories>
                                <repository>
                                          <id>jboss</id>
                                          <url>https://repository.jboss.org/nexus/</url>
                                          <releases>
                                                    <enabled>true</enabled>
                                          </releases>
                                          <snapshots>
                                                    <enabled>false</enabled>
                                          </snapshots>
                                </repository>
                      </repositories>
            
            
                      <build>
                                <plugins>
                                          <plugin>
                                                    <groupId>org.apache.maven.plugins</groupId>
                                                    <artifactId>maven-compiler-plugin</artifactId>
                                                    <version>3.1</version>
                                                    <configuration>
                                                              <verbose>true</verbose>
                                                              <compilerVersion>1.6</compilerVersion>
                                                              <downloadSources>true</downloadSources>
                                                              <downloadJavadocs>true</downloadJavadocs>
                                                    </configuration>
                                          </plugin>
                                </plugins>
                      </build>
                      <profiles>
                                <profile>
            
            
                                          <!-- When built in OpenShift the 'openshift' profile will be used when
                                                    invoking mvn. -->
                                          <!-- Use this profile for any OpenShift specific customization your app
                                                    will need. -->
                                          <!-- By default that is to put the resulting archive into the 'webapps'
                                                    folder. -->
                                          <!-- http://maven.apache.org/guides/mini/guide-building-for-different-environments.html -->
                                          <id>openshift</id>
                                          <build>
                                                    <plugins>
                                                              <plugin>
                                                                        <artifactId>maven-war-plugin</artifactId>
                                                                        <version>2.1.1</version>
                                                                        <configuration>
                                                                                  <outputDirectory>webapps</outputDirectory>
                                                                                  <warName>ROOT</warName>
                                                                        </configuration>
                                                              </plugin>
                                                    </plugins>
                                          </build>
                                </profile>
            
            
                                <!-- Profile para desenvolvimento -->
                                <profile>
                                          <id>development-tomcat</id>
                                          <build>
                                                    <finalName>controle-se</finalName>
                                                    <plugins>
                                                              <plugin>
                                                                        <groupId>org.apache.tomcat.maven</groupId>
                                                                        <artifactId>tomcat7-maven-plugin</artifactId>
                                                                        <version>2.0</version>
                                                                        <configuration>
                                                                                  <path>/${project.build.finalName}</path>
                                                                                  <contextFile>${basedir}/src/main/webapp/META-INF/context.xml</contextFile>
                                                                        </configuration>
                                                              </plugin>
                                                    </plugins>
                                          </build>
                                </profile>
            
            
                                <profile>
                                          <id>development</id>
                                          <build>
                                                    <finalName>controle-se</finalName>
                                                    <plugins>
                                                              <plugin>
                                                                        <groupId>org.mortbay.jetty</groupId>
                                                                        <artifactId>maven-jetty-plugin</artifactId>
                                                                        <version>6.1.10</version>
                                                                        <configuration>
                                                                                  <scanIntervalSeconds>10</scanIntervalSeconds>
                                                                                  <stopKey>foo</stopKey>
                                                                                  <stopPort>9999</stopPort>
                                                                        </configuration>
                                                                        <executions>
                                                                                  <execution>
                                                                                            <id>start-jetty</id>
                                                                                            <phase>pre-integration-test</phase>
                                                                                            <goals>
                                                                                                      <goal>run</goal>
                                                                                            </goals>
                                                                                            <configuration>
                                                                                                      <scanIntervalSeconds>0</scanIntervalSeconds>
                                                                                                      <daemon>true</daemon>
                                                                                            </configuration>
                                                                                  </execution>
                                                                                  <execution>
                                                                                            <id>stop-jetty</id>
                                                                                            <phase>post-integration-test</phase>
                                                                                            <goals>
                                                                                                      <goal>stop</goal>
                                                                                            </goals>
                                                                                  </execution>
                                                                        </executions>
                                                              </plugin>
                                                    </plugins>
                                          </build>
                                </profile>
                      </profiles>
            </project>
            
            

             

             

            I'm using the profile development-tomcat therefore I use the maven command line to bootstrap app mvn clean package tomcat7:run

            • 3. Re: Famous error WELD-001408 Unsatisfied dependencies
              mkouba

              First of all - servlet instance managed by servlet container is not a CDI bean. In other words the servlet instance will not be the same instance obtained when using @Inject. So remove @RequestScoped and @Named annotations.

               

              The injection point @Inject Teste usuario should work. But looking at the stack trace, it seems the exception is thrown inside weld servlet integration code - when it tries to create injection target from the servlet. Have no idea why... try to change the log level for weld and inspect logged info afterwards.

               

              Teste has not @Named annotation defined, so you cannot lookup a bean by name, just by type (resolver.resolve("usuario") wouldn't work).

               

              Also don't use Weld internal impl classes - NameBasedResolver, use CDI API instead - BeanManager.getBeans(String) to have your app portable.

              1 of 1 people found this helpful
              • 4. Re: Famous error WELD-001408 Unsatisfied dependencies
                ivandasilva

                Martin Kouba tks a lot !!!

                 

                I found the error....

                 

                I change the folder where beans.xml is detected.

                 

                Before was in

                  src/main/webapp/WEB-INF

                 

                And now

                  src/main/resources/META-INF and works !!!

                • 5. Re: Famous error WELD-001408 Unsatisfied dependencies
                  mkouba

                  Hm, but this is against the spec. In a WAR, beans.xml should be in WEB-INF/ (CDI 1.0) or in WEB-INF/classes/META-INF/ (CDI 1.1). META-INF/ should only work for JARs.

                  • 6. Re: Famous error WELD-001408 Unsatisfied dependencies
                    oehmsmith

                    I found another cause / solution but don't understand why.  I had to add a scope to the producer class (or method apparantly):

                     

                    @javax.enterprise.context.SessionScoped

                    public class LoggingProducer implements Serializable {

                        private static final long serialVersionUID = 1L;

                     

                        @Produces

                        public Logger produceLogger(InjectionPoint injectionPoint) {

                     

                    According to http://docs.jboss.org/weld/reference/1.0.0/en-US/html/producermethods.html#d0e3306, it will take the scope of what injects it.  I don't understand why my uses don't have a @Dependant scope.  Anyways that is a different issue and adding the scope got it working for me.  And after lots of googling so I hope this helps someone else.

                    ----

                    UPDATE / EDIT

                    I believe I found the cause of my problem that required @SessionScoped on the Producer.  I have an EAR project and seemed to have a mix of Java 1.6 and Java 1.7 (as set on the Eclipse Project Facet).  Doesn't help the original poster though, sorry.

                    ----

                    UPDATE 2

                    That was not correct.  @Stateless seems more correct.  I found this out when doing Arquillian testing.  This testing also unearthed another cause and solution of the WELD-001408 error.  I had a producer like the following that was only a problem when run through Arquillian testing:

                     

                    @Stateless
                    public class EntityProducer implements Serializable {
                         private static final long serialVersionUID = 1L;
                         // Now just do @Inject EntityManager em - the unitName is only set once here
                    
                         @Produces
                         @PersistenceContext(unitName = "esaarch01-pu")
                         private EntityManager em;
                    }
                    

                     

                    I changed it to this which work as before and with Arquillian testing (no more WELD-001408 error):

                     

                    @Stateless
                    public class EntityProducer implements Serializable {
                        private static final long serialVersionUID = 1L;
                        // Now just do @Inject EntityManager em - the unitName is only set once here
                        @PersistenceContext(unitName = "esaarch01-pu")
                        private EntityManager em;
                    
                        @Produces
                        public EntityManager getEntityManager() {
                            return em;
                        }
                    }
                    
                    • 7. Re: Famous error WELD-001408 Unsatisfied dependencies
                      milgoff

                      Hi. I have the same error I'm trying to run Arqullian tests.

                       

                      16:49:42,713 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-4) MSC00001: Failed to start service jboss.deployment.unit."test.war".WeldService: org.jboss.msc.service.StartException in service jboss.deployment.unit."test.war".WeldService: org.jboss.weld.exceptions.DeploymentException: WELD-001408 Unsatisfied dependencies for type [Sender] with qualifiers [@Default] at injection point [[field] @Inject com.test.test2.ejb.AppManagerBean.sender]
                          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_13]
                          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_13]
                          at java.lang.Thread.run(Thread.java:722) [rt.jar:1.7.0_13]
                      Caused by: org.jboss.weld.exceptions.DeploymentException: WELD-001408 Unsatisfied dependencies for type [Sender] with qualifiers [@Default] at injection point [[field] @Inject com.test.test2.ejb.AppManagerBean.sender]
                          at org.jboss.weld.bootstrap.Validator.validateInjectionPoint(Validator.java:275)
                          at org.jboss.weld.bootstrap.Validator.validateInjectionPoint(Validator.java:244)
                          at org.jboss.weld.bootstrap.Validator.validateBean(Validator.java:107)
                          at org.jboss.weld.bootstrap.Validator.validateRIBean(Validator.java:127)
                          at org.jboss.weld.bootstrap.Validator.validateBeans(Validator.java:346)
                          at org.jboss.weld.bootstrap.Validator.validateDeployment(Validator.java:331)
                          at org.jboss.weld.bootstrap.WeldBootstrap.validateBeans(WeldBootstrap.java:366)
                          at org.jboss.as.weld.WeldContainer.start(WeldContainer.java:83)
                          at org.jboss.as.weld.services.WeldService.start(WeldService.java:76)
                          ... 5 more
                      

                      My test class CustomerCollectionResourceTest:

                       

                       

                       

                      import com.google.android.gcm.server.Result;
                      import com.google.android.gcm.server.Sender;
                      import org.jboss.arquillian.container.test.api.Deployment;
                      import org.jboss.arquillian.junit.Arquillian;
                      import org.jboss.shrinkwrap.api.ShrinkWrap;
                      import org.jboss.shrinkwrap.api.asset.EmptyAsset;
                      import org.jboss.shrinkwrap.api.spec.WebArchive;
                      import org.json.simple.parser.ParseException;
                      import org.junit.Test;
                      import org.junit.runner.RunWith;
                      
                      import javax.ejb.EJB;
                      import javax.inject.Inject;
                      
                      @RunWith(Arquillian.class)
                      public class CustomerCollectionResourceTest {
                      
                          @Deployment
                          public static WebArchive createTestArchive() {
                              return ShrinkWrap.create(WebArchive.class, "test.war")
                                      .addClasses(CustomerCollectionResource.class, EntityManagerProducer.class,
                                              AppManager.class, AppManagerBean.class, Storage.class,
                                              ParseException.class, Sender.class)
                                      .addPackage(Customer.class.getPackage())
                                      .addPackage(Result.class.getPackage())
                                      .addPackage(NotFoundException.class.getPackage())
                                      .addPackage(CustomerPhotoResource.class.getPackage())
                                      .addPackage(ProximityModel.class.getPackage())
                                      .addAsResource("import.sql")
                                      .addAsManifestResource(EmptyAsset.INSTANCE, "META-INF/beans.xml")
                                      .addAsManifestResource("test-ds.xml", "test-ds.xml");
                          }
                      
                          @Inject
                          CustomerCollectionResource resource;
                          @EJB
                          AppManager manager;
                      
                          @Test
                          public void testList() throws Exception {
                              resource = new CustomerCollectionResource();
                              resource.list(null);
                          }
                      }
                      

                      AppManagerBean.java

                       

                      import com.google.android.gcm.server.Constants;
                      import com.google.android.gcm.server.Message;
                      import com.google.android.gcm.server.Result;
                      import com.google.android.gcm.server.Sender;
                      import com.google.common.base.Strings;
                      import com.test.test2.json.JacksonObjectMapperProvider;
                      import com.test.test2.model.*;
                      import com.test.test2.rest.HttpStatusException;
                      import com.test.test2.rest.NotFoundException;
                      import com.test.test2.rest.model.ProximityModel;
                      import org.codehaus.jackson.map.ObjectMapper;
                      import org.slf4j.Logger;
                      import org.slf4j.LoggerFactory;
                      
                      import javax.ejb.Asynchronous;
                      import javax.ejb.Local;
                      import javax.ejb.Stateless;
                      import javax.inject.Inject;
                      import javax.persistence.*;
                      import javax.persistence.criteria.*;
                      import javax.ws.rs.core.Response;
                      import java.io.IOException;
                      import java.util.List;
                      
                      
                      /**
                       * Stateless EJB bean containing entire business logic implementation
                       */
                      @Local(AppManager.class)
                      @Stateless
                      public class AppManagerBean implements AppManager {
                      
                          public static final String
                                  GCM_ENTER_ACTION = "enter",
                                  GCM_EXIT_ACTION = "exit",
                                  PARAM_DATA_JSON = "proximityModel",
                                  PARAM_CUSTOMER_ID = "customerId",
                                  PARAM_ACTION = "action";
                      
                          @Inject
                          EntityManager em;
                      
                          @Inject
                          Sender sender;
                      ....
                      }
                      

                      And finally class for test CustomerCollectionResource

                       

                      @Path("customer/")
                      @RequestScoped
                      public class CustomerCollectionResource {
                      
                          final static int CACHEABLE_SECONDS = 0;
                          @EJB
                          private AppManager manager;
                      
                          @GET
                          @Produces(MediaType.APPLICATION_JSON)
                          public Response list(@QueryParam("email") String email) {
                      
                              final List<Customer> entities = manager.listCustomers(email);
                      
                              if(entities.size() == 0)
                                  throw new NotFoundException("There is no any customer");
                      
                              ListModel<ListItem> result = new ListModel<ListItem>(entities.size());
                              result.itemType = ListItem.MEDIA_TYPE;
                              final UriBuilder itemLink = UriBuilder.fromResource(CustomerResource.class);
                              for (Customer entity : entities) {
                                  result.add(new ListItem(entity.getName(), itemLink.build(entity.getId())));
                              }
                              CacheControl cc = new CacheControl();
                              cc.setMaxAge(CACHEABLE_SECONDS);
                              cc.setPrivate(true);
                              return Response.ok(result).cacheControl(cc).build();
                          }
                      
                      
                      }
                      

                      Thanks for any help

                      • 8. Re: Famous error WELD-001408 Unsatisfied dependencies
                        luksa

                        Where's your SenderProducer? According to [1] the Sender doesn't have a no-arg constructor and will therefore not be a managed bean.

                         

                        [1] https://code.google.com/p/gcm/source/browse/gcm-server/src/com/google/android/gcm/server/Sender.java

                        • 9. Re: Famous error WELD-001408 Unsatisfied dependencies
                          milgoff

                          Producer code:

                           

                          public class GcmSenderProducer {
                          
                              @Resource String senderId;
                          
                              @Produces public Sender getSender() {
                                  return new Sender(senderId);
                              }
                          
                          }
                          
                          • 10. Re: Famous error WELD-001408 Unsatisfied dependencies
                            luksa

                            Are you adding it to your web archive in your arquillian test?  You're not adding the class directly, so is it in one of the packages you are adding?

                            • 11. Re: Famous error WELD-001408 Unsatisfied dependencies
                              omidashouri

                              god bless you Ivan Rodrigues , you were right i move bean.xml to META-INF  and every thing go correct....thanks alot

                              • 12. Re: Famous error WELD-001408 Unsatisfied dependencies
                                lakshmi_097091

                                Hi

                                 

                                i was unable to deploying war file in wildfly-8.1.0.Final server. while deploying i am getting below error.

                                2015-07-08 15:50:14,322 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-3) MSC000001: Failed to start service jboss.deployment.unit."rewards-jsf.war".WeldStartService: org.jboss.msc.service.StartException in service jboss.deployment.unit."rewards-jsf.war".WeldStartService: Failed to start service

                                  at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1904) [jboss-msc-1.2.2.Final.jar:1.2.2.Final]

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

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

                                  at java.lang.Thread.run(Thread.java:745) [rt.jar:1.7.0_76]

                                Caused by: org.jboss.weld.exceptions.DeploymentException: Exception List with 2 exceptions:

                                Exception 0 :

                                org.jboss.weld.exceptions.DeploymentException: WELD-001408: Unsatisfied dependencies for type Injector with qualifiers @Default

                                  at injection point [BackedAnnotatedField] @Inject private org.sonatype.guice.bean.binders.TypeConverterMap.injector

                                  at org.sonatype.guice.bean.binders.TypeConverterMap.injector(TypeConverterMap.java:0)

                                 

                                 

                                I am new to JBPM, i try to execute rewards-jsf example, i have downloaded this from online.

                                my persistence.xml file is

                                 

                                <?xml version="1.0" encoding="UTF-8"?>

                                <persistence version="2.0"

                                  xmlns="http://java.sun.com/xml/ns/persistence"

                                  xmlns:orm="http://java.sun.com/xml/ns/persistence/orm"

                                  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

                                  xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd http://java.sun.com/xml/ns/persistence/orm http://java.sun.com/xml/ns/persistence/orm_2_0.xsd">

                                 

                                 

                                  <persistence-unit name="org.jbpm.domain" transaction-type="JTA">

                                    <provider>org.hibernate.ejb.HibernatePersistence</provider>

                                    <jta-data-source>java:jboss/datasources/jbpmDS</jta-data-source>

                                <properties>

                                      <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" />

                                      <property name="hibernate.max_fetch_depth" value="3" />

                                      <property name="hibernate.hbm2ddl.auto" value="update" />

                                      <property name="hibernate.show_sql" value="false" />     

                                      <!-- BZ 841786: AS7/EAP 6/Hib 4 uses new (sequence) generators which seem to cause problems -->

                                      <property name="hibernate.id.new_generator_mappings" value="false" />

                                      <property name="hibernate.transaction.jta.platform" value="org.hibernate.service.jta.platform.internal.JBossAppServerJtaPlatform" />

                                    </properties>

                                  </persistence-unit>

                                </persistence>


                                could you please let me know how can i fix this and deploy successfully the war file in server.


                                Thanks,

                                Lakshmi

                                • 13. Re: Famous error WELD-001408 Unsatisfied dependencies
                                  mkouba

                                  Hi,

                                  you war contains some Guice integration code which is also using javax.inject annotations, namely org.sonatype.guice.bean.binders.TypeConverterMap. You should either identify the corresponding dependency and remove it (if possible) or supress implicit bean archives so that Weld only scans archives with beans.xml descriptor (see also CDI Reference - WildFly 9 - Project Documentation Editor).

                                  • 14. Re: Famous error WELD-001408 Unsatisfied dependencies
                                    lakshmi_097091

                                    Thanks Martin for responding error and providing informaiton , i will look into the issue as you suggested way.