-
Notifications
You must be signed in to change notification settings - Fork 40.2k
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
Error deploying a Spring Boot / Liquibase app on Cloud Foundry #1792
Comments
Is it an executable JAR? Cloud Foundry runs that as an exploded archive, which is probably different than the other platforms. Can you run it locally by exploding your JAR and running with "-classpath ."? |
Hi @dsyer ! |
I got it working by adding:
This is of course a big hack, the root cause of the issue being that Liquibase fails to start when running
This is only on CloudFoundry, and you would (of course) expect that Spring Boot works on Cloud Foundry! I'm going to clean up and test everything, I will post here when I have something correct. |
There is a pull request in to spring-boot to support the new Liquibase API. There have been additional fixes in Liquibase that may help as well if you can get it updated to the newest version. Note: I'm working to get 3.3.0 out today. |
Thanks @nvoxland ! |
I'm closing this as my hack works, still I don't find this very user-friendly! |
While the workaround lowers the priority of this issue, I don't think it should be closed. At the least, it would be nice to understand why Liquibase is unable to read from a |
@wilkinsona I do find that strange since I'm guessing that Boot itself reads that file when starting... |
Actually @wilkinsona, is the answer in the IBM issue? Is it possible that Liquibase is using |
As far as I can tell the comment on the IBM issue is wrong. |
Perhaps CloudFoundry customises the handler for |
No, that's not likely to be it. I build OpenJDK directly and it's as stock as I can make it. @jdubois Can you please provide me with a fully built JAR as it would be deployed to Cloud Foundry? I'll take a look at reproducing the issue using the exact command line that Cloud Foundry would use, but I don't think it's related to Cloud Foundry per se. In fact, I believe that Sagan originally used Liquibase in Spring Boot on Cloud Foundry without any problems at all. |
@nebhale sure, do you want it working with MySQL or Postgresql? |
Anything that reproduces your problem will work. |
Here is one: It's working with Postgresql, with the "prod" profile. Here is my manifest.yml:
And here is the output (of course it works without my hack!):
|
So, step one of diagnosis is to run this using the buildpack, but locally on the machine: bhale-desktop: detect
java-buildpack=647c0bd-https://github.com/cloudfoundry/java-buildpack.git#647c0bd java-main open-jdk-jre=1.8.0_25 spring-auto-reconfiguration=1.5.0_RELEASE bhale-desktop: compile
-----> Java Buildpack Version: 647c0bd | https://github.com/cloudfoundry/java-buildpack.git#647c0bd
-----> Downloading Open Jdk JRE 1.8.0_25 from https://download.run.pivotal.io/openjdk/mountainlion/x86_64/openjdk-1.8.0_25.tar.gz (15.8s)
Expanding Open Jdk JRE to .java-buildpack/open_jdk_jre (0.6s)
-----> Downloading Spring Auto Reconfiguration 1.5.0_RELEASE from https://download.run.pivotal.io/auto-reconfiguration/auto-reconfiguration-1.5.0_RELEASE.jar (1.1s) bhale-desktop: release
SERVER_PORT=$PORT $PWD/.java-buildpack/open_jdk_jre/bin/java -cp $PWD/.:$PWD/.java-buildpack/spring_auto_reconfiguration/spring_auto_reconfiguration-1.5.0_RELEASE.jar -Djava.io.tmpdir=$TMPDIR -XX:OnOutOfMemoryError=$PWD/.java-buildpack/open_jdk_jre/bin/killjava.sh -XX:MaxMetaspaceSize=64M -XX:MetaspaceSize=64M org.springframework.boot.loader.WarLauncher
bhale-desktop: SERVER_PORT=$PORT $PWD/.java-buildpack/open_jdk_jre/bin/java -cp $PWD/.:$PWD/.java-buildpack/spring_auto_reconfiguration/spring_auto_reconfiguration-1.5.0_RELEASE.jar -Djava.io.tmpdir=$TMPDIR -XX:OnOutOfMemoryError=$PWD/.java-buildpack/open_jdk_jre/bin/killjava.sh -XX:MaxMetaspaceSize=64M -XX:MetaspaceSize=64M org.springframework.boot.loader.WarLauncher
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:483)
at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:53)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.ExceptionInInitializerError
at org.springframework.boot.liquibase.LiquibaseServiceLocatorApplicationListener$LiquibasePresent.replaceServiceLocator(LiquibaseServiceLocatorApplicationListener.java:38)
at org.springframework.boot.liquibase.LiquibaseServiceLocatorApplicationListener.onApplicationEvent(LiquibaseServiceLocatorApplicationListener.java:28)
at org.springframework.boot.liquibase.LiquibaseServiceLocatorApplicationListener.onApplicationEvent(LiquibaseServiceLocatorApplicationListener.java:19)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:98)
at org.springframework.boot.context.event.EventPublishingRunListener.publishEvent(EventPublishingRunListener.java:100)
at org.springframework.boot.context.event.EventPublishingRunListener.started(EventPublishingRunListener.java:54)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:276)
at com.mycompany.myapp.Application.main(Application.java:56)
... 6 more
Caused by: liquibase.exception.UnexpectedLiquibaseException: java.net.UnknownServiceException: protocol doesn't support input
at liquibase.servicelocator.ServiceLocator.setResourceAccessor(ServiceLocator.java:109)
at liquibase.servicelocator.ServiceLocator.<init>(ServiceLocator.java:44)
at liquibase.servicelocator.ServiceLocator.<clinit>(ServiceLocator.java:31)
... 14 more
Caused by: java.net.UnknownServiceException: protocol doesn't support input
at java.net.URLConnection.getInputStream(URLConnection.java:830)
at java.net.URL.openStream(URL.java:1038)
at liquibase.servicelocator.ServiceLocator.setResourceAccessor(ServiceLocator.java:98)
... 16 more The problem is definitely not Cloud Foundry specific, but rather in the way that the application is being run on Cloud Foundry. |
Looks like maybe it's that "-cp ..." enhancement we added (for CF buildpack)? |
Thanks, @nebhale. It's blowing up because Liquibase is being given an |
The problem can be reproduced by downloading the app from @jdubois, unzipping it into a fresh directory, moving into that directory, and running
|
I'm not sure that filtering in @philwebb Have I misunderstood the intent of the current filtering? |
@wilkinsona I can't remember why the original archive is added. I have a feeling that we've improved the embedded Tomcat/Jetty support so that entries from the war can be served. That might not have always been the case and adding the filtered WAR archive might have provided a way around that. I think that |
I have a fix for this issue – it removes the root of the war file from the classpath. While this is correct for a war file, I'm reluctant to make this change in 1.1.x in case anyone was relying on the existing, incorrect behaviour, particularly as the reporter has a workaround. |
I am trying to deploy a Spring Boot 1.1.8 application + Liquibase 3.1.1 application on Cloud Foundry (Version 2/26/2014 (ccbd61)). I've also tried with Liquibase 3.0.8, which is the one provided by default, and I get the same result.
It fails with the stacktrace I have posted at the end of this ticket.
Please note that on the latest (3.2.2) version of Liquibase, they have changed their API and the SpringPackageScanClassResolver does not override the correct method.
I only have this issue on Cloud Foundry, it works everywhere else (my machine, Heroku, Openshift...), so it must be something specific to Cloud Foundry (once again, I am with Version 2/26/2014 (ccbd61)).
BTW, this has also been reported on BlueMix, but as it's based on CloudFoundry (and as the reporter uses a JHipster application, like me) this is the same issue here:
https://developer.ibm.com/answers/questions/27960/using-liquibase-with-bluemix-fails-when-reading-url-file-home-vcap-app-meta-inf-manifest-mf.html
I'm reporting this here as:
I'm notifying @nvoxland because he might also help with this.
The text was updated successfully, but these errors were encountered: