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

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

Open
4 tasks done
msupic opened this issue Sep 1, 2023 · 0 comments
Open
4 tasks done

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

msupic opened this issue Sep 1, 2023 · 0 comments

Comments

@msupic
Copy link
Contributor

msupic commented Sep 1, 2023

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

  • Steps to reproduce provided
  • Stacktrace (if present) provided
  • Example that reproduces the problem uploaded to Github
  • 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant