configcat / java-sdk

ConfigCat SDK for Java. ConfigCat is a hosted feature flag service: https://configcat.com. Manage feature toggles across frontend, backend, mobile, desktop apps. Alternative to LaunchDarkly. Management app + feature flag SDKs.
https://configcat.com/docs/sdk-reference/java
MIT License
20 stars 6 forks source link

BeanCreationException error after upgrading to version 8.x #35

Closed rafa-acioly closed 1 year ago

rafa-acioly commented 1 year ago

Describe the bug

After upgrading java from version 16 to 17 and upgrading the config-cat lib from vesion 6.x to 8.x, the Bean creation on spring started to fail with the exception BeanCreationException

To reproduce

Upgrade java vertion to 17 and config-cat to 8.x

<dependency>
      <groupId>com.configcat</groupId>
      <artifactId>configcat-java-client</artifactId>
      <version>[8.0.0,)</version>
    </dependency>

Change the bean creation from:

@Bean
    ConfigCatClient configCatClient() {
        return ConfigCatClient
            .newBuilder()
            .mode(PollingModes.autoPoll(60))
            .logLevel(LogLevel.WARNING)
            .build(this.settings.sdkKey)
    }

To:

import com.configcat.*;

@Bean
    ConfigCatClient configCatClient() {
        return ConfigCatClient.get(this.settings.sdkKey, options -> {
          options.pollingMode(PollingModes.autoPoll());
          options.logLevel(LogLevel.WARNING);
        })
    }

The error:

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'configCatClient' defined in class path resource [br/com/blz/myrepo/config/ConfigCat.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.configcat.ConfigCatClient]: Factory method 'configCatClient' threw exception; nested exception is java.lang.reflect.GenericSignatureFormatError: Signature Parse error: expected a class type
novalisdenahi commented 1 year ago

Hi, @rafa-acioly! Thank you for the issue! I will check on the problem and let you know if we fixed the problem.

rafa-acioly commented 1 year ago

@novalisdenahi Is there a temporary solution to this? Maybe another version?

novalisdenahi commented 1 year ago

@rafa-acioly Can you provide me with a little bit more info? I tried to reproduce the error, but I couldn't do it. Worked with Maven and Gradle as well. Different java versions, and I tried other versions of org.springframework.boot plugin as well (maven/gradle both worked well).

Can you try with the fix 8.1.0 configcat-java-client version? Also, can you provide me with the exact java and spring version?

Thanks in advance!

rafa-acioly commented 1 year ago

@novalisdenahi I found the error cause, for some reason the newrelic library was having problem with completabe future and was messing up everything.

novalisdenahi commented 1 year ago

@rafa-acioly Did you manage to solve the problem? Let us know if everything works fine so we can close the issue. Otherwise, please provide us with more info regarding the cause of the problem.

Thanks in advance!

github-actions[bot] commented 1 year ago

This issue is marked stale because it has no activity in the last 3 weeks. The issue will be closed in one week. Please remove the stale flag to keep it open.

github-actions[bot] commented 1 year ago

This issue was closed due to no activity.