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

The "Helidon MP Config guide" provides confusing code samples #3057

Closed
javierdiegof opened this issue May 28, 2021 · 2 comments
Closed

The "Helidon MP Config guide" provides confusing code samples #3057

javierdiegof opened this issue May 28, 2021 · 2 comments
Assignees
Labels
bug Something isn't working docs P3
Milestone

Comments

@javierdiegof
Copy link

javierdiegof commented May 28, 2021

Environment Details

  • Helidon Version: 2.3.0
  • Helidon MP
  • JDK version: OpenJDK 11
  • OS: Oracle Linux 8

Problem Description

It is a minor problem, but I think it makes the guide hard to follow.
In the Default configuration section of the Helidon MP Config Guide a code snippet with a Main class is provided:

package io.helidon.examples.quickstart.mp;

import io.helidon.microprofile.server.Server;
import java.io.IOException;

public final class Main {

    private Main() { } 

    public static void main(final String[] args) throws IOException {
        Server server = startServer();
        System.out.println("http://localhost:" + server.port() + "/greet");
    }

    static Server startServer() {
        return Server.create().start(); 
    }

}

The class is supposed to be added to the archetype template code generated earlier in the tutorial, in the section Create a sample Helidon MP project:

mvn -U archetype:generate -DinteractiveMode=false \
    -DarchetypeGroupId=io.helidon.archetypes \
    -DarchetypeArtifactId=helidon-quickstart-mp \
    -DarchetypeVersion=2.3.0 \
    -DgroupId=io.helidon.examples \
    -DartifactId=helidon-quickstart-mp \
    -Dpackage=io.helidon.examples.quickstart.mp

That archetype project does not provide a Main.java file, just a GreetingProvider.java and a GreetResource.java. That means that something besides those two classes is providing the 'main entry point'. Looking at the MANIFEST.MF of the jar file, it appears that the main class is being provided by the Helidon framework:

Main-Class: io.helidon.microprofile.cdi.Main

Which is OK. The problem is that adding the Main.java file in the tutorial does not change that, the io.helidon.microprofile.cdi.Main is still the entry point. In practical terms, this means that the Main.java file that the user is writing as he/she goes through the tutorial is being completely ignored when packaging and running the project, which makes the tutorial very hard to follow since the code does not do what it is supposed to do.

Steps to reproduce

  1. Create the project using archetype in the code snippet above.
  2. Add the Main.java to the project according to the snippet above.
  3. Package the application: mvn package.
  4. Run the packaged application: java -jar target target/java_jar_file.jar.
  5. See how the code provided in the Main.java file is ignored.

Please correct me if anything is wrong with the description I did in this bug report. I'm very much a noob in Helidon.
I would still like to be able to follow the tutorials and have the project use the Main.java so that I can continue to learn Helidon. How can I do that?

In advance, thank you very much 🙂

@barchetta barchetta added docs bug Something isn't working P3 labels Jun 3, 2021
@barchetta barchetta self-assigned this Jun 3, 2021
@barchetta
Copy link
Member

barchetta commented Jun 4, 2021

At some point the quickstart archetypes were updated to use the built-in Main, and looks like the Config guide was not properly updated. So we need to fix that. I also quickly checked the other guides and they seem OK wrt Main.

To continue working with the guide add the following property to the project's pom.xml:

    <properties>
        <mainClass>io.helidon.examples.quickstart.mp.Main</mainClass>
    </properties>

@javierdiegof
Copy link
Author

Thanks a lot Joe :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working docs P3
Projects
Archived in project
Development

No branches or pull requests

2 participants