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("10.253.153.81"), 9300));
if(client != null){
String json = "{" +
"\"user\":\"kimchy124\"," +
"\"postDate\":\"2013-01-30\"," +
"\"message\":\"trying out Elasticsearch\"" +
"}";
IndexResponse response = client.prepareIndex("twitter", "tweet")
.setSource(json)
.get();
}else{
System.out.println("Not success");
}
client.close();
} catch (UnknownHostException e) {
e.printStackTrace();
}
}
}
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:
MainApp.main(null);
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.