Elastic Search and webmethods Integration

Hi All,

I am trying to integrate elastic search with webmethods. In order to achieve that, I have created a maven java project and downloaded all the dependent jars. After that, I created the a sample class to index a new document. The code of the class is as follows:

package com.fiserv.icc;

import java.net.InetAddress;
import java.net.UnknownHostException;

import org.elasticsearch.action.index.IndexResponse;
import org.elasticsearch.client.transport.TransportClient;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.transport.InetSocketTransportAddress;
import org.elasticsearch.transport.client.PreBuiltTransportClient;

public class MainApp {

public static void main(String[] args) {
	try {
		TransportClient client = new PreBuiltTransportClient(Settings.EMPTY)
		        .addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName(""), 9300));
		if(client != null){
			String json = "{" +
			        "\"user\":\"kimchy124\"," +
			        "\"postDate\":\"2013-01-30\"," +
			        "\"message\":\"trying out Elasticsearch\"" +

			IndexResponse response = client.prepareIndex("twitter", "tweet")
			System.out.println("Not success");
	} catch (UnknownHostException e) {			

Then I packaged all the dependent jars and the code into a JAR and imported it in webmethods. Inside webmethod's Java service, i am calling the following method:


But i am getting the following exception:

Could not initialize class org.elasticsearch.common.settings.IndexScopedSettings
Caused by: java.lang.reflect.InvocationTargetException: null
Caused by: java.lang.NoClassDefFoundError: Could not initialize class org.elasticsearch.common.settings.IndexScopedSettings java.lang.NoClassDefFoundError: Could not initialize class org.elasticsearch.common.settings.IndexScopedSettings
at org.elasticsearch.common.settings.SettingsModule.(SettingsModule.java:68)
at org.elasticsearch.client.transport.TransportClient.buildTemplate(TransportClient.java:133)
at org.elasticsearch.client.transport.TransportClient.(TransportClient.java:247)
at org.elasticsearch.transport.client.PreBuiltTransportClient.(PreBuiltTransportClient.java:92)
at org.elasticsearch.transport.client.PreBuiltTransportClient.(PreBuiltTransportClient.java:81)
at org.elasticsearch.transport.client.PreBuiltTransportClient.(PreBuiltTransportClient.java:71)
at com.fiserv.icc.MainApp.main(MainApp.java:16)
at AthenaLogsElasticSearch.v1_0.testConnectivity(v1_0.java:46)
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:497)

I tried searching on the internet for resolution but was unable to find one. Please let me know if some one has faced this issue and how we can resolve it.

What does your pom looks like?

PFB the POM which i have used:






Please format your code using </> icon as explained in this guide. It will make your post more readable.

Or use markdown style like:


IndexScopedSettings is part of the elasticsearch core jar. Not sure why you are not seeing it.

If you are really using Maven, you should not see such an issue. May be you used Maven "just to download" jars but then copied manually jars in your application classpath?

Thanks dadoonet for the formatting tip.

I did not copied the jars manually but used Eclipse to create the runnable jar along with all the dependent jars packed into it.

When I am using this jar in a separate java project, i am able to index the document. But when I am trying to use it with webmethods java service, it is giving issue.

Kindly let me know if I could try something.

So you are probably missing some jars in your final package.

Either use something like Maven, Gradle to build your end package or fix manually the missing jars.

Run mvn dependency:tree and you'll get the list of needed jars.

I checked and all the jars are present in the final package. I even looked into the final jar and the IndexedScopedSettings class was present.

The class path is also having the final packaged jar loaded.

Please let me know, if I could try some other approach.

Can you ls -l the content of your distribution?
Are you sure you are adding all those jars to the classpath when you start your app?

Disclaimer: I don't know Webmethods.

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