# Elastic Search and webmethods Integration

**URL:** <https://discuss.elastic.co/t/elastic-search-and-webmethods-integration/73465>\
**Category:** Elasticsearch\
**Created:** [February 1, 2017, 6:32am UTC](https://discuss.elastic.co/t/elastic-search-and-webmethods-integration/73465 "2017-02-01T06:32:02Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![ravi.techie2010](https://avatars.discourse-cdn.com/v4/letter/r/da6949/32.png) [@ravi.techie2010](https://discuss.elastic.co/u/ravi.techie2010)\
**Post date:** [February 1, 2017, 6:32am UTC](https://discuss.elastic.co/t/elastic-search-and-webmethods-integration/73465/1 "2017-02-01T06:32:02Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [February 1, 2017, 7:25am UTC](https://discuss.elastic.co/t/elastic-search-and-webmethods-integration/73465/2 "2017-02-01T07:25:00Z")

</div>

What does your pom looks like?

---

<div class="post-metadata">

**Author:** ![ravi.techie2010](https://avatars.discourse-cdn.com/v4/letter/r/da6949/32.png) [@ravi.techie2010](https://discuss.elastic.co/u/ravi.techie2010)\
**Post date:** [February 1, 2017, 8:10am UTC](https://discuss.elastic.co/t/elastic-search-and-webmethods-integration/73465/3 "2017-02-01T08:10:46Z")

</div>

PFB the POM which i have used:

4.0.0

```
<groupId>com.fiserv.icc</groupId>
<artifactId>myElasticSearch</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>

<name>myElasticSearch</name>
<url>http://maven.apache.org</url>

<properties>
	<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>
	<dependency>
		<groupId>junit</groupId>
		<artifactId>junit</artifactId>
		<version>3.8.1</version>
		<scope>test</scope>
	</dependency>
	<dependency>
		<groupId>org.elasticsearch.client</groupId>
		<artifactId>transport</artifactId>
		<version>5.1.1</version>
	</dependency>
</dependencies>

```

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [February 1, 2017, 8:24am UTC](https://discuss.elastic.co/t/elastic-search-and-webmethods-integration/73465/4 "2017-02-01T08:24:38Z")

</div>

Please format your code using `</>` icon as explained in [this guide](https://discuss.elastic.co/t/about-the-elasticsearch-category/21). It will make your post more readable.

Or use markdown style like:

````
```
CODE
```

````

`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?

---

<div class="post-metadata">

**Author:** ![ravi.techie2010](https://avatars.discourse-cdn.com/v4/letter/r/da6949/32.png) [@ravi.techie2010](https://discuss.elastic.co/u/ravi.techie2010)\
**Post date:** [February 1, 2017, 8:33am UTC](https://discuss.elastic.co/t/elastic-search-and-webmethods-integration/73465/5 "2017-02-01T08:33:34Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [February 1, 2017, 9:03am UTC](https://discuss.elastic.co/t/elastic-search-and-webmethods-integration/73465/6 "2017-02-01T09:03:39Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![ravi.techie2010](https://avatars.discourse-cdn.com/v4/letter/r/da6949/32.png) [@ravi.techie2010](https://discuss.elastic.co/u/ravi.techie2010)\
**Post date:** [February 1, 2017, 1:07pm UTC](https://discuss.elastic.co/t/elastic-search-and-webmethods-integration/73465/7 "2017-02-01T13:07:22Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [February 1, 2017, 1:45pm UTC](https://discuss.elastic.co/t/elastic-search-and-webmethods-integration/73465/8 "2017-02-01T13:45:24Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [March 1, 2017, 1:46pm UTC](https://discuss.elastic.co/t/elastic-search-and-webmethods-integration/73465/9 "2017-03-01T13:46:00Z")

</div>

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