liquibase / liquibase-gradle-plugin

A Gradle plugin for Liquibase
Other
197 stars 57 forks source link

Cannot find main class Corporation #65

Closed lucasmontec closed 3 years ago

lucasmontec commented 4 years ago

The plugin seems to be misbehaving with spaces in the run command. I'm getting a 'java.lang.ClassNotFoundException: Corporation'. Inspecting the execution with --info I found out that the run command line is not wrapping the vendor in " for all the cases:

-Djava.vm.specification.vendor=Oracle Corporation -Djava.vm.specification.version=10 -Djava.vm.vendor="Oracle Corporation"

It looks like the run command line is trying to set the vendor but without quotes, which causes java to think that the main class is Corporation.

stevesaliman commented 4 years ago

Can you provide the relevant parts of the liquibase block of your build.gradle file, along with the command line you're using to run Gradle? That will help me to determine why some properties are wrapped properly, but others aren't

lucasmontec commented 4 years ago

Unfortunately I gave up using the plugin temporarily and lost the exact configuration, but I'll rebuild here what I did the best I can.

build.gradle:

diff.dependsOn compileJava diffChangeLog.dependsOn compileJava generateChangelog.dependsOn compileJava

liquibase { activities { main { changeLogFile '' url '' username 'user' password 'pass' } }}

dependencies {

liquibaseRuntime 'org.liquibase:liquibase-core:3.6.1' liquibaseRuntime 'org.liquibase:liquibase-groovy-dsl:2.0.1' liquibaseRuntime ''

liquibaseRuntime('org.springframework.boot:spring-boot-starter-data-jpa')

liquibaseRuntime sourceSets.main.output

}

It was something along those lines. I have followed several posts to configure, and also the readme on the github page.

https://stackoverflow.com/questions/52517215/setup-liquibase-in-a-gradle-spring-boot-hibernate-project

I can try to recreate the same setup on next monday if the information provided here is insufficient. For now, I'll be writing my changelogs by hand as I always did.

On Fri, Feb 14, 2020, 19:14 Steven C. Saliman notifications@github.com wrote:

Can you provide the relevant parts of the liquibase block of your build.gradle file, along with the command line you're using to run Gradle? That will help me to determine why some properties are wrapped properly, but others aren't

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/liquibase/liquibase-gradle-plugin/issues/65?email_source=notifications&email_token=AAKRX7O2N23GGDI5WIZWIILRC4JVNA5CNFSM4KVPLZP2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEL2TBNI#issuecomment-586494133, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAKRX7OHPOWYFSBQSZBVDADRC4JVNANCNFSM4KVPLZPQ .

stevesaliman commented 4 years ago

There is nothing in the plugin itself that would try to set the vendor, so I'm trying to figure out where they are coming from. Either they are activity parameters - which doesn't seem to be the case from the config above - or it is being passed in some other way, and my guess is that there is a quoting issue there.

stevesaliman commented 4 years ago

I tried running a Gradle 5.4.1 and 6.2 on a local project, and I don't see of the vm properties passed to Liquibase. I'm using Java 8, and when I print the System properties from within my build.gradle file, I see java.vm.specification.vendor, and it is also set to "Oracle Corporation", but they are not being passed to the Liquibase command being run.

My hunch is that if you look at the process the plugin is starting, the -D options that are causing you the problem appear before the classpath of the command. The liquibase plugin only creates -D arguments after the main class name. So something in your environment is causing Gradle to pass more system properties in the command.

I do notice you have a Spring Boot dependency in your liquibaseRuntime. Exactly what Gradle command are you running when you get the error?

lucasmontec commented 4 years ago

I'm sorry, we are a small startup and we don't have time when plugins don't work out of the box. I'll be trying again this exact procedure next week, after Brazilian carnival and I'll gather all the necessary data and setup for you.

Sorry for the inconvenience.

On Sat, Feb 22, 2020, 15:38 Steven C. Saliman notifications@github.com wrote:

