# Using ElasticSearch Java API on an EAR project in Glassfish 4.1

**URL:** <https://discuss.elastic.co/t/using-elasticsearch-java-api-on-an-ear-project-in-glassfish-4-1/48408>\
**Category:** Elasticsearch\
**Created:** [April 26, 2016, 9:38am UTC](https://discuss.elastic.co/t/using-elasticsearch-java-api-on-an-ear-project-in-glassfish-4-1/48408 "2016-04-26T09:38:14Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Erates](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/erates/32/9406_2.png) [@Erates](https://discuss.elastic.co/u/Erates)\
**Post date:** [April 26, 2016, 9:38am UTC](https://discuss.elastic.co/t/using-elasticsearch-java-api-on-an-ear-project-in-glassfish-4-1/48408/1 "2016-04-26T09:38:14Z")

</div>

Hello,

I'm trying to create a EAR application that talks to ElasticSearch. But I can't get it to work. It keeps complaining about classes not being able to load.

I know Glassfish has it's own implementations of Jackson, so I tried to use the libraries attribute while deploying the app. Doesn't solve it 100%. Now I have a "dependencies" project which has jackson and ElasticSearch as dependencies, and I use the maven shade plugin like explained on the documentation. When I place that jar in the /domain/lib folder and try to run the application, I still get the following exception:

Caused by: java.lang.NoSuchFieldError: FAIL\_ON\_SYMBOL\_HASH\_OVERFLOW  
at org.elasticsearch.common.xcontent.smile.SmileXContent.(SmileXContent.java:46)  
at org.elasticsearch.common.xcontent.XContentFactory.contentBuilder(XContentFactory.java:124)  
at org.elasticsearch.action.support.ToXContentToBytes.buildAsBytes(ToXContentToBytes.java:62)  
at org.elasticsearch.action.search.SearchRequest.source(SearchRequest.java:250)  
at org.elasticsearch.action.search.SearchRequestBuilder.beforeExecute(SearchRequestBuilder.java:1027)  
at org.elasticsearch.action.search.SearchRequestBuilder.beforeExecute(SearchRequestBuilder.java:50)  
at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:85)  
at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:59)  
at com.example.ESMessagesSessionBean.getMessages(ESMessagesSessionBean.java:23)

These are the libraries I include in the "dependencies" project

```
<dependencies>
    <dependency>
        <groupId>com.fasterxml.jackson.core</groupId>
        <artifactId>jackson-core</artifactId>
        <version>2.6.2</version>
    </dependency>
    <dependency>
        <groupId>org.codehaus.jackson</groupId>
        <artifactId>jackson-core-asl</artifactId>
        <version>1.9.4</version>
    </dependency>
    <dependency>
        <groupId>com.fasterxml.jackson.core</groupId>
        <artifactId>jackson-annotations</artifactId>
        <version>2.6.0</version>
    </dependency>
    <dependency>
        <groupId>com.fasterxml.jackson.core</groupId>
        <artifactId>jackson-databind</artifactId>
        <version>2.6.1</version>
    </dependency>
    <dependency>
        <groupId>com.fasterxml.jackson.dataformat</groupId>
        <artifactId>jackson-dataformat-cbor</artifactId>
        <version>2.6.2</version>
    </dependency>
    <dependency>
        <groupId>com.fasterxml.jackson.dataformat</groupId>
        <artifactId>jackson-dataformat-smile</artifactId>
        <version>2.6.2</version>
    </dependency>
    <dependency>
        <groupId>com.fasterxml.jackson.dataformat</groupId>
        <artifactId>jackson-dataformat-yaml</artifactId>
        <version>2.6.2</version>
    </dependency>
    <dependency>
        <groupId>com.fasterxml.jackson.datatype</groupId>
        <artifactId>jackson-datatype-joda</artifactId>
        <version>2.6.1</version>
    </dependency>
    
    <dependency>
        <groupId>org.elasticsearch</groupId>
        <artifactId>elasticsearch</artifactId>
        <version>2.2.1</version>
        <scope>compile</scope>
    </dependency>
</dependencies>`

```

Any idea on how to fix this issue? I ran out of ideas.

Erates

---

<div class="post-metadata">

**Author:** ![m.hartwig](https://avatars.discourse-cdn.com/v4/letter/m/e274bd/32.png) [@m.hartwig](https://discuss.elastic.co/u/m.hartwig)\
**Post date:** [May 25, 2016, 12:52pm UTC](https://discuss.elastic.co/t/using-elasticsearch-java-api-on-an-ear-project-in-glassfish-4-1/48408/2 "2016-05-25T12:52:00Z")

</div>

Hi,

the problem is, that Glassfish 4.1 provides the Jackson libraries as OSGI bundle. You aaplication uses jackson libraries from the OSGI cache, even if you do not develop an OSGI application.

The version of Jackson, glassfish 4.1 provides, is 2.3.2 and this version differs from the version, elasticsearch Java API is using. The older Version does not have the field FAIL\_ON\_SYMBOL\_HASH\_OVERFLOW in com.fasterxml.jackson.core.JsonFactory$Feature.

THe solution is to update the version of Jackson in glassfish 4.1. The way you should do this, is explained here: [Stackoverflow](http://stackoverflow.com/questions/27334528/upgrading-jackson-in-glassfish-4-1).

If you are using elasticsearch 2.3.2, you also have to update the version of guava. elasticsearch depends on guava-18.0 and glassfish provides an older version.

Hope, it helps...

---

<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:** [May 25, 2016, 1:04pm UTC](https://discuss.elastic.co/t/using-elasticsearch-java-api-on-an-ear-project-in-glassfish-4-1/48408/3 "2016-05-25T13:04:33Z")

</div>

++

You might want to shade elasticsearch deps if you wish...

Read [https://www.elastic.co/blog/to-shade-or-not-to-shade](https://www.elastic.co/blog/to-shade-or-not-to-shade) in case it helps...

---

<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:** [July 5, 2017, 10:49pm UTC](https://discuss.elastic.co/t/using-elasticsearch-java-api-on-an-ear-project-in-glassfish-4-1/48408/4 "2017-07-05T22:49:03Z")

</div>


