Liquibase Error when using logback.xml in JMIX Project

I use a logback file to store logs in an array so that I can read them in the UI.

Unfortunately I have problems with this, because when I regenerate / update the database a ClassNotFoundException is thrown by Liquibase.

<configuration>
    <!-- UNCOMMENT IF YOU RECREATE DATABASE -->

    <appender name="MEMORY" class="de.bytestore.hostinger.listener.InMemoryAppender">
        <encoder>
            <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
        </encoder>
    </appender>

    <root level="info">
        <appender-ref ref="MEMORY"/>
    </root>
</configuration>

Appender Class:

package de.bytestore.hostinger.listener;

import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.core.UnsynchronizedAppenderBase;
import lombok.Getter;

import java.util.ArrayList;
import java.util.concurrent.LinkedBlockingDeque;


public class InMemoryAppender extends UnsynchronizedAppenderBase<ILoggingEvent> {
    @Getter
    static final LinkedBlockingDeque<ILoggingEvent> events = new LinkedBlockingDeque<>(1024);

    static final ArrayList<InMemoryListener> listeners = new ArrayList<>();

    /**
     * Attaches a given InMemoryListener to the listeners list.
     * The attached listener will receive events and updates.
     *
     * @param listenerIO The InMemoryListener to attach.
     */
    public static void attach(InMemoryListener listenerIO) {
        listeners.add(listenerIO);
    }

    /**
     * Detaches a given InMemoryListener from the listeners list.
     * The detached listener will no longer receive events and updates.
     *
     * @param listenerIO The InMemoryListener to detach.
     */
    public static void detach(InMemoryListener listenerIO) {
        listeners.remove(listenerIO);
    }

