Closed lianghuiyuan closed 5 years ago
Can you try to remove <type>pom</type>
and see what happens?
I have removed <type>pom</type>
, It can not load in project External Libraries either.
@lianghuiyuan is there a way for us to reproduce the issue like a sample project we could look at?
@metacosm Thank you for help!
I new created a Springboot project, and add istio-java-api
dependency in the pom.xml
It can not load in project External Libraries.
The example project: https://github.com/lianghuiyuan/springworld.git
below is the project pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.6.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.lhy.spring</groupId>
<artifactId>springworld</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>springworld</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/me.snowdrop/istio-java-api -->
<dependency>
<groupId>me.snowdrop</groupId>
<artifactId>istio-java-api</artifactId>
<version>1.1.0</version>
<type>pom</type>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
Thanks, I will take a look soon.
@metacosm Thanks. is my pom.xml
error or something ?
I tried different ways, but still can not load in project External Libraries.
@lianghuiyuan actually, what you want to be using is the istio-client
artifact most likely, not the istio-java-api
one which is the parent POM and therefore doesn't contain any code by itself. Sorry I missed it earlier.
Let me know if that fixes your issue.
Thank you! @metacosm Sorry for late reply. Actually, I need both istio-client
and kubernetes-client
artifacts as I need to create/update/delete/list Gateway, VirtualService, DestinationRule and ServiceEntry. I am not sure it is the best way, but it works. Follow is the configuration in maven:
<!-- https://mvnrepository.com/artifact/me.snowdrop/istio-client -->
<dependency>
<groupId>me.snowdrop</groupId>
<artifactId>istio-client</artifactId>
<version>1.1.0</version>
</dependency>
<dependency>
<groupId>io.fabric8</groupId>
<artifactId>kubernetes-client</artifactId>
<version>${kubernetes-client.version}</version>
</dependency>
But now another problem came out: I config the IstioClient failed It seems the same like the issue: #https://github.com/fabric8io/kubernetes-client/issues/1592
I config the IstioClient with following code:
Config config = new ConfigBuilder()
.withCaCertData(k8s_cluster_clientCertData)
.withClientKeyData(k8s_cluster_clientKeyData)
.withClientCertData(k8s_cluster_clientCertData)
.withMasterUrl(k8s_cluster_url)
.build();
IstioClient istioClient = new DefaultIstioClient(config);
It comes out the follow error: NullPointerException:
[2019-07-30 00:15:23,834][ERROR:restartedMain][SpringApplication.java:858] Application run failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'gatewayController' defined in file [api/controller/GatewayController.class]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.authine.lateinos.kube.api.controller.GatewayController]: Constructor threw exception; nested exception is java.lang.NullPointerException
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1303)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1197)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:515)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:843)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:877)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:549)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:142)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:775)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:316)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1260)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1248)
at com.authine.lateinos.kube.api.Application.main(Application.java:23)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49)
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.authine.lateinos.kube.api.controller.GatewayController]: Constructor threw exception; nested exception is java.lang.NullPointerException
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:184)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:87)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1295)
... 22 more
Caused by: java.lang.NullPointerException
at io.fabric8.kubernetes.client.Config.<init>(Config.java:267)
at io.fabric8.kubernetes.client.ConfigBuilder.build(ConfigBuilder.java:132)
at com.authine.lateinos.kube.api.controller.GatewayController.<init>(GatewayController.java:47)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:172)
OK, I fixed the problem.
To Config the Client as follow two ways:
System.setProperty(Config.KUBERNETES_MASTER_SYSTEM_PROPERTY, k8s_cluster_url);
System.setProperty(Config.KUBERNETES_CA_CERTIFICATE_DATA_SYSTEM_PROPERTY, k8s_cluster_authData);
System.setProperty(Config.KUBERNETES_CLIENT_KEY_DATA_SYSTEM_PROPERTY, k8s_cluster_clientKeyData);
System.setProperty(Config.KUBERNETES_CLIENT_CERTIFICATE_DATA_SYSTEM_PROPERTY, k8s_cluster_clientCertData);
Config config = new ConfigBuilder().build();
istioClient = new DefaultIstioClient(config);
Or
istioClient = new DefaultIstioClient(new ConfigBuilder()
.withTrustCerts(true)
.withMasterUrl(k8s_cluster_url)
.withClientKeyData(k8s_cluster_clientKeyData)
.withClientCertData(k8s_cluster_clientCertData)
.withOauthToken(k8s_cluster_authData)
.build());
the artifacts in pom.xml are:
<dependency>
<groupId>me.snowdrop</groupId>
<artifactId>istio-client</artifactId>
<version>1.1.0</version>
</dependency>
<dependency>
<groupId>io.fabric8</groupId>
<artifactId>kubernetes-client</artifactId>
<version>${kubernetes-client.version}</version>
</dependency>
This dependency is seems not work? It can not load in project External Libraries.