# Embedded Elasticsearch on shutdown: java.lang.IllegalArgumentException: Illegal shift value, must be 0..63

**URL:** <https://discuss.elastic.co/t/embedded-elasticsearch-on-shutdown-java-lang-illegalargumentexception-illegal-shift-value-must-be-0-63/16847>\
**Category:** Elasticsearch\
**Created:** [April 7, 2014, 3:47pm UTC](https://discuss.elastic.co/t/embedded-elasticsearch-on-shutdown-java-lang-illegalargumentexception-illegal-shift-value-must-be-0-63/16847 "2014-04-07T15:47:30Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Doru\_Sular](https://avatars.discourse-cdn.com/v4/letter/d/e9bcb4/32.png) [@Doru\_Sular](https://discuss.elastic.co/u/Doru_Sular)\
**Post date:** [April 7, 2014, 3:47pm UTC](https://discuss.elastic.co/t/embedded-elasticsearch-on-shutdown-java-lang-illegalargumentexception-illegal-shift-value-must-be-0-63/16847/1 "2014-04-07T15:47:30Z")

</div>

Hello everybody,  
I am using elasticsearch embedded in my web application. I start the node  
via ContextListener method contextInitialized and I call node.stop() in  
contextDestroyed method of my ServletContextListener implementation.

However, the following message appear in the logs:

Apr 07, 2014 5:39:38 PM org.apache.catalina.loader.WebappClassLoader

> checkThreadLocalMapForLeaks  
> java.lang.IllegalArgumentException: Illegal shift value, must be 0..63  
> at  
> org.apache.lucene.util.NumericUtils.longToPrefixCoded(NumericUtils.java:114)  
> at  
> org.apache.lucene.analysis.NumericTokenStream$NumericTermAttributeImpl.reflectWith(NumericTokenStream.java:199)  
> at  
> org.apache.lucene.util.AttributeSource.reflectAsString(AttributeSource.java:430)  
> at  
> org.apache.catalina.loader.WebappClassLoader.checkThreadLocalMapForLeaks(WebappClassLoader.java:2521)  
> at  
> org.apache.catalina.loader.WebappClassLoader.clearReferences(WebappClassLoader.java:1996)  
> at  
> org.apache.catalina.loader.WebappLoader.stopInternal(WebappLoader.java:662)  
> at  
> org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5616)  
> at  
> org.apache.catalina.core.ContainerBase$StopChild.call(ContainerBase.java:1575)  
> at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)  
> at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)  
> at java.lang.Thread.run(Unknown Source)

I am using elasticsearch version 1.0.1.

Do you have any idea how I can shutdown ES in a friendly way?  
Thank you very much

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/2fa44b2d-9da6-4e77-89ac-6e03682240d1%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/2fa44b2d-9da6-4e77-89ac-6e03682240d1%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![jprante](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jprante/32/44941_2.png) [@jprante](https://discuss.elastic.co/u/jprante)\
**Post date:** [April 7, 2014, 5:26pm UTC](https://discuss.elastic.co/t/embedded-elasticsearch-on-shutdown-java-lang-illegalargumentexception-illegal-shift-value-must-be-0-63/16847/2 "2014-04-07T17:26:31Z")

</div>

It seems you are not using a client but a data node?

You can not expect a data node in a web app context with an index works,  
because in this case for example, your Tomcat wants to use an index  
setting/mapping for an internal leakage check, which is doomed to fail.

Jörg

On Mon, Apr 7, 2014 at 5:47 PM, Doru Sular [doru.sular@gmail.com](mailto:doru.sular@gmail.com) wrote:

> Hello everybody,  
> I am using elasticsearch embedded in my web application. I start the node  
> via ContextListener method contextInitialized and I call node.stop() in  
> contextDestroyed method of my ServletContextListener implementation.
> 
> However, the following message appear in the logs:
> 
> Apr 07, 2014 5:39:38 PM org.apache.catalina.loader.WebappClassLoader
> 
> > checkThreadLocalMapForLeaks  
> > java.lang.IllegalArgumentException: Illegal shift value, must be 0..63  
> > at  
> > org.apache.lucene.util.NumericUtils.longToPrefixCoded(NumericUtils.java:114)  
> > at  
> > org.apache.lucene.analysis.NumericTokenStream$NumericTermAttributeImpl.reflectWith(NumericTokenStream.java:199)  
> > at  
> > org.apache.lucene.util.AttributeSource.reflectAsString(AttributeSource.java:430)  
> > at  
> > org.apache.catalina.loader.WebappClassLoader.checkThreadLocalMapForLeaks(WebappClassLoader.java:2521)  
> > at  
> > org.apache.catalina.loader.WebappClassLoader.clearReferences(WebappClassLoader.java:1996)  
> > at  
> > org.apache.catalina.loader.WebappLoader.stopInternal(WebappLoader.java:662)  
> > at  
> > org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5616)  
> > at  
> > org.apache.catalina.core.ContainerBase$StopChild.call(ContainerBase.java:1575)  
> > at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)  
> > at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)  
> > at java.lang.Thread.run(Unknown Source)
> 
> I am using elasticsearch version 1.0.1.
> 
> Do you have any idea how I can shutdown ES in a friendly way?  
> Thank you very much
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/2fa44b2d-9da6-4e77-89ac-6e03682240d1%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/2fa44b2d-9da6-4e77-89ac-6e03682240d1%40googlegroups.com)[https://groups.google.com/d/msgid/elasticsearch/2fa44b2d-9da6-4e77-89ac-6e03682240d1%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/2fa44b2d-9da6-4e77-89ac-6e03682240d1%40googlegroups.com?utm_medium=email&utm_source=footer)  
> .  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAKdsXoEeFW2YdHKX7ks6fuKYubR2C%3D4c5xpB-5c6NgenkWpr%3Dg%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKdsXoEeFW2YdHKX7ks6fuKYubR2C%3D4c5xpB-5c6NgenkWpr%3Dg%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![roytmana](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/roytmana/32/44855_2.png) [@roytmana](https://discuss.elastic.co/u/roytmana)\
**Post date:** [April 8, 2014, 1:40am UTC](https://discuss.elastic.co/t/embedded-elasticsearch-on-shutdown-java-lang-illegalargumentexception-illegal-shift-value-must-be-0-63/16847/3 "2014-04-08T01:40:20Z")

</div>

I am not sure it can be done with context listeners particularity when shutting down tomcat. I do not believe it will wait for listeners to complete - they are fired asynchronously and tomcat exits without waiting but I am not positive of that. I was going to test it but have not had a chance

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/32e14429-d24a-42c6-9045-9682087c2170%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/32e14429-d24a-42c6-9045-9682087c2170%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![jprante](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jprante/32/44941_2.png) [@jprante](https://discuss.elastic.co/u/jprante)\
**Post date:** [April 8, 2014, 7:29am UTC](https://discuss.elastic.co/t/embedded-elasticsearch-on-shutdown-java-lang-illegalargumentexception-illegal-shift-value-must-be-0-63/16847/4 "2014-04-08T07:29:14Z")

</div>

FIY using TransportClient in Wildfly context listeners work like a charm,  
when close() method on client is called in contextDestroyed().

Jörg

On Tue, Apr 8, 2014 at 3:40 AM, AlexR [roytmana@gmail.com](mailto:roytmana@gmail.com) wrote:

> I am not sure it can be done with context listeners particularity when  
> shutting down tomcat. I do not believe it will wait for listeners to  
> complete - they are fired asynchronously and tomcat exits without waiting  
> but I am not positive of that. I was going to test it but have not had a  
> chance
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/32e14429-d24a-42c6-9045-9682087c2170%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/32e14429-d24a-42c6-9045-9682087c2170%40googlegroups.com)  
> .  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAKdsXoHMeYFpMnjZ%3D7q0TL-h3f19DmnBBDao20Lz4A%2BhuWu1bw%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKdsXoHMeYFpMnjZ%3D7q0TL-h3f19DmnBBDao20Lz4A%2BhuWu1bw%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Doru\_Sular](https://avatars.discourse-cdn.com/v4/letter/d/e9bcb4/32.png) [@Doru\_Sular](https://discuss.elastic.co/u/Doru_Sular)\
**Post date:** [April 8, 2014, 11:40am UTC](https://discuss.elastic.co/t/embedded-elasticsearch-on-shutdown-java-lang-illegalargumentexception-illegal-shift-value-must-be-0-63/16847/5 "2014-04-08T11:40:35Z")

</div>

Of course it waits for listeners to complete.

On Tuesday, April 8, 2014 3:40:20 AM UTC+2, AlexR wrote:

> I am not sure it can be done with context listeners particularity when  
> shutting down tomcat. I do not believe it will wait for listeners to  
> complete - they are fired asynchronously and tomcat exits without waiting  
> but I am not positive of that. I was going to test it but have not had a  
> chance

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/e2c2aac2-cd1d-4ac4-9741-60b6f512a0c1%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/e2c2aac2-cd1d-4ac4-9741-60b6f512a0c1%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Doru\_Sular](https://avatars.discourse-cdn.com/v4/letter/d/e9bcb4/32.png) [@Doru\_Sular](https://discuss.elastic.co/u/Doru_Sular)\
**Post date:** [April 10, 2014, 3:29pm UTC](https://discuss.elastic.co/t/embedded-elasticsearch-on-shutdown-java-lang-illegalargumentexception-illegal-shift-value-must-be-0-63/16847/6 "2014-04-10T15:29:13Z")

</div>

Hi Jörg,  
I am using an elasticsearch node embedded in my webapplication. Before my  
web app is unloaded from tomcat I am stopping the node. Is there a way to  
check that the node was completly stop or even to check if a node was  
started programatically ?  
Thank you very much.  
Doru

On Monday, April 7, 2014 7:26:31 PM UTC+2, Jörg Prante wrote:

> It seems you are not using a client but a data node?
> 
> You can not expect a data node in a web app context with an index works,  
> because in this case for example, your Tomcat wants to use an index  
> setting/mapping for an internal leakage check, which is doomed to fail.
> 
> Jörg
> 
> On Mon, Apr 7, 2014 at 5:47 PM, Doru Sular \<[doru....@gmail.com](mailto:doru....@gmail.com)\<javascript:\>
> 
> > wrote:
> 
> > Hello everybody,  
> > I am using elasticsearch embedded in my web application. I start the node  
> > via ContextListener method contextInitialized and I call node.stop() in  
> > contextDestroyed method of my ServletContextListener implementation.
> > 
> > However, the following message appear in the logs:
> > 
> > Apr 07, 2014 5:39:38 PM org.apache.catalina.loader.WebappClassLoader
> > 
> > > checkThreadLocalMapForLeaks  
> > > java.lang.IllegalArgumentException: Illegal shift value, must be 0..63  
> > > at  
> > > org.apache.lucene.util.NumericUtils.longToPrefixCoded(NumericUtils.java:114)  
> > > at  
> > > org.apache.lucene.analysis.NumericTokenStream$NumericTermAttributeImpl.reflectWith(NumericTokenStream.java:199)  
> > > at  
> > > org.apache.lucene.util.AttributeSource.reflectAsString(AttributeSource.java:430)  
> > > at  
> > > org.apache.catalina.loader.WebappClassLoader.checkThreadLocalMapForLeaks(WebappClassLoader.java:2521)  
> > > at  
> > > org.apache.catalina.loader.WebappClassLoader.clearReferences(WebappClassLoader.java:1996)  
> > > at  
> > > org.apache.catalina.loader.WebappLoader.stopInternal(WebappLoader.java:662)  
> > > at  
> > > org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5616)  
> > > at  
> > > org.apache.catalina.core.ContainerBase$StopChild.call(ContainerBase.java:1575)  
> > > at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)  
> > > at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)  
> > > at java.lang.Thread.run(Unknown Source)
> > 
> > I am using elasticsearch version 1.0.1.
> > 
> > Do you have any idea how I can shutdown ES in a friendly way?  
> > Thank you very much
> > 
> > --  
> > You received this message because you are subscribed to the Google Groups  
> > "elasticsearch" group.  
> > To unsubscribe from this group and stop receiving emails from it, send an  
> > email to [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> > To view this discussion on the web visit  
> > [https://groups.google.com/d/msgid/elasticsearch/2fa44b2d-9da6-4e77-89ac-6e03682240d1%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/2fa44b2d-9da6-4e77-89ac-6e03682240d1%40googlegroups.com)[https://groups.google.com/d/msgid/elasticsearch/2fa44b2d-9da6-4e77-89ac-6e03682240d1%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/2fa44b2d-9da6-4e77-89ac-6e03682240d1%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > .  
> > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/25d13fe0-116e-4481-9a52-28b159af6a27%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/25d13fe0-116e-4481-9a52-28b159af6a27%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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 6, 2017, 1:36am UTC](https://discuss.elastic.co/t/embedded-elasticsearch-on-shutdown-java-lang-illegalargumentexception-illegal-shift-value-must-be-0-63/16847/7 "2017-07-06T01:36:51Z")

</div>


