title: Liquibase CDI unsatisfied dependencies for type DataSource
body: <p>I am migrating from JBoss 7.1 to Wildfly 8. When I try to deploy module, which contains Liquibase scripts for DB I am getting following error:</p>
  
  <pre><code>at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1904) [jboss-msc-1.2.0.Final.jar:1.2.0.Final]
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_45]
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_45]
      at java.lang.Thread.run(Thread.java:744) [rt.jar:1.7.0_45]
  Caused by: org.jboss.weld.exceptions.DeploymentException: WELD-001408: Unsatisfied dependencies for type DataSource with qualifiers @LiquibaseType
    at injection point [BackedAnnotatedField] @Inject @LiquibaseType private liquibase.integration.cdi.CDILiquibase.dataSource
    at liquibase.integration.cdi.CDILiquibase.dataSource(CDILiquibase.java:0)
  </code></pre>
  
  <p>The producer is set up according to the documentation:</p>
  
  <pre><code>public class LiquibaseProducer {
  
      private static final String MASTER_CHANGE_LOG_FILE="master_change_log.xml";
  
      @Resource(mappedName="java:jboss/datasources/MyDS")
      private DataSource dataSource;
  
      @Produces @LiquibaseType
      public CDILiquibaseConfig createConfig() {
          CDILiquibaseConfig config = new CDILiquibaseConfig();
          config.setChangeLog(MASTER_CHANGE_LOG_FILE);
          return config;
      }
  
      @Produces @LiquibaseType
      public DataSource createDataSource() throws SQLException {
          return dataSource;
      }
  
      @Produces @LiquibaseType
      public ResourceAccessor create() {
          return new ClassLoaderResourceAccessor(getClass().getClassLoader());
      }
  
  }
  </code></pre>
  
  <p>I've tried to add <code>@Dependent</code> annotation as described in <a href="https://stackoverflow.com/questions/26964483/running-liquibase-with-cdi-on-wildfly-8">this answer</a>, but no luck. Also, tried to use <code>@Startup/@ApplicationScoped/@Stateless</code>, but this also didn't helped.</p>
  
  <p>Initially we were using Liquibase 3.0.2. Now, due to <a href="https://liquibase.jira.com/browse/CORE-1325" rel="nofollow noreferrer">this Jira issue</a> I've upgraded to 3.0.6 and now even to 3.4.1 - still nothing.</p>
  
  <p>By enabling debug I can see that LiquibaseProducer is registered:</p>
  
  <pre><code>11:27:53,180 DEBUG [org.jboss.weld.Bootstrap] (MSC service thread 1-7) WELD-000106: Bean: Producer Method [ResourceAccessor] with qualifiers [@LiquibaseType @Any] declared as [[BackedAnnotatedMethod] @Produces @LiquibaseType public com.server.database.LiquibaseProducer.create()]
  11:27:53,180 DEBUG [org.jboss.weld.Bootstrap] (MSC service thread 1-7) WELD-000106: Bean: WELD|AbstractSyntheticBean|com.server.deployment.ear.ear/com.server.database-1.19.0-SNAPSHOT.war/WEB-INF/classes|BoundRequestContext
  11:27:53,181 DEBUG [org.jboss.weld.Bootstrap] (MSC service thread 1-7) WELD-000106: Bean: WELD|AbstractSyntheticBean|com.server.deployment.ear.ear/com.server.database-1.19.0-SNAPSHOT.war/WEB-INF/classes|BoundSessionContext
  11:27:53,181 DEBUG [org.jboss.weld.Bootstrap] (MSC service thread 1-7) WELD-000106: Bean: WELD|AbstractSyntheticBean|com.server.deployment.ear.ear/com.server.database-1.19.0-SNAPSHOT.war/WEB-INF/classes|HttpServletRequest
  11:27:53,181 DEBUG [org.jboss.weld.Bootstrap] (MSC service thread 1-7) WELD-000106: Bean: WELD|AbstractSyntheticBean|com.server.deployment.ear.ear/com.server.database-1.19.0-SNAPSHOT.war/WEB-INF/classes|ServletContext
  11:27:53,182 DEBUG [org.jboss.weld.Bootstrap] (MSC service thread 1-7) WELD-000106: Bean: Managed Bean [class com.server.database.LiquibaseProducer] with qualifiers [@Any @Default]
  11:27:53,182 DEBUG [org.jboss.weld.Bootstrap] (MSC service thread 1-7) WELD-000106: Bean: WELD|AbstractSyntheticBean|com.server.deployment.ear.ear/com.server.database-1.19.0-SNAPSHOT.war/WEB-INF/classes|BoundConversationContext
  11:27:53,183 DEBUG [org.jboss.weld.Bootstrap] (MSC service thread 1-7) WELD-000106: Bean: WELD|AbstractSyntheticBean|com.server.deployment.ear.ear/com.server.database-1.19.0-SNAPSHOT.war/WEB-INF/classes|HttpConversationContext
  11:27:53,183 DEBUG [org.jboss.weld.Bootstrap] (MSC service thread 1-7) WELD-000106: Bean: WELD|AbstractSyntheticBean|com.server.deployment.ear.ear/com.server.database-1.19.0-SNAPSHOT.war/WEB-INF/classes|HttpSessionContext
  11:27:53,183 DEBUG [org.jboss.weld.Bootstrap] (MSC service thread 1-7) WELD-000106: Bean: WELD|AbstractSyntheticBean|com.server.deployment.ear.ear/com.server.database-1.19.0-SNAPSHOT.war/WEB-INF/classes|HttpSessionDestructionContext
  11:27:53,184 DEBUG [org.jboss.weld.Bootstrap] (MSC service thread 1-7) WELD-000106: Bean: WELD|AbstractSyntheticBean|com.server.deployment.ear.ear/com.server.database-1.19.0-SNAPSHOT.war/WEB-INF/classes|RequestContext
  11:27:53,184 DEBUG [org.jboss.weld.Bootstrap] (MSC service thread 1-7) WELD-000106: Bean: WELD|AbstractSyntheticBean|com.server.deployment.ear.ear/com.server.database-1.19.0-SNAPSHOT.war/WEB-INF/classes|ApplicationContext
  11:27:53,184 DEBUG [org.jboss.weld.Bootstrap] (MSC service thread 1-7) WELD-000106: Bean: WELD|AbstractSyntheticBean|com.server.deployment.ear.ear/com.server.database-1.19.0-SNAPSHOT.war/WEB-INF/classes|SingletonContext
  11:27:53,184 DEBUG [org.jboss.weld.Bootstrap] (MSC service thread 1-7) WELD-000106: Bean: Producer Method [DataSource] with qualifiers [@LiquibaseType @Any] declared as [[BackedAnnotatedMethod] @Produces @LiquibaseType public com.server.database.LiquibaseProducer.createDataSource()]
  11:27:53,184 DEBUG [org.jboss.weld.Bootstrap] (MSC service thread 1-7) WELD-000106: Bean: WELD|AbstractSyntheticBean|com.server.deployment.ear.ear/com.server.database-1.19.0-SNAPSHOT.war/WEB-INF/classes|Conversation
  11:27:53,184 DEBUG [org.jboss.weld.Bootstrap] (MSC service thread 1-7) WELD-000106: Bean: Producer Method [CDILiquibaseConfig] with qualifiers [@LiquibaseType @Any] declared as [[BackedAnnotatedMethod] @Produces @LiquibaseType public com.server.database.LiquibaseProducer.createConfig()]
  </code></pre>
  
  <p>So I am out if thoughts now why it is not working with Wildfly. The last idea is that my producer produces different DataSource, than Liquibase expects, from different rt.jar. Not sure if it makes any sense though.</p>
  
  <p>Any help would be greatly appreciated.</p>