java.lang.ClassNotFoundException: org.elasticsearch.common.CharArrays

I'm attempting to wire ES Cloud with a Spring Boot App, using x-pack, and get the following error. Any idea of where I may start looking? I've spent the past day hunting down dependency issues and I can't seem to find any info on this.

Caused by: java.lang.NoClassDefFoundError: org/elasticsearch/common/CharArrays
    	at org.elasticsearch.xpack.core.security.authc.support.UsernamePasswordToken.basicAuthHeaderValue(UsernamePasswordToken.java:40) ~[x-pack-core-6.7.2.jar:6.7.2]
    	at org.elasticsearch.xpack.core.security.SecuritySettings.lambda$addUserSettings$0(SecuritySettings.java:46) ~[x-pack-core-6.7.2.jar:6.7.2]
    	at java.util.Optional.ifPresent(Optional.java:159) ~[na:1.8.0_131]
    	at org.elasticsearch.xpack.core.security.SecuritySettings.addUserSettings(SecuritySettings.java:38) ~[x-pack-core-6.7.2.jar:6.7.2]
    	at org.elasticsearch.xpack.core.XPackClientPlugin.additionalSettings(XPackClientPlugin.java:235) ~[x-pack-core-6.7.2.jar:6.7.2]
    	at org.elasticsearch.xpack.core.XPackClientPlugin.additionalSettings(XPackClientPlugin.java:228) ~[x-pack-core-6.7.2.jar:6.7.2]
    	at org.elasticsearch.plugins.PluginsService.updatedSettings(PluginsService.java:203) ~[elasticsearch-6.4.3.jar:6.4.3]
    	at org.elasticsearch.client.transport.TransportClient.buildTemplate(TransportClient.java:137) ~[elasticsearch-6.4.3.jar:6.4.3]
    	at org.elasticsearch.client.transport.TransportClient.<init>(TransportClient.java:283) ~[elasticsearch-6.4.3.jar:6.4.3]
    	at org.elasticsearch.transport.client.PreBuiltTransportClient.<init>(PreBuiltTransportClient.java:128) ~[transport-6.4.3.jar:6.4.3]
    	at org.elasticsearch.xpack.client.PreBuiltXPackTransportClient.<init>(PreBuiltXPackTransportClient.java:47) ~[x-pack-transport-6.7.2.jar:6.7.2]
    	at org.elasticsearch.xpack.client.PreBuiltXPackTransportClient.<init>(PreBuiltXPackTransportClient.java:42) ~[x-pack-transport-6.7.2.jar:6.7.2]
    	at org.elasticsearch.xpack.client.PreBuiltXPackTransportClient.<init>(PreBuiltXPackTransportClient.java:38) ~[x-pack-transport-6.7.2.jar:6.7.2]
    	at com.clatsch.application.config.component.elasticsearch.ElasticSearchConfiguration.elasticsearchSecuredClient(ElasticSearchConfiguration.java:49) ~[classes/:na]
    	at com.clatsch.application.config.component.elasticsearch.ElasticSearchConfiguration$$EnhancerBySpringCGLIB$$8bc96cbf.CGLIB$elasticsearchSecuredClient$6(<generated>) ~[classes/:na]
    	at com.clatsch.application.config.component.elasticsearch.ElasticSearchConfiguration$$EnhancerBySpringCGLIB$$8bc96cbf$$FastClassBySpringCGLIB$$842db440.invoke(<generated>) ~[classes/:na]
    	at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:244) ~[spring-core-5.1.6.RELEASE.jar:5.1.6.RELEASE]
    	at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:363) ~[spring-context-5.1.6.RELEASE.jar:5.1.6.RELEASE]
    	at com.clatsch.application.config.component.elasticsearch.ElasticSearchConfiguration$$EnhancerBySpringCGLIB$$8bc96cbf.elasticsearchSecuredClient(<generated>) ~[classes/:na]
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_131]
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_131]
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_131]
    	at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_131]
    	at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154) ~[spring-beans-5.1.6.RELEASE.jar:5.1.6.RELEASE]
    	... 20 common frames omitted
    Caused by: java.lang.ClassNotFoundException: org.elasticsearch.common.CharArrays
    	at java.net.URLClassLoader.findClass(URLClassLoader.java:381) ~[na:1.8.0_131]
    	at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_131]
    	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335) ~[na:1.8.0_131]
    	at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_131]
    	... 44 common frames omitted

Code

@Bean
    public ElasticsearchOperations elasticsearchTemplate() throws Exception {
        return new ElasticsearchTemplate(elasticsearchSecuredClient());
    }

@Bean
public TransportClient elasticsearchSecuredClient() throws Exception {
    return new PreBuiltXPackTransportClient(this.getSettings())
            .addTransportAddress(this.getTransportAddress());

}

private Settings getSettings() {
    return Settings.builder()
            .put("cluster.name", this.getCluster())
            .put("request.headers.X-Found-Cluster", this.getCluster())
            .put("xpack.security.user", this.getUserPassword())
            .put("xpack.security.transport.ssl.enabled", "true")
            .build();
}

private String getUserPassword() {
    return this.user + ":" + this.password;
}

private TransportAddress getTransportAddress() throws UnknownHostException {
    return new TransportAddress(InetAddress.getByName(this.getHost()), this.getPort());
}

pom.xml

	<dependency>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-data-elasticsearch</artifactId>
		<exclusions>
			<exclusion>
				<groupId>org.elasticsearch.client</groupId>
				<artifactId>transport</artifactId>
			</exclusion>
		</exclusions>
	</dependency>

	<dependency>
		<groupId>org.elasticsearch.client</groupId>
		<artifactId>x-pack-transport</artifactId>
		<version>6.7.2</version>
	</dependency>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.