Hello together,
hopefully someone can help me?
I have following code, which is failing on startup:
@Dependent
@NoArgsConstructor
@Slf4j
public
class InitSystemLiquibase {
/** the {@link DataSource}. */
@Resource(name = DataSourceConstants.JNDI_NAME_REDD_DS)
private transient DataSource dataSource;
/**
-
Create the DB config/schema.
-
@return {@link CDILiquibaseConfig}
*/
@Produces
@LiquibaseType
public CDILiquibaseConfig createConfig() {
LOG.info(“starting Liquibase execution.”);
CDILiquibaseConfig lConfig = new CDILiquibaseConfig();
lConfig.setChangeLog(DataSourceConstants.LIQUIBASE_MASTERCHANGELOG);
return lConfig;
}
/** create the datasource for the CDI.
*
-
@return the {@link DataSource}
*/
@Produces
@LiquibaseType
public DataSource createDataSource() {
return dataSource;
}
/**
-
Create the classloader.
-
@return The {@link ResourceAccessor}
*/
@Produces
@LiquibaseType
public ResourceAccessor create() {
LOG.debug(“getting the classloader”);
ResourceAccessor lResult = null;
ClassLoader lLoader = Thread.currentThread().getContextClassLoader();
lResult = new ClassLoaderResourceAccessor(lLoader);
//TODO: added to test classloading of the packaged db-addons, else
this call is fully useless
//new WildflyClasspathWorarkoundDriver();
return lResult;
}
}
My issue now is, that my Liquibase is failing on startup of the
application with following exception:
org.jboss.weld.exceptions.WeldException:
WELD-000049: Unable to invoke public void
liquibase.integration.cdi.CDILiquibase.onStartup() on liquibase.integ
ration.cdi.CDILiquibase@ae5f6f6
at org.jboss.weld.injection.producer.DefaultLifecycleCallbackInvoker.invokeMethods(DefaultLifecycleCallbackInvoker.java:100)
at org.jboss.weld.injection.producer.DefaultLifecycleCallbackInvoker.postConstruct(DefaultLifecycleCallbackInvoker.java:81)
at org.jboss.weld.injection.producer.BasicInjectionTarget.postConstruct(BasicInjectionTarget.java:126)
at org.jboss.weld.injection.producer.BeanInjectionTarget.postConstruct(BeanInjectionTarget.java:70)
at liquibase.integration.cdi.CDIBootstrap$1.create(CDIBootstrap.java:95)
at liquibase.integration.cdi.CDIBootstrap$1.create(CDIBootstrap.java:38)
at org.jboss.weld.context.AbstractContext.get(AbstractContext.java:96)
at org.jboss.weld.bean.proxy.ContextBeanInstance.getInstance(ContextBeanInstance.java:98)
at org.jboss.weld.bean.proxy.ProxyMethodHandler.invoke(ProxyMethodHandler.java:78)
at
liquibase.integration.cdi.CDILiquibase$Proxy$_$$_WeldClientProxy.toString(Unknown Source)
at liquibase.integration.cdi.CDIBootstrap.afterDeploymentValidation(CDIBootstrap.java:111)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.jboss.weld.injection.MethodInjectionPoint.invokeOnInstanceWithSpecialValue(MethodInjectionPoint.java:90)
at org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:271)
at org.jboss.weld.event.ExtensionObserverMethodImpl.sendEvent(ExtensionObserverMethodImpl.java:121)
at org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:258)
at org.jboss.weld.event.ObserverMethodImpl.notify(ObserverMethodImpl.java:237)
at org.jboss.weld.event.ObserverNotifier.notifyObserver(ObserverNotifier.java:174)
at org.jboss.weld.event.ObserverNotifier.notifyObservers(ObserverNotifier.java:133)
at org.jboss.weld.event.ObserverNotifier.fireEvent(ObserverNotifier.java:107)
at org.jboss.weld.bootstrap.events.AbstractContainerEvent.fire(AbstractContainerEvent.java:54)
at org.jboss.weld.bootstrap.events.AbstractDeploymentContainerEvent.fire(AbstractDeploymentContainerEvent.java:35)
at org.jboss.weld.bootstrap.events.AfterDeploymentValidationImpl.fire(AfterDeploymentValidationImpl.java:28)
at org.jboss.weld.bootstrap.WeldStartup.validateBeans(WeldStartup.java:439)
at org.jboss.weld.bootstrap.WeldBootstrap.validateBeans(WeldBootstrap.java:90)
at org.jboss.as.weld.WeldStartService.start(WeldStartService.java:93)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1948)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1881)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused
by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.jboss.weld.injection.producer.DefaultLifecycleCallbackInvoker.invokeMethods(DefaultLifecycleCallbackInvoker.java:98)
… 33 more
Caused
by: liquibase.exception.UnexpectedLiquibaseException:
liquibase.exception.MigrationFailedException: Migration failed for
change set liquibase/001_CreateUsers.xml::001_CreateUsers_DefaultTable::me:
Reason: liquibase.exception.DatabaseException: Error creating or
initializing trigger
\“MODIFY_ROWCREATED_ROWUPDATED_TRIGGER\” object, class
\“com.x.db.h2.ModifyRowCreatedRowUpdatedTrigger\”,
cause: \“org.h2.message.DbException: Class
\”\“com.x.db.h2.ModifyRowCreatedRowUpdatedTrigger\”\"
not found [90086-173]\"; see root cause for details; SQL statement:
CREATE
TRIGGER IF NOT EXISTS modify_rowCreated_rowUpdated_trigger BEFORE
INSERT ON Users FOR EACH ROW CALL
\“com.x.db.h2.ModifyRowCreatedRowUpdatedTrigger\”
[90043-173] [Failed SQL: CREATE TRIGGER IF NOT EXISTS
modify_rowCreated_rowUpdated_trigger BEFORE INSERT ON Users FOR EACH
ROW CALL \“com.x.db.h2.ModifyRowCreatedRowUpdatedTrigger\”]
at liquibase.integration.cdi.CDILiquibase.onStartup(CDILiquibase.java:118)
… 38 more
Caused
by: liquibase.exception.MigrationFailedException: Migration failed
for change set liquibase/001_CreateUsers.xml::001_CreateUsers_DefaultTable::me:
Reason: liquibase.exception.DatabaseException: Error creating or
initializing trigger
\“MODIFY_ROWCREATED_ROWUPDATED_TRIGGER\” object, class
\“com.x.db.h2.ModifyRowCreatedRowUpdatedTrigger\”,
cause: \“org.h2.message.DbException: Class
\”\“com.x.db.h2.ModifyRowCreatedRowUpdatedTrigger\”\"
not found [90086-173]\"; see root cause for details; SQL statement:
CREATE
TRIGGER IF NOT EXISTS modify_rowCreated_rowUpdated_trigger BEFORE
INSERT ON Users FOR EACH ROW CALL
\“com.x.db.h2.ModifyRowCreatedRowUpdatedTrigger\”
[90043-173] [Failed SQL: CREATE TRIGGER IF NOT EXISTS
modify_rowCreated_rowUpdated_trigger BEFORE INSERT ON Users FOR EACH
ROW CALL \“com.x.db.h2.ModifyRowCreatedRowUpdatedTrigger\”]
at liquibase.changelog.ChangeSet.execute(ChangeSet.java:584)
at liquibase.changelog.visitor.UpdateVisitor.visit(UpdateVisitor.java:51)
at liquibase.changelog.ChangeLogIterator.run(ChangeLogIterator.java:73)
at liquibase.Liquibase.update(Liquibase.java:210)
at liquibase.Liquibase.update(Liquibase.java:190)
at liquibase.integration.cdi.CDILiquibase.performUpdate(CDILiquibase.java:129)
at liquibase.integration.cdi.CDILiquibase.onStartup(CDILiquibase.java:116)
… 38 more
If I execute the scripts with ANT and this JDBC driver:
driverclasspath=“org.postgresql.Driver”
jdbcUrl=“jdbc:postgresql://10.1.2.12/mydb”
Everything is working fine.
So I tried also as workaround to populate FIRST the database with
liquibase before starting my wildfly, and I am still getting the issue,
that my H2 classes are pulled instead of the Postgres simpler triggers.
And here the changeset parts:
CREATE OR REPLACE FUNCTION
modify_rowCreated_rowUpdated() RETURNS trigger
LANGUAGE plpgsql
AS $$
DECLARE
current_ts timestamp;
BEGIN
current_ts := CURRENT_TIMESTAMP;
NEW."rowCreated" := current_ts;
NEW."rowUpdated" := current_ts;
RETURN NEW;
END;
$$;
CREATE OR REPLACE FUNCTION
modify_rowUpdated() RETURNS trigger
LANGUAGE plpgsql
AS $$
BEGIN
NEW."rowUpdated" := CURRENT_TIMESTAMP;
RETURN NEW;
END;
$$;
DROP TRIGGER IF EXISTS
"modify_rowCreated_rowUpdated_trigger" ON
"${table.name}" ;
CREATE TRIGGER
"modify_rowCreated_rowUpdated_trigger" BEFORE
INSERT ON "${table.name}" FOR EACH ROW EXECUTE
PROCEDURE modify_rowCreated_rowUpdated();
DROP TRIGGER IF EXISTS "modify_rowUpdated_trigger"
ON "${table.name}";
CREATE TRIGGER "modify_rowUpdated_trigger" BEFORE
UPDATE ON "${table.name}" FOR EACH ROW EXECUTE
PROCEDURE modify_rowUpdated();
CREATE TRIGGER IF NOT EXISTS modify_rowCreated_rowUpdated_trigger
BEFORE INSERT ON ${table.name} FOR EACH ROW CALL "com.x.db.h2.ModifyRowCreatedRowUpdatedTrigger";
CREATE TRIGGER IF NOT EXISTS modify_rowUpdated_trigger BEFORE UPDATE
ON ${table.name} FOR EACH ROW CALL "com.x.db.h2.ModifyRowUpdatedTrigger";
Can someone help me out of the dark?
Versions:
Liquibase 3.4.1
Wildfly 8.2.0
JDK 1.8.0_45
best wishes,
Darko