I tried running a Gradle 5.4.1 and 6.2 on a local project, and I don't see of the vm properties passed to Liquibase. I'm using Java 8, and when I print the System properties from within my build.gradle file, I see java.vm.specification.vendor, and it is also set to "Oracle Corporation", but they are not being passed to the Liquibase command being run.

My hunch is that if you look at the process the plugin is starting, the -D options that are causing you the problem appear before the classpath of the command. The liquibase plugin only creates -D arguments after the main class name. So something in your environment is causing Gradle to pass more system properties in the command.

I do notice you have a Spring Boot dependency in your liquibaseRuntime. Exactly what Gradle command are you running when you get the error?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/liquibase/liquibase-gradle-plugin/issues/65?email_source=notifications&email_token=AAKRX7JAZUHPJNEMFYHQFETREFWLRA5CNFSM4KVPLZP2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEMVHPXA#issuecomment-589985756, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAKRX7KCG6F4MYPCYZVEMX3REFWLRANCNFSM4KVPLZPQ .

stevesaliman commented 4 years ago

I've done some more testing, and I now see the java.vm.specification.vendor in my output. It is Oracle Corporation without quotes, just like your output. But it doesn't prevent Liquibase from running in my case. I'm running in a Linux environment.

When you get some time, I'd be interested to see the full command being executed by the plugin - it will be the line beginning "Starting process" in your log file. You'll obviously want to replace the database credentials.

Also are you running in Linux, Windows, or a Mac?

lucasmontec commented 4 years ago

I'm running on Windows. I'll get those logs asap.

On Sun, Feb 23, 2020, 11:29 Steven C. Saliman notifications@github.com wrote:

I've done some more testing, and I now see the java.vm.specification.vendor in my output. It is Oracle Corporation without quotes, just like your output. But it doesn't prevent Liquibase from running in my case. I'm running in a Linux environment.

When you get some time, I'd be interested to see the full command being executed by the plugin - it will be the line beginning "Starting process" in your log file. You'll obviously want to replace the database credentials.

Also are you running in Linux, Windows, or a Mac?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/liquibase/liquibase-gradle-plugin/issues/65?email_source=notifications&email_token=AAKRX7N4GRXL7TFP6CTQRL3REKB5RA5CNFSM4KVPLZP2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEMV5FFY#issuecomment-590074519, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAKRX7J3UPCJMXACEACUPVDREKB5RANCNFSM4KVPLZPQ .

stevesaliman commented 4 years ago

This is getting more and more interesting :-)

I just tried to run a gradle update on one of my projects in a Windows 7 environment using Gradle 5.4.1 and both Java 8 and Java 11, but I still can't reproduce the problem.

The liquibase plugin works by defining Gradle tasks of type JavaExec, so whenever you run a gradle liquibase task, it starts up a new process to do the work. There is some difference between the way this process starts on my system and your system, but I can't figure out what it might be.

lucasmontec commented 4 years ago

I was running this within eclipse. Earlier I was having problems also with spaces on the project path. I changed the gradle cache directory to be in the root of my D drive (non primary drive). This solved all the problems with spaces. Maybe it is a problem with eclipse and not with your plugin. When I try this I'll try executing using the command line also.

On Sun, Feb 23, 2020, 17:02 Steven C. Saliman notifications@github.com wrote:

This is getting more and more interesting :-)

I just tried to run a gradle update on one of my projects in a Windows 7 environment using Gradle 5.4.1 and both Java 8 and Java 11, but I still can't reproduce the problem.

The liquibase plugin works by defining Gradle tasks of type JavaExec, so whenever you run a gradle liquibase task, it starts up a new process to do the work. There is some difference between the way this process starts on my system and your system, but I can't figure out what it might be.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/liquibase/liquibase-gradle-plugin/issues/65?email_source=notifications&email_token=AAKRX7O4QXFVVIV67AYZOALRELI4XA5CNFSM4KVPLZP2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEMWFYQI#issuecomment-590109761, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAKRX7NH3UZVQ5WUWNLJ4ZLRELI4XANCNFSM4KVPLZPQ .

stevesaliman commented 3 years ago

Closing due to inactivity, and the fact that I can't reproduce this in any of my environments.