question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Warning "'mainClass' configured in 'maven-jar-plugin' is not a valid Java class" appearing since jib 2.3

See original GitHub issue

Environment:

  • Jib version: 2.4
  • Build tool: Maven 3.6.3
  • OS: Windows

Description of the issue:

Since jib 2.3 the build prints below warning when I use it with Spring Boot application:

[WARNING] 'mainClass' configured in 'maven-jar-plugin' is not a valid Java class: ${start-class}

Still later entry point is correctly inferred which is visible in log:

[INFO] Container entrypoint set to [java, -cp, /app/resources:/app/classes:/app/libs/*, com.example.ExampleApplication]

Expected behavior:

The warning should not be printed, like before jib 2.3.

Additional Information:

I believe this issue was introduced in pr #2457. Looks like it introduced some additional logging, which in this scenario creates odd experience: jib logs warnings about invalid mainClass, but is still able to set it correctly.

It can be seen as Spring Boot issue, as the Spring Boot sets mainClass in maven-jar-plugin to ${start-class}. Still, even though the root cause is in Spring Boot, if maven-jar-plugin does not issue such warning, why should jib do it on its behalf. Better yet, (but I do not know anything about Maven internals), jib could try to resolve value of ${start-class}, which I believe is empty, and issue warning only when that resolved value is invalid.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

7reactions
robert-gdvcommented, Feb 22, 2022

@chanseokoh : I think you should decide: Either you provide the automatic class detection as a reasonable working default or you require a definition.

The world currently tends to work with reasonable defaults. In this case, if the main class is wrong, it will surely come up in an integration test. If every reasonably default comes with a warning “Hey we assumed this setting. But it is probably wrong.”, I would disable warnings.

So either it works in the end, then don’t warn. Or it doesn’t work. Then break the build.

5reactions
moondownercommented, Jun 17, 2021

@loosebazooka @listaction you’ve probably resolved this by now, but I’ll add this comment for future people that may end up on this ticket while browsing for a solution:

Here’s an example:

                <groupId>com.google.cloud.tools</groupId>
                <artifactId>jib-maven-plugin</artifactId>
                <version>3.1.1</version>
                <configuration>
                    <container>
                        <mainClass>com.test.ServerApplication</mainClass>
                    </container>
                </configuration>
            </plugin>
Read more comments on GitHub >

github_iconTop Results From Across the Web

Building with JIB give Multiple valid main classes were found ...
The main class need to be set in the < plugins > define in < build > of the pom.xml file. It would...
Read more >
Developing with Spring Boot
This section goes into more detail about how you should use Spring Boot. It covers topics such as build systems, auto-configuration, ...
Read more >
Building Java containers with Jib - Google Cloud
This tutorial shows how to use Jib to build an optimal Java container and deploy to Cloud Run.
Read more >
Spring Boot, Maven and Eclipse Errors and TroubleShooting ...
Failed to load class (or)Could not find or load main class or ... Maven plugin uses a settings file where the configuration can...
Read more >
Containerizing Spring Boot Applications with Jib - Foojay
With Jib, you can containerize your Java applications in no time by adding Maven ... 'mainClass' configured in 'maven-jar-plugin' is not a valid...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found