Skip to content

Undertow: servletContext.getResourcePaths("/") not listed in PROD modeΒ #28028

@melloware

Description

Describe the bug

I have a simple ApplicationInitializer to print out all the available servlet resource paths...

public class ApplicationInitializer implements ServletContainerInitializer {

	private static final Logger logger = Logger.getLogger(ApplicationInitializer.class.getName());

	@Override
	public void onStartup(Set<Class<?>> c, ServletContext servletContext) throws ServletException {
		logger.info("Checking servlet resource paths...");

		Set<String> resourcePaths = servletContext.getResourcePaths("/");
		for (String resourcePath : resourcePaths) {
			logger.info("Resource: " + resourcePath);
		}
		
		if (resourcePaths.isEmpty()) {
			logger.warning("NO servlet resource paths found!");
		}
	}
}

When running in DEV mode mvn quarkus:dev the following is printed out it finds the mapped /index.html:

2022-09-17 07:51:08,575 INFO  [org.acm.ApplicationInitializer] (Quarkus Main Thread) Checking servlet resource paths...
2022-09-17 07:51:08,577 INFO  [org.acm.ApplicationInitializer] (Quarkus Main Thread) Resource: /index.html

When running in PRD mode mvn clean package -DskipTests && java -jar target/quarkus-app/quarkus-run.jar it doesn't find anything:

2022-09-17 07:49:05,376 INFO  [org.acm.ApplicationInitializer] (main) Checking servlet resource paths...
2022-09-17 07:49:05,376 WARNING [org.acm.ApplicationInitializer] (main) NO servlet resource paths found!

Expected behavior

All servlet resource paths should be available in both DEV and PRD mode.

Actual behavior

Resource Paths are only available in DEV mode.

How to Reproduce?

quarkus-servlet.zip

  1. Unzip the reproducer attached
  2. Run mvn clean quarkus:dev and see the servlet paths printed out 2022-12-27 13:00:20,489 INFO [org.acm.ApplicationInitializer] (Quarkus Main Thread) Resource: /index.html
  3. Run mvn clean package -DskipTests && java -jar target/quarkus-app/quarkus-run.jar and see the WARNING that no paths found 2022-12-27 13:01:06,297 WARNING [org.acm.ApplicationInitializer] (main) NO servlet resource paths found!

Output of uname -a or ver

OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"

Output of java -version

OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.10+9, mixed mode)

GraalVM version (if different from Java)

No response

Quarkus version or git rev

2.15.1

Build tool (ie. output of mvnw --version or gradlew --version)

Apache Maven 3.8.5 (3599d3414f046de2324203b78ddcf9b5e4388aa0) Maven home: C:\Tools\apache-maven-3.8.5 Java version: 11.0.10, vendor: AdoptOpenJDK, runtime: C:\Tools\jdk-11.0.10 Default locale: en_US, platform encoding: Cp1252 OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"

Additional information

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions