无法初始化类 liquibase.sqlgenerator.core.LockDatabaseChangeLogGenerator

Posted

技术标签:

【中文标题】无法初始化类 liquibase.sqlgenerator.core.LockDatabaseChangeLogGenerator【英文标题】:Could not initialize class liquibase.sqlgenerator.core.LockDatabaseChangeLogGenerator 【发布时间】:2014-10-22 02:11:12 【问题描述】:

当我尝试运行 maven 测试时遇到此问题。不确定是什么导致了问题,因为这些测试之前运行没有问题。我的依赖项由 maven 管理

Caused by: java.lang.NoClassDefFoundError: Could not initialize class liquibase.sqlgenerator.core.LockDatabaseChangeLogGenerator
at sun.reflect.GeneratedConstructorAccessor379.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:408)
at liquibase.sqlgenerator.SqlGeneratorFactory.<init>(SqlGeneratorFactory.java:39)
at liquibase.sqlgenerator.SqlGeneratorFactory.getInstance(SqlGeneratorFactory.java:53)
at liquibase.executor.AbstractExecutor.applyVisitors(AbstractExecutor.java:22)
at liquibase.executor.jvm.JdbcExecutor.access$500(JdbcExecutor.java:35)
at liquibase.executor.jvm.JdbcExecutor$ExecuteStatementCallback.doInStatement(JdbcExecutor.java:284)
at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:54)
at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:106)
at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:96)
at liquibase.lockservice.StandardLockService.init(StandardLockService.java:83)
at liquibase.lockservice.StandardLockService.acquireLock(StandardLockService.java:182)
at liquibase.lockservice.StandardLockService.waitForLock(StandardLockService.java:148)
at liquibase.Liquibase.update(Liquibase.java:189)
at liquibase.Liquibase.update(Liquibase.java:181)
at liquibase.integration.spring.SpringLiquibase.performUpdate(SpringLiquibase.java:342)
at liquibase.integration.spring.SpringLiquibase.afterPropertiesSet(SpringLiquibase.java:299)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1571)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1509)

【问题讨论】:

【参考方案1】:

在 OSX 上测试的快速修复:

在您的控制台中输入:

$ hostname -f   

输出应该看起来像这样:

MAC008.local

将此作为本地主机添加到您的主机文件中:

$ sudo vi /etc/hosts 

看起来有点像这样:

##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting.  Do not change this entry.
##
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1             localhost 
fe80::1%lo0 localhost
127.0.0.1 MAC008.local

更改网络后重复。

【讨论】:

【参考方案2】:

从 Windows 切换到 Linux 后,我遇到了同样的问题。我发现了模拟错误https://liquibase.jira.com/browse/CORE-1943 我配置了nss-myhostname,这个错误就消失了。

【讨论】:

以上是关于无法初始化类 liquibase.sqlgenerator.core.LockDatabaseChangeLogGenerator的主要内容,如果未能解决你的问题,请参考以下文章

无法初始化类对象:Objective-C

“NoClassDefFoundError:无法初始化类”错误

排毒 - 无法初始化类 DefaultKotlinSourceSetKt

> 无法初始化类 com.android.repository.api.RepoManager

无法将一个类包含到 Ruby 中的另一个类中:未初始化的常量 (NameError)

无法初始化类 org.codehaus.groovy.reflection.ReflectionCache