Skip to content
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

NullPointerException at org.flywaydb.maven.MigrateMojo.doExecute(MigrateMojo.java:35) #905

Closed
cowwoc opened this issue Dec 6, 2014 · 8 comments

Comments

@cowwoc
Copy link

cowwoc commented Dec 6, 2014

Flyway 3.1

Output:

--- flyway-maven-plugin:3.1:migrate (default) @ database ---
Database: jdbc:postgresql://localhost/foo_querydsl (PostgreSQL 9.3)
Possible solution: run mvn compile first so Flyway can find the migrations
Validated 0 migrations (execution time 00:00.014s)
Current version of schema "public": << Empty Schema >>
Schema "public" is up to date. No migration necessary.
[...]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.flywaydb:flyway-maven-plugin:3.1:migrate (default) on project database: java.lang.NullPointerException
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:217)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
    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.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
Caused by: org.apache.maven.plugin.MojoExecutionException: java.lang.NullPointerException
    at org.flywaydb.maven.AbstractFlywayMojo.execute(AbstractFlywayMojo.java:509)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
    ... 19 more
Caused by: java.lang.NullPointerException
    at org.flywaydb.maven.MigrateMojo.doExecute(MigrateMojo.java:35)
    at org.flywaydb.maven.AbstractFlywayMojo.execute(AbstractFlywayMojo.java:507)
    ... 21 more

I assume this is triggered by user error, but Flyway shouldn't be throwing an exception.

@cowwoc
Copy link
Author

cowwoc commented Dec 6, 2014

Looking at the code (and my project) I think this exception is caused by the fact that Flyway assumes at least one migration will be found. You probably need to add an explicit check in case no migrations are found.

@axelfontaine
Copy link
Contributor

Uh oh, that's never good. Consider this fixed in time for the next release. Pull request also welcome.

@bmurillop
Copy link

Hi, Is there anyway I can help you with this ? Im trying to get it working, and it's really annoying that it wont work right out of the box. I guess I can manually add the entry to the table, but I was wondering if I can help you in here.

axelfontaine pushed a commit to flyway/flywaydb.org that referenced this issue Mar 4, 2015
@MrEcko
Copy link

MrEcko commented May 6, 2015

This bug is happening in Flyway 3.2.1.

@axelfontaine
Copy link
Contributor

@MrEcko Please verify the stacktrace to make sure it is the same problem. If it isn't, please open a separate issue.

Cheers
Axel

@MrEcko
Copy link

MrEcko commented May 6, 2015

It is the same


On a side note, i got to this by going with the default sqlMigrationPrefix but naming the migrations with v (lower case). Worked after prefixing the files with V.


[INFO] Flyway 3.2.1 by Boxfuse

[INFO] Database: jdbc:oracle:thin:@//x.y.z.t:p/somesid (Oracle 11.2)

[WARNING] Possible solution: run mvn compile first so Flyway can find the migrations

[INFO] Validated 0 migrations (execution time 00:00.007s)

[INFO] Current version of schema "THESCHEMA": << Empty Schema >>

[INFO] Schema "THESCHEMA" is up to date. No migration necessary.

[ERROR] Failed to execute goal org.flywaydb:flyway-maven-plugin:3.2.1:migrate (default-cli) on project SOMEPROJECT: java.lang.NullPointerException -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.flywaydb:flyway-maven-plugin:3.2.1:migrate (default-cli) on project SOMEPROJECT:
java.lang.NullPointerException
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:216)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:317)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:152)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:555)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:214)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:158)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.plugin.MojoExecutionException: java.lang.NullPointerException
at org.flywaydb.maven.AbstractFlywayMojo.execute(AbstractFlywayMojo.java:526)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:106)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
... 19 more
Caused by: java.lang.NullPointerException
at java.util.Hashtable.put(Hashtable.java:514)
at java.util.Properties.setProperty(Properties.java:161)
at org.flywaydb.maven.MigrateMojo.doExecute(MigrateMojo.java:38)
at org.flywaydb.maven.AbstractFlywayMojo.execute(AbstractFlywayMojo.java:524)

@axelfontaine
Copy link
Contributor

Good catch! Reopening. Thanks.

@axelfontaine axelfontaine reopened this May 6, 2015
@axelfontaine axelfontaine modified the milestones: Flyway 4.0, Flyway 3.2 May 6, 2015
axelfontaine pushed a commit to flyway/flywaydb.org that referenced this issue Oct 28, 2015
@axelfontaine
Copy link
Contributor

Fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants