micronaut-starter icon indicating copy to clipboard operation
micronaut-starter copied to clipboard

`io.micronaut.http.client.HttpClient` class not found in maven project

Open msupic opened this issue 1 year ago • 0 comments

Description

Micronaut launcher generates a maven project with the following dependency

    <dependency>
      <groupId>io.micronaut</groupId>
      <artifactId>micronaut-http-client</artifactId>
      <scope>test</scope>
    </dependency>

which overrides micronaut-http-client dependency with runtime scope that comes via micronaut-oraclecloud-httpclient-netty, so the application fails to start with the following exception

Caused by: java.lang.ClassNotFoundException: io.micronaut.http.client.HttpClient
	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
	at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
	... 57 common frames omitted

Task List

  • [x] Steps to reproduce provided
  • [x] Stacktrace (if present) provided
  • [x] Example that reproduces the problem uploaded to Github
  • [x] Full description of the issue provided (see below)

Steps to Reproduce

The error can be reproduced using the following project: https://github.com/msupic/maven-http-client-bug or by executing the following steps

  1. Generate a maven project with oracle-cloud-sdk feature using the Micronaut Launch page
  2. Add the following dependency
    <dependency>
      <groupId>io.micronaut.oraclecloud</groupId>
      <artifactId>micronaut-oraclecloud-logging</artifactId>
      <scope>compile</scope>
    </dependency>
  1. Create logback.xml like in this example
  2. Create LogController like in this example
  3. Run the app

Expected Behaviour

The application should be successfully started

Actual Behaviour

The application fails to start

If micronaut-http-client dependency with the test scope is removed, the app is successfully started.

Environment Information

  • Operating System: macOS
  • Micronaut Version: 4.0.6
  • JDK Version: 17.0.8

Example Application

https://github.com/msupic/maven-http-client-bug

msupic avatar Sep 01 '23 15:09 msupic