    /**
     * Appends a logging event to the list of events.
     * If the list exceeds the size limit of 1024, the oldest event will be removed.
     *
     * @param event the logging event to append
     */
    @Override
    protected void append(ILoggingEvent event) {
        // Print Output.
        System.out.println(event.getFormattedMessage());

        // Remove old Logs.
        if (events.size() > 1024) {
            events.removeFirst();
        }

        // Add last Log.
        events.addLast(event);

        // Sometimes it's holding Thread in this line... @todo

        // Print Message for all Listeners.
        listeners.forEach(listener -> {
            listener.onLog(event);
        });
    }
}
12:33:50,822 |-ERROR in ch.qos.logback.core.model.processor.AppenderModelHandler - Could not create an Appender of type [de.bytestore.hostinger.listener.InMemoryAppender]. ch.qos.logback.core.util.DynamicClassLoadingException: Failed to instantiate type de.bytestore.hostinger.listener.InMemoryAppender
	at ch.qos.logback.core.util.DynamicClassLoadingException: Failed to instantiate type de.bytestore.hostinger.listener.InMemoryAppender
	at 	at ch.qos.logback.core.util.OptionHelper.instantiateByClassNameAndParameter(OptionHelper.java:69)
	at 	at ch.qos.logback.core.util.OptionHelper.instantiateByClassName(OptionHelper.java:44)
	at 	at ch.qos.logback.core.util.OptionHelper.instantiateByClassName(OptionHelper.java:33)
	at 	at ch.qos.logback.core.model.processor.AppenderModelHandler.handle(AppenderModelHandler.java:67)
	at 	at ch.qos.logback.core.model.processor.DefaultProcessor.secondPhaseTraverse(DefaultProcessor.java:241)
	at 	at ch.qos.logback.core.model.processor.DefaultProcessor.secondPhaseTraverse(DefaultProcessor.java:253)
	at 	at ch.qos.logback.core.model.processor.DefaultProcessor.traversalLoop(DefaultProcessor.java:90)
	at 	at ch.qos.logback.core.model.processor.DefaultProcessor.process(DefaultProcessor.java:106)
	at 	at ch.qos.logback.core.joran.GenericXMLConfigurator.processModel(GenericXMLConfigurator.java:208)
	at 	at ch.qos.logback.core.joran.GenericXMLConfigurator.doConfigure(GenericXMLConfigurator.java:170)
	at 	at ch.qos.logback.core.joran.GenericXMLConfigurator.doConfigure(GenericXMLConfigurator.java:122)
	at 	at ch.qos.logback.core.joran.GenericXMLConfigurator.doConfigure(GenericXMLConfigurator.java:65)
	at 	at ch.qos.logback.classic.util.DefaultJoranConfigurator.configureByResource(DefaultJoranConfigurator.java:68)
	at 	at ch.qos.logback.classic.util.DefaultJoranConfigurator.configure(DefaultJoranConfigurator.java:35)
	at 	at ch.qos.logback.classic.util.ContextInitializer.invokeConfigure(ContextInitializer.java:122)
	at 	at ch.qos.logback.classic.util.ContextInitializer.autoConfig(ContextInitializer.java:97)
	at 	at ch.qos.logback.classic.util.ContextInitializer.autoConfig(ContextInitializer.java:65)
	at 	at ch.qos.logback.classic.spi.LogbackServiceProvider.initializeLoggerContext(LogbackServiceProvider.java:52)
	at 	at ch.qos.logback.classic.spi.LogbackServiceProvider.initialize(LogbackServiceProvider.java:41)
	at 	at org.slf4j.LoggerFactory.bind(LoggerFactory.java:195)
	at 	at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:182)
	at 	at org.slf4j.LoggerFactory.getProvider(LoggerFactory.java:490)
	at 	at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:476)
	at 	at org.apache.logging.slf4j.SLF4JLogger.<clinit>(SLF4JLogger.java:39)
	at 	at org.apache.logging.slf4j.SLF4JLoggerContext.getLogger(SLF4JLoggerContext.java:36)
	at 	at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:666)
	at 	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
	at 	at java.base/java.lang.reflect.Method.invoke(Method.java:578)
	at 	at org.hsqldb.lib.FrameworkLogger.<init>(Unknown Source)
	at 	at org.hsqldb.lib.FrameworkLogger.getLog(Unknown Source)
	at 	at org.hsqldb.lib.FrameworkLogger.getLog(Unknown Source)
	at 	at org.hsqldb.persist.Logger.getEventLogger(Unknown Source)
	at 	at org.hsqldb.persist.Logger.logDetailEvent(Unknown Source)
	at 	at org.hsqldb.persist.Log.closeLog(Unknown Source)
	at 	at org.hsqldb.persist.Log.close(Unknown Source)
	at 	at org.hsqldb.persist.Logger.close(Unknown Source)
	at 	at org.hsqldb.Database.close(Unknown Source)
	at 	at org.hsqldb.Database.closeIfLast(Unknown Source)
	at 	at org.hsqldb.Session.close(Unknown Source)
	at 	at org.hsqldb.jdbc.JDBCConnection.close(Unknown Source)
	at 	at liquibase.database.jvm.JdbcConnection.close(JdbcConnection.java:262)
	at 	at liquibase.database.AbstractJdbcDatabase.close(AbstractJdbcDatabase.java:1209)
	at 	at liquibase.integration.commandline.Main.doMigration(Main.java:1923)
	at 	at liquibase.integration.commandline.Main$1.lambda$run$0(Main.java:415)
	at 	at liquibase.Scope.lambda$child$0(Scope.java:187)
	at 	at liquibase.Scope.child(Scope.java:196)
	at 	at liquibase.Scope.child(Scope.java:186)
	at 	at liquibase.Scope.child(Scope.java:165)
	at 	at liquibase.integration.commandline.Main$1.run(Main.java:414)
	at 	at liquibase.integration.commandline.Main$1.run(Main.java:231)
	at 	at liquibase.Scope.child(Scope.java:196)
	at 	at liquibase.Scope.child(Scope.java:172)
	at 	at liquibase.integration.commandline.Main.run(Main.java:231)
	at 	at liquibase.integration.commandline.Main.main(Main.java:173)
Caused by: java.lang.ClassNotFoundException: de.bytestore.hostinger.listener.InMemoryAppender
	at 	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
	at 	at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
	at 	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
	at 	at ch.qos.logback.core.util.OptionHelper.instantiateByClassNameAndParameter(OptionHelper.java:56)
	at 	... 53 common frames omitted
