# Maven shade during build strips guava classes

**URL:** <https://discuss.elastic.co/t/maven-shade-during-build-strips-guava-classes/9266>\
**Category:** Elasticsearch\
**Created:** [October 7, 2012, 9:55am UTC](https://discuss.elastic.co/t/maven-shade-during-build-strips-guava-classes/9266 "2012-10-07T09:55:15Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [October 7, 2012, 9:55am UTC](https://discuss.elastic.co/t/maven-shade-during-build-strips-guava-classes/9266/1 "2012-10-07T09:55:15Z")

</div>

Hi there,

I am struggling right now with a strange problem of missing classes of  
google guava in elasticsearch, even though the non-shaded version  
includes what I am searching for.

The concrete class is the  
com.google.common.util.concurrent.AbstractScheduledService, which I  
would like to use. However, it seems not to be available in  
elasticsearch 0.19.10, and it is also not available when I am  
searching for, after I build the jar myself from the current github  
master.  
I could not find anything obvious about excluding it on the pom.xml,  
however I've never really worked with the shade plugin, so there might  
be some setting I just have overlooked.

The only thing I could imagine is, that it is missing because there is  
a different relocation happening for  
org.elasticsearch.common.util.concurrent.jsr166y and  
org.elasticsearch.common.util.concurrent.jsr166e packages.

Can anyone shed light on this?

Thanks and regards, Alexander

--

---

<div class="post-metadata">

**Author:** ![Chris\_Male](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/chris_male/32/2607_2.png) [@Chris\_Male](https://discuss.elastic.co/u/Chris_Male)\
**Post date:** [October 8, 2012, 3:37am UTC](https://discuss.elastic.co/t/maven-shade-during-build-strips-guava-classes/9266/2 "2012-10-08T03:37:27Z")

</div>

Hi,

Funny you raise this issue, a few similar situation tripped me up just  
recently too.

What the shade plugin configuration is doing is basically picking a few  
packages from Guava and 'shading' them into the ES jar until new package  
names. The Guava dependency, including those packages not shaded, is then  
not distributed along with ES. AbstractScheduledService is in a package  
which is not shaded, which is why you cannot find it.

Are you creating a plugin or using ES in a client application? If so, you  
can go ahead and include a Guava version in your application and because ES  
has shaded its use of Guava to new packages, you won't have any classpath  
collisions.

On Sunday, October 7, 2012 10:55:18 PM UTC+13, Alexander Reelsen wrote:

> Hi there,
> 
> I am struggling right now with a strange problem of missing classes of  
> google guava in elasticsearch, even though the non-shaded version  
> includes what I am searching for.
> 
> The concrete class is the  
> com.google.common.util.concurrent.AbstractScheduledService, which I  
> would like to use. However, it seems not to be available in  
> elasticsearch 0.19.10, and it is also not available when I am  
> searching for, after I build the jar myself from the current github  
> master.  
> I could not find anything obvious about excluding it on the pom.xml,  
> however I've never really worked with the shade plugin, so there might  
> be some setting I just have overlooked.
> 
> The only thing I could imagine is, that it is missing because there is  
> a different relocation happening for  
> org.elasticsearch.common.util.concurrent.jsr166y and  
> org.elasticsearch.common.util.concurrent.jsr166e packages.
> 
> Can anyone shed light on this?
> 
> Thanks and regards, Alexander

--

---

<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:** [October 8, 2012, 8:21am UTC](https://discuss.elastic.co/t/maven-shade-during-build-strips-guava-classes/9266/3 "2012-10-08T08:21:29Z")

</div>

The reason is the "minimize = true" option in the shading, this drops all  
classes not used from the included jars.

Jörg

On Monday, October 8, 2012 5:37:27 AM UTC+2, Chris Male wrote:

> Hi,
> 
> Funny you raise this issue, a few similar situation tripped me up just  
> recently too.
> 
> What the shade plugin configuration is doing is basically picking a few  
> packages from Guava and 'shading' them into the ES jar until new package  
> names. The Guava dependency, including those packages not shaded, is then  
> not distributed along with ES. AbstractScheduledService is in a package  
> which is not shaded, which is why you cannot find it.
> 
> Are you creating a plugin or using ES in a client application? If so, you  
> can go ahead and include a Guava version in your application and because ES  
> has shaded its use of Guava to new packages, you won't have any classpath  
> collisions.
> 
> On Sunday, October 7, 2012 10:55:18 PM UTC+13, Alexander Reelsen wrote:
> 
> > Hi there,
> > 
> > I am struggling right now with a strange problem of missing classes of  
> > google guava in elasticsearch, even though the non-shaded version  
> > includes what I am searching for.
> > 
> > The concrete class is the  
> > com.google.common.util.concurrent.AbstractScheduledService, which I  
> > would like to use. However, it seems not to be available in  
> > elasticsearch 0.19.10, and it is also not available when I am  
> > searching for, after I build the jar myself from the current github  
> > master.  
> > I could not find anything obvious about excluding it on the pom.xml,  
> > however I've never really worked with the shade plugin, so there might  
> > be some setting I just have overlooked.
> > 
> > The only thing I could imagine is, that it is missing because there is  
> > a different relocation happening for  
> > org.elasticsearch.common.util.concurrent.jsr166y and  
> > org.elasticsearch.common.util.concurrent.jsr166e packages.
> > 
> > Can anyone shed light on this?
> > 
> > Thanks and regards, Alexander

--

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [October 8, 2012, 3:10pm UTC](https://discuss.elastic.co/t/maven-shade-during-build-strips-guava-classes/9266/4 "2012-10-08T15:10:43Z")

</div>

Hi

On Mon, Oct 8, 2012 at 10:21 AM, Jörg Prante [joergprante@gmail.com](mailto:joergprante@gmail.com) wrote:

> The reason is the "minimize = true" option in the shading, this drops all  
> classes not used from the included jars.  
> Damn, had overlooked that one. Thanks for pointing out!  
> Chris: I am writing a plugin, but it shouldnt be a problem as well to  
> include guava in it, as the package path is changed for the  
> elasticsearch specific part. However, moving in the whole dependency  
> just for the abstract service seems too much, I'll keep with threads  
> then...

Thanks for your help!

--Alexander

--

---

<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, 3:09am UTC](https://discuss.elastic.co/t/maven-shade-during-build-strips-guava-classes/9266/5 "2017-07-06T03:09:45Z")

</div>


