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

Exception when 'run' goal is executed for SpringBoot repackaged WAR with looseApplication=false and SB deploy #1793

Open
scottkurz opened this issue Feb 13, 2024 · 0 comments

Comments

@scottkurz
Copy link
Member

scottkurz commented Feb 13, 2024

If I start with the SpringBoot pet clinic sample, e.g. something like (spring-projects/spring-petclinic@082cfb4 - though I didn't verify this exact commit would recreate the problem:

and do:

mvn package liberty:run -DlooseApplication=false -DdeployPackages=spring-boot-project -Dspring-javaformat.skip -Dcheckstyle.skip -DskipTests -e

I get the error

Caused by: org.apache.maven.plugin.MojoExecutionException: C:\ydosppa\apps\spring-petclinic\target\spring-petclinic-3.2.0-SNAPSHOT.war file is not an executable archive. The repackage goal of the spring-boot-maven-plugin must be configured to run first in order to create the required executable archive.
    at io.openliberty.tools.maven.applications.DeployMojo.installSpringBootApp (DeployMojo.java:130)
    at io.openliberty.tools.maven.applications.DeployMojo.doDeploy (DeployMojo.java:93)
    at io.openliberty.tools.maven.applications.DeployMojo.execute (DeployMojo.java:61)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
    at org.twdata.maven.mojoexecutor.MojoExecutor.executeMojo (MojoExecutor.java:120)
    at io.openliberty.tools.maven.server.StartDebugMojoSupport.runLibertyMojo (StartDebugMojoSupport.java:380)
    at io.openliberty.tools.maven.server.StartDebugMojoSupport.runLibertyMojoDeploy (StartDebugMojoSupport.java:343)
    at io.openliberty.tools.maven.server.RunServerMojo.doRunServer (RunServerMojo.java:133)

EXPLANATION

The liberty:run mojo, as an "all-in-one" goal, assumes it needs to do a package step if "loose" is disabled (set to false), and so it calls the war:war goal. This wrongly replaces the SpringBoot-repackaged WAR with a plain WAR, leading to this error.

We might want to skip war:war in a case like this, when the user has selected a SpringBoot deploy package.

WORKAROUND

Just use:

mvn package liberty:run -DlooseApplication=false -DdeployPackages=spring-boot-project ...

There's no need in this use case to explictly set -DlooseApplication=false. For a SpringBoot deploy package, there's no option to use loose applications anyway at the moment. Probably someone is just copying instructions from somewhere if they're trying to use this anyway.

ALSO

We leverage the fact that in some ways an executable/Uber WAR looks just look a similar JAR.

That said messages like this:

[WARNING] The file at the following location is not a Spring Boot Uber JAR:

could perhaps be improved by generalizing the language to "..Uber JAR or WAR", or something like that.

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

No branches or pull requests

1 participant