1

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:

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)

The producer is set up according to the documentation:

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());
    }

}

I've tried to add @Dependent annotation as described in this answer, but no luck. Also, tried to use @Startup/@ApplicationScoped/@Stateless, but this also didn't helped.

Initially we were using Liquibase 3.0.2. Now, due to this Jira issue I've upgraded to 3.0.6 and now even to 3.4.1 - still nothing.

By enabling debug I can see that LiquibaseProducer is registered:

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()]

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.

Any help would be greatly appreciated.

Community
  • 1
  • 1
Alex K.
  • 3,294
  • 4
  • 29
  • 41

1 Answers1

1

It looks like you have an ear deployment. Make sure that there is a visibility from CDILiquibase to your producer. From the log, Your producer seems to be located in a war. If CDILiquibase is inside a different module, this could be the problem.

Franck
  • 1,754
  • 1
  • 13
  • 14
  • You are right. Deployment structure is .ear, containing a .war file with LiquibaseProducer.java and liquibase-cdi is located in .ear/lib folder. This works fine in JBoss 7.1 and liquibase 3.0.2. How do I ensure my producer is visible to outside of the .war world? – Alex K. Aug 06 '15 at 12:32
  • Your dependencies seems to be upside down. ear/lib cannot see anything in your war. It is working the other way around. Ref doc: https://docs.jboss.org/author/display/WFLY8/Class+Loading+in+WildFly – Franck Aug 06 '15 at 12:39
  • You point seems valid. I've tried to package liquibase jars into the lib folder under database.war, instead of parent .ear and it seemed to wok (though some other exceptions occurred). Also, it is stated in the documentation, you have provided. I am wondering though, why solution, when liquibase jars are located in .ear/lib is working with Jboss 7.1 Is there a big difference in class loading, compared to Wildfly? – Alex K. Aug 07 '15 at 06:54
  • No difference. In both you cannot refer to a class living in war inside ear or ear/lib modules without a ClassCatException. This is per JEE specs. I would say that if you can do that through Weld is clearly a hole that must have been fixed in earlier version of Weld (a lot has been done since v1.0). Your app will be much more portable this way. – Franck Aug 07 '15 at 11:37