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

Springboot application fails to start with default configuration from version >= 2.5 #979

Open
1 task done
fattila16 opened this issue Sep 25, 2023 · 1 comment
Open
1 task done
Labels
bug Something isn't working

Comments

@fattila16
Copy link
Contributor

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

With the release of spring 2.5, if one uses it along with gradle, by default it will generate a library next to your executable jar, when you run the ./gradlew build command. The default start command generated by the JavaProvider in nixpacks is java $JAVA_OPTS -jar -Dserver.port=$PORT build/libs/*.jar. If there are multiple *.jar files in the build/libs folder it can point to the one which is not an executable, in this case the *plain.jar.

When you run the image you'll get the following error:

no main manifest attribute

This is because it tries to execute a jar, which is in reality a library.

Of course the user can modify the gradle.build configuration, to not generate the *plain.jar, however to provide a better user experience that works without requiring user intervention would be a good thing. (Mentioned here: #677)

Solution:

From spring v2, there is a dedicated gradle task, called bootJar that only generates an executable jar file. If one modifies the JavaProvider to do this, for gradle + spring applications the problem goes away. However, this means that spring v1 applications won't work anymore.

I can provide a PR, along with the modifications to implement this.

My question is, is it okay to drop the support of spring v1 applications? The last release was back in 2007. I am not sure how many users of nixpacks use spring v1, so that would be an interesting metric also to decide this.

To reproduce

Steps to reproduce the bug:

  1. Clone an example spring v3 project, for eg.: https://github.com/appuio/example-spring-boot-helloworld
  2. Run nixpacks build . in the project root
  3. Use docker to run the image
  4. Results in an error: no main manifest attribute, in build/libs/app-0.1.1-SNAPSHOT-plain.jar

Expected behavior

The expected behaviour would be that a default spring >= v2.5 project works out of the box without the need to overwrite default configurations.

Environment

  • OS version: macOS 13.5.2
  • nixpacks version: 1.16.0
@fattila16
Copy link
Contributor Author

PR to fix the issue: #980

coffee-cup pushed a commit that referenced this issue Oct 19, 2023
…980)

* fix: adjust the `JavaProvider.get_start_cmd` so that it finds the executable

jar file if gradle is used, and blacklists plain.jar files

Co-authored-by: Tibor Toth <toth.t11@gmail.com>

* test: add e2e test cases for spring v1, v2 and v3 in order to

be sure that the adjusted start cmd is backwards compatible

Co-authored-by: Tibor Toth <toth.t11@gmail.com>

* docs: update the docs of the `JavaProvider` to include the changed start cmd for gradle

Co-authored-by: Tibor Toth <toth.t11@gmail.com>

---------

Co-authored-by: Tibor Toth <toth.t11@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant