question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Rest Client extension seems to have problem with kotlin

See original GitHub issue

Describe the bug I’ve tried to reproduce the doc tutorial using a kotlin environment https://quarkus.io/guides/rest-client. It won’t instanciate the rest client:

org.junit.jupiter.api.extension.TestInstantiationException: TestInstanceFactory [io.quarkus.test.junit.QuarkusTestExtension] failed to instantiate test class [org.acme.ExampleResourceTest]: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
	[error]: Build step io.quarkus.arc.deployment.ArcProcessor#validate threw an exception: javax.enterprise.inject.spi.DeploymentException: javax.enterprise.inject.UnsatisfiedResolutionException: Unsatisfied dependency for type org.acme.CountriesService and qualifiers [@Default]
	- java member: org.acme.ExampleResource#countriesService
	- declared on CLASS bean [types=[org.acme.ExampleResource], qualifiers=[@Default, @Any], target=org.acme.ExampleResource]
	at io.quarkus.arc.processor.BeanDeployment.processErrors(BeanDeployment.java:850)
	at io.quarkus.arc.processor.BeanDeployment.init(BeanDeployment.java:220)
	at io.quarkus.arc.processor.BeanProcessor.initialize(BeanProcessor.java:106)
	at io.quarkus.arc.deployment.ArcProcessor.validate(ArcProcessor.java:251)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at io.quarkus.deployment.ExtensionLoader$1.execute(ExtensionLoader.java:941)
	at io.quarkus.builder.BuildContext.run(BuildContext.java:415)
	at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
	at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2011)
	at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1535)
	at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1426)
	at java.base/java.lang.Thread.run(Thread.java:834)
	at org.jboss.threads.JBossThread.run(JBossThread.java:479)
Caused by: javax.enterprise.inject.UnsatisfiedResolutionException: Unsatisfied dependency for type org.acme.CountriesService and qualifiers [@Default]
	- java member: org.acme.ExampleResource#countriesService
	- declared on CLASS bean [types=[org.acme.ExampleResource], qualifiers=[@Default, @Any], target=org.acme.ExampleResource]
	at io.quarkus.arc.processor.Beans.resolveInjectionPoint(Beans.java:472)
	at io.quarkus.arc.processor.BeanInfo.init(BeanInfo.java:404)
	at io.quarkus.arc.processor.BeanDeployment.init(BeanDeployment.java:212)
	... 14 more

Expected behavior It should instanciate it and work

Actual behavior We get an exception

To Reproduce Steps to reproduce the behavior:

  1. https://code.quarkus.io/api/download?g=org.acme&a=code-with-quarkus&v=1.0.0-SNAPSHOT&b=MAVEN&c=org.acme.ExampleResource&e=io.quarkus%3Aquarkus-resteasy-jsonb&e=io.quarkus%3Aquarkus-rest-client&e=io.quarkus%3Aquarkus-kotlin
  2. Add a service:
package org.acme

import org.eclipse.microprofile.rest.client.inject.RegisterRestClient

import javax.ws.rs.GET
import javax.ws.rs.Path
import javax.ws.rs.Produces

@Path("/v2")
@RegisterRestClient(baseUri = "https://andy/")
interface CountriesService {

    @GET
    @Path("/get")
    @Produces("application/json")
    fun get(): Set<String>
}
  1. Inject it:
...
@Path("/hello")
class ExampleResource {

    @Inject
    @RestClient
    lateinit var countriesService: CountriesService
...
  1. run the test

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

0reactions
emmanuelbernardcommented, Jun 30, 2020

This is fixed AFAIK

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error to inject some dependency with kotlin + quarkus
This problem results as a combination of how Kotlin handles annotations and the lack of the a @Target on the @RestClient annotation ...
Read more >
Using Kotlin - Quarkus
The Quarkus Kotlin extension already declares a dependency on some base Kotlin libraries like kotlin-stdlib-jdk8 and kotlin-reflect . The Kotlin version of ...
Read more >
Calling Java from Kotlin
In this section, we describe some details about calling Java code from Kotlin. Pretty much all Java code can be used without any...
Read more >
Using the REST Client within PhpStorm and WebStorm
When building REST-based web APIs, it's worth having a tool available to invoke them over HTTP. The current versions of WebStorm 6, ...
Read more >
Known issues with Android Studio and Android Gradle Plugin
To fix the issue for the current project, click Run > Edit Configurations and change the default JUnit configuration to only include the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found