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

StaticContentService Not Working with Java Modules #8483

Closed
crgardner opened this issue Mar 16, 2024 · 2 comments · Fixed by #8506
Closed

StaticContentService Not Working with Java Modules #8483

crgardner opened this issue Mar 16, 2024 · 2 comments · Fixed by #8506
Assignees
Labels
4.x Version 4.x archetypes bug Something isn't working docs P2

Comments

@crgardner
Copy link

Environment Details

  • Helidon Version: 4.0.5
  • Helidon SE
  • JDK version: openjdk version "21.0.2" 2024-01-16 LTS
  • OS: Fedora 37
  • Docker version (if applicable): NA

Problem Description

Generated starter project with static content and Java modules returns 404 NOT FOUND for when requesting the static content. If I remove the module-info.java, making the application non-explcitly modular, Helidon finds the static content and returns it.

The following code was generated from the Helidon starter. The onlyh thin different is I removed the "/" redirect to "/ui" to see if that made any difference (it didn't):

  static void routing(HttpRouting.Builder routing) {
        routing
               .register("/greet", new GreetService())
               .get("/simple-greet", (req, res) -> res.send("Hello World!"))

                .register("/ui", StaticContentService.builder("WEB")
                        .welcomeFileName("index.html")
                        .build())
                .register("/api", new FileService());
    }

This problem happens consistently with module-info.java. With no module-info.java, index.html is returned consistently.

Does StaticContentService need to be updated to find files differently than the classpath and file system when modules are used?

Steps to reproduce

  1. Generate a starter project with static content (the file upload example)
  2. Start the application.
  3. Navigate to the root or /ui URL.
  4. Receive 404.
@m0mus m0mus added the triage label Mar 18, 2024
@m0mus m0mus added bug Something isn't working archetypes P2 and removed triage labels Mar 18, 2024
@romain-grecourt
Copy link
Contributor

Add this to your module-info:

opens WEB;

This is a bug in the archetype, the module-info generated should be functional.

@wojtask9
Copy link
Contributor

wojtask9 commented Mar 19, 2024

Also this info "should" be also in documentation. When you use "jpms" with "StaticContent" not all paths are available like in classic classpath.

Took some time to debug this issue :)

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

Successfully merging a pull request may close this issue.

5 participants