12:33:50,822 |-ERROR in ch.qos.logback.core.model.processor.DefaultProcessor@46185a1b - Failed to traverse model appender ch.qos.logback.core.model.processor.ModelHandlerException: ch.qos.logback.core.util.DynamicClassLoadingException: Failed to instantiate type de.bytestore.hostinger.listener.InMemoryAppender
	at ch.qos.logback.core.model.processor.ModelHandlerException: ch.qos.logback.core.util.DynamicClassLoadingException: Failed to instantiate type de.bytestore.hostinger.listener.InMemoryAppender
	at 	at ch.qos.logback.core.model.processor.AppenderModelHandler.handle(AppenderModelHandler.java:75)
	at 	at ch.qos.logback.core.model.processor.DefaultProcessor.secondPhaseTraverse(DefaultProcessor.java:241)
	at 	at ch.qos.logback.core.model.processor.DefaultProcessor.secondPhaseTraverse(DefaultProcessor.java:253)
	at 	at ch.qos.logback.core.model.processor.DefaultProcessor.traversalLoop(DefaultProcessor.java:90)
	at 	at ch.qos.logback.core.model.processor.DefaultProcessor.process(DefaultProcessor.java:106)
	at 	at ch.qos.logback.core.joran.GenericXMLConfigurator.processModel(GenericXMLConfigurator.java:208)
	at 	at ch.qos.logback.core.joran.GenericXMLConfigurator.doConfigure(GenericXMLConfigurator.java:170)
	at 	at ch.qos.logback.core.joran.GenericXMLConfigurator.doConfigure(GenericXMLConfigurator.java:122)
	at 	at ch.qos.logback.core.joran.GenericXMLConfigurator.doConfigure(GenericXMLConfigurator.java:65)
	at 	at ch.qos.logback.classic.util.DefaultJoranConfigurator.configureByResource(DefaultJoranConfigurator.java:68)
	at 	at ch.qos.logback.classic.util.DefaultJoranConfigurator.configure(DefaultJoranConfigurator.java:35)
	at 	at ch.qos.logback.classic.util.ContextInitializer.invokeConfigure(ContextInitializer.java:122)
	at 	at ch.qos.logback.classic.util.ContextInitializer.autoConfig(ContextInitializer.java:97)
	at 	at ch.qos.logback.classic.util.ContextInitializer.autoConfig(ContextInitializer.java:65)
	at 	at ch.qos.logback.classic.spi.LogbackServiceProvider.initializeLoggerContext(LogbackServiceProvider.java:52)
	at 	at ch.qos.logback.classic.spi.LogbackServiceProvider.initialize(LogbackServiceProvider.java:41)
	at 	at org.slf4j.LoggerFactory.bind(LoggerFactory.java:195)
	at 	at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:182)
	at 	at org.slf4j.LoggerFactory.getProvider(LoggerFactory.java:490)
	at 	at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:476)
	at 	at org.apache.logging.slf4j.SLF4JLogger.<clinit>(SLF4JLogger.java:39)
	at 	at org.apache.logging.slf4j.SLF4JLoggerContext.getLogger(SLF4JLoggerContext.java:36)
	at 	at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:666)
	at 	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
	at 	at java.base/java.lang.reflect.Method.invoke(Method.java:578)
	at 	at org.hsqldb.lib.FrameworkLogger.<init>(Unknown Source)
	at 	at org.hsqldb.lib.FrameworkLogger.getLog(Unknown Source)
	at 	at org.hsqldb.lib.FrameworkLogger.getLog(Unknown Source)
	at 	at org.hsqldb.persist.Logger.getEventLogger(Unknown Source)
	at 	at org.hsqldb.persist.Logger.logDetailEvent(Unknown Source)
	at 	at org.hsqldb.persist.Log.closeLog(Unknown Source)
	at 	at org.hsqldb.persist.Log.close(Unknown Source)
	at 	at org.hsqldb.persist.Logger.close(Unknown Source)
	at 	at org.hsqldb.Database.close(Unknown Source)
	at 	at org.hsqldb.Database.closeIfLast(Unknown Source)
	at 	at org.hsqldb.Session.close(Unknown Source)
	at 	at org.hsqldb.jdbc.JDBCConnection.close(Unknown Source)
	at 	at liquibase.database.jvm.JdbcConnection.close(JdbcConnection.java:262)
	at 	at liquibase.database.AbstractJdbcDatabase.close(AbstractJdbcDatabase.java:1209)
	at 	at liquibase.integration.commandline.Main.doMigration(Main.java:1923)
	at 	at liquibase.integration.commandline.Main$1.lambda$run$0(Main.java:415)
	at 	at liquibase.Scope.lambda$child$0(Scope.java:187)
	at 	at liquibase.Scope.child(Scope.java:196)
	at 	at liquibase.Scope.child(Scope.java:186)
	at 	at liquibase.Scope.child(Scope.java:165)
	at 	at liquibase.integration.commandline.Main$1.run(Main.java:414)
	at 	at liquibase.integration.commandline.Main$1.run(Main.java:231)
	at 	at liquibase.Scope.child(Scope.java:196)
	at 	at liquibase.Scope.child(Scope.java:172)
	at 	at liquibase.integration.commandline.Main.run(Main.java:231)
	at 	at liquibase.integration.commandline.Main.main(Main.java:173)
Caused by: ch.qos.logback.core.util.DynamicClassLoadingException: Failed to instantiate type de.bytestore.hostinger.listener.InMemoryAppender
	at 	at ch.qos.logback.core.util.OptionHelper.instantiateByClassNameAndParameter(OptionHelper.java:69)
	at 	at ch.qos.logback.core.util.OptionHelper.instantiateByClassName(OptionHelper.java:44)
	at 	at ch.qos.logback.core.util.OptionHelper.instantiateByClassName(OptionHelper.java:33)
	at 	at ch.qos.logback.core.model.processor.AppenderModelHandler.handle(AppenderModelHandler.java:67)
	at 	... 50 common frames omitted
Caused by: java.lang.ClassNotFoundException: de.bytestore.hostinger.listener.InMemoryAppender
	at 	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
	at 	at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
	at 	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
	at 	at ch.qos.logback.core.util.OptionHelper.instantiateByClassNameAndParameter(OptionHelper.java:56)
	at 	... 53 common frames omitted
12:33:50,822 |-INFO in ch.qos.logback.core.model.processor.DefaultProcessor@46185a1b - End of configuration.

The error only occurs when I generate an entity or recreate the database.

If I start JMIX normally, there are no problems ;(

Is there a way to ignore the logback file in Liquibase?

Hi

It seems that the issue caused by HSQL DB, not Liquibase. Did you try to switch to another DB type?

It also would be helpful if you share test project with such configuration.

1 Like

Unfortunately, the basic problem is that when I create a new entity, no changelog is created.

I have removed the logback again, I do not receive any error messages from JMIX Studio, can I debug this?

idea.zip (515,1 KB)

Hi

I see the following line in your log:

023-12-16 09:29:14,662 [1007637]   WARN - liquibase.ext - Diff changelog command failed

That is the reason why you have no changelogs generated.
Unfortunately in the current plugin version there is no logging for such error.
We added such logging but you need to install NIGHTLY version of Jmix plugin to get this update.
See Installation :: Jmix Documentation
With nightly build installed try to generate changelog again and there should be notification with error message and stacktrace in the idea.log.

Here is my IntelliJ Log :slight_smile:

idea.zip (25,4 KB)

Regards

For Example this Entity:

Worked before this strange Error:

@Table(name = "HOST_PROCESS", indexes = {
        @Index(name = "IDX_HOST_PROCESS_PORT_BINDING", columnList = "PORT_BINDING_ID", unique = true)
})

   ...
 
@OneToOne(fetch = FetchType.LAZY, mappedBy = "processes")
private PortBinding portBinding;

image

Now with new created Entity 1:1 via UI:

@Table(name = "HOST_PROCESS", indexes = {
        @Index(name = "IDX_HOST_PROCESS_PORT_BINDING", columnList = "PORT_BINDING_ID")
})

   ...
    
@JoinColumn(name = "PORT_BINDING_ID")
@OneToOne(fetch = FetchType.LAZY)
private PortBinding portBinding;

image

Strangely, “Owning side” is active for the newly created entity, either this option is new or I never noticed it.

Thanks for sharing your logs! Your entity annotations seem to have columns that don’t exist. Did fixing the annotations solve the problem?
Regarding the different state of the Owning side property, are you sure you created a One to One association from the same entity in both cases? Perhaps in the first case Owning side is specified for the PortBinding entity? It is not a new option.

I would have expected the same from the stacktrace error, but the key mentioned was present in the other table.

I have linked the entity in both tables as I remember it, but I can check the GIT changelog and let you know if I am wrong.

Nevertheless, thanks for the nightly version, it has helped me a lot :slight_smile: Without error logging the whole thing was a bit difficulty :slight_smile: