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.

Cannot instantiate DefaultKubernetesClient due to NoSuchMethodError

See original GitHub issue

Describe the bug

When create DefaultKubernetesClient(), there is a java exception

Fabric8 Kubernetes Client version

5.9.0

Steps to reproduce

  1. Create DefaultKubernetesClient
        MyKubernetesInfo info;
        Config config = new ConfigBuilder()
                .withMasterUrl(info.getUrl())
                .withOauthToken(info.getToken())
                .withDisableHostnameVerification(true)
                .withTrustCerts(true)
                .build();

        return new DefaultKubernetesClient(config);
  1. See the exception

Expected behavior

DefaultKubernetesClient() should be instantiated like version 5.4.1

Runtime

Kubernetes (vanilla)

Kubernetes API Server version

other (please specify in additional context)

Environment

Linux

Fabric8 Kubernetes Client Logs

java.lang.NoSuchMethodError: 'java.lang.String io.fabric8.kubernetes.api.model.HasMetadata.getGroup(java.lang.Class)'
	at io.fabric8.kubernetes.client.dsl.base.ResourceDefinitionContext.fromResourceType(ResourceDefinitionContext.java:51) ~[kubernetes-client-5.9.0.jar:na]
	at io.fabric8.kubernetes.client.ResourceHandlerImpl.<init>(ResourceHandlerImpl.java:43) ~[kubernetes-client-5.9.0.jar:na]
	at io.fabric8.kubernetes.client.Handlers.register(Handlers.java:50) ~[kubernetes-client-5.9.0.jar:na]
	at io.fabric8.kubernetes.client.BaseKubernetesClient.<clinit>(BaseKubernetesClient.java:132) ~[kubernetes-client-5.9.0.jar:na]
	at MyPackage.getNewKubernetesClient(Fabric8KubernetesApiClientPool.java:70) ~[main/:na]

Additional context

Kubernetes API version: 1.18, 1.21 That code snippet worked at the lib version 5.4.1

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
youngbo89commented, Dec 20, 2021

I found something… I think there is a conflict with Spring-Cloud

Without Spring cloud

In build.gradle:

dependencies {
	implementation 'com.fasterxml.jackson.core:jackson-core:2.12.3'
	implementation 'io.fabric8:kubernetes-client:5.7.0'
}

Result:

11:41:59 AM: Executing task 'MyTest.main()'...

> Task :compileJava
> Task :processResources UP-TO-DATE
> Task :classes

> Task :MyTest.main()

with spring-cloud configuration

In build.gradle:

ext {
	set('springCloudVersion', "2020.0.3")
}

dependencyManagement {
	imports {
		mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
	}
}

dependencies {
	implementation 'com.fasterxml.jackson.core:jackson-core:2.12.3'
	implementation 'io.fabric8:kubernetes-client:5.7.0'
}

Result:

Exception in thread "main" java.lang.NoSuchMethodError: 'java.lang.String io.fabric8.kubernetes.api.model.HasMetadata.getGroup(java.lang.Class)'
	at io.fabric8.kubernetes.client.dsl.base.ResourceDefinitionContext.fromResourceType(ResourceDefinitionContext.java:60)
	at io.fabric8.kubernetes.client.ResourceHandlerImpl.<init>(ResourceHandlerImpl.java:42)
	at io.fabric8.kubernetes.client.Handlers.register(Handlers.java:49)
	at io.fabric8.kubernetes.client.BaseKubernetesClient.<clinit>(BaseKubernetesClient.java:133)
	at com.samsung.sco.dso.cnf.monitoring.operation.MyTest.main(MyTest.java:7)

Execution failed for task ':MyTest.main()'.

Compatibility table

Just for creating test of DefaultKubernetesClient Object.

The result is depends on the version of spring-cloud and fabric8-kubernetes

version Spring-Cloud-Version Result With Spring-Cloud Without Spring cloud
kubernetes-client-5.4.1 2020.0.3 O O
kubernetes-client-5.6.0 2020.0.3 O O
kubernetes-client-5.7.0 2020.0.3 X O
kubernetes-client-5.8.0 2020.0.3 X O
kubernetes-client-5.11.0 2020.0.3 X O
0reactions
stale[bot]commented, Mar 20, 2022

This issue has been automatically marked as stale because it has not had any activity since 90 days. It will be closed if no further activity occurs within 7 days. Thank you for your contributions!

Read more comments on GitHub >

github_iconTop Results From Across the Web

NoSuchMethodError on OkHttpClient$Builder.pingInterval #45
Exception in thread "main" java.lang.IllegalArgumentException: Cannot instantiate interface org.springframework.context.
Read more >
由于nosuchmethoderror,无法实例化defaultkubernetesclient
Cannot instantiate DefaultKubernetesClient due to NoSuchMethodError 描述错误当创建defaultkubernetesclient()时,有一个Java例外fabric8 ...
Read more >
Setup Spring Cloud Data Flow server for Kubernetes
I couldn't find any certificate/fabric8 related configuration in documentation, ... IllegalArgumentException: Cannot instantiate interface ...
Read more >
Red Hat Fuse 7.4 Release Notes
Red Hat is not formally related to or endorsed by the ... Openshift 4 + FMP: DefaultKubernetesClient cannot be cast to OpenShiftClient.
Read more >
CHANGELOG.md · master · mirrors / fabric8io / kubernetes-client
The stream pumper related classes were also simplified to utility methods on ... cascading() causes NoSuchMethodError * Fix #1309: Can't get ...
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