Skip to content

NoClassDefFoundError when running with Liquibase 2.x #11608

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
tony-pelton opened this issue Jan 11, 2018 · 1 comment
Closed

NoClassDefFoundError when running with Liquibase 2.x #11608

tony-pelton opened this issue Jan 11, 2018 · 1 comment
Assignees
Labels
type: bug A general bug
Milestone

Comments

@tony-pelton
Copy link

tony-pelton commented Jan 11, 2018

i'm trying to get a spring 4.x application onto spring-boot. a problem i've run into, is that you can't have Liquibase 2.x libraries on the classpath or spring-boot intialization fails.

`java.lang.NoClassDefFoundError: liquibase/servicelocator/CustomResolverServiceLocator

at org.springframework.boot.liquibase.LiquibaseServiceLocatorApplicationListener.onApplicationEvent(LiquibaseServiceLocatorApplicationListener.java:44)
at org.springframework.boot.liquibase.LiquibaseServiceLocatorApplicationListener.onApplicationEvent(LiquibaseServiceLocatorApplicationListener.java:35)
at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:167)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:122)
at org.springframework.boot.context.event.EventPublishingRunListener.starting(EventPublishingRunListener.java:68)
at org.springframework.boot.SpringApplicationRunListeners.starting(SpringApplicationRunListeners.java:48)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:303)`

the application listener does this :

if (ClassUtils.isPresent("liquibase.servicelocator.ServiceLocator", null)) { new LiquibasePresent().replaceServiceLocator(); }
the problem is, the class it is looking for exists in 2.x Liquibase, but the classes the "replacer" looks for don't.

and there is no switch to stop this from happening, since it is an application listener.

this is a problem for me, as i'd like to upgrade to 3.x, but i'm having trouble, and wanted to be able to do some testing with 2.x vs 3.x ... but this listener prevents me from having any control at all over whether i can have Liquibase 2.x on the classpath.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jan 11, 2018
@wilkinsona wilkinsona added priority: normal type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged labels Jan 11, 2018
@wilkinsona wilkinsona added this to the 1.5.10 milestone Jan 11, 2018
@wilkinsona
Copy link
Member

wilkinsona commented Jan 11, 2018

Thanks for the analysis. We can tighten things up by checking for liquibase.servicelocator.CustomResolverServiceLocator. In the meantime, you can work around the problem with the following, slightly clunky approach:

SpringApplication application = new SpringApplication(SampleLiquibaseApplication.class);
application.setListeners(application.getListeners().stream()
	.filter((listener) -> !(listener instanceof LiquibaseServiceLocatorApplicationListener))
	.collect(Collectors.toSet()));
application.run(args);

eddumelendez added a commit to eddumelendez/spring-boot that referenced this issue Jan 13, 2018
`CustomResolverServiceLocator` was introduced in Liquibase 2.0.4, this
check prevents failures during initialization when previous versions are
used.

See spring-projectsgh-11608
@snicoll snicoll self-assigned this Jan 16, 2018
@snicoll snicoll changed the title spring-boot 1.5.3 incompatible with Liquibase 2.x NoClassDefFoundError when running with Liquibase 2.x Jan 16, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
Development

No branches or pull requests

4 participants