WildFly不会运行我的LiquibaseProcucer CDI

时间:2016-11-30 10:03:29

标签: cdi wildfly liquibase wildfly-9

我试图在WildFly 9.0.2中运行我的LiquibaseProducer。这是我的制作人类:

package nl.itris.mjop.database;
import liquibase.integration.cdi.*;
import liquibase.integration.cdi.annotations.*;
import liquibase.resource.*;

import ********** 

@Singleton
@Startup
@Dependent
public class LiquibaseProcducer {


@Resource(lookup="java:jboss/datasources/PostgresDS")
private static DataSource myDataSource;

@Produces @LiquibaseType
public CDILiquibaseConfig createConfig() {
    System.out.println("============= liquibase createConfig entry =============");
    CDILiquibaseConfig config = new CDILiquibaseConfig();
    config.setChangeLog("liquibase/parser/core/xml/simpleChangeLog.xml");
    System.out.println("============= liquibase createConfig exit =============");
    return config;
}

@Produces @LiquibaseType
public DataSource createDataSource() throws SQLException {
    System.out.println("============= liquibase createDataSource entry =============");

    return getDataSource();
}

@Produces @LiquibaseType
public ResourceAccessor create() {
    System.out.println("============= liquibase create entry =============");
    return new ClassLoaderResourceAccessor(getClass().getClassLoader());
}

public static DataSource getDataSource() {

    if (myDataSource == null) {
      /* Workaround for failing  @Resource(lookup="java:jboss/datasources/PostgresDS") */

        try {
            System.out.println("============= liquibase  datasource lookup via initial context  workaround =============");
            InitialContext ctx = new InitialContext();
            myDataSource = (DataSource) ctx.lookup("java:jboss/datasources/PostgresDS");
        } catch(NamingException ne) {
            ne.printStackTrace();
        }
    }
    return myDataSource;
}
}

当我(重新)在WildFly中部署我的WAR文件时,这个生产者没有做任何事情!我在日志文件中看不到任何错误消息,我没有看到我在生产者方法中放入的任何system.out消息。

生产者类似乎被WildFly加载和识别,因此这个日志片段:

2016-11-30 10:58:53,662 INFO  [org.jboss.as.ejb3.deployment.processors.EjbJndiBindingsDeploymentUnitProcessor] (MSC service thread 1-7) JNDI bindings for session bean named LiquibaseProcducer in deployment unit deployment "mjop-elements.war" are as follows:

java:global/mjop-elements/LiquibaseProcducer!nl.itris.mjop.database.LiquibaseProcducer
java:app/mjop-elements/LiquibaseProcducer!nl.itris.mjop.database.LiquibaseProcducer
java:module/LiquibaseProcducer!nl.itris.mjop.database.LiquibaseProcducer
java:global/mjop-elements/LiquibaseProcducer
java:app/mjop-elements/LiquibaseProcducer
java:module/LiquibaseProcducer

我没有选择。为什么我的制作人没有被执行?我做错了什么?

任何帮助表示赞赏!

我的beans.xml是这样的:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
                   http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd"
   version="1.1" bean-discovery-mode="all">
 </beans>   

0 个答案:

没有答案