# Jar Hell for Unit testing with jboss projects

**URL:** <https://discuss.elastic.co/t/jar-hell-for-unit-testing-with-jboss-projects/86304>\
**Category:** Elasticsearch\
**Created:** [May 18, 2017, 4:04pm UTC](https://discuss.elastic.co/t/jar-hell-for-unit-testing-with-jboss-projects/86304 "2017-05-18T16:04:34Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![elastic\_boston](https://avatars.discourse-cdn.com/v4/letter/e/a183cd/32.png) [@elastic\_boston](https://discuss.elastic.co/u/elastic_boston)\
**Post date:** [May 18, 2017, 4:04pm UTC](https://discuss.elastic.co/t/jar-hell-for-unit-testing-with-jboss-projects/86304/1 "2017-05-18T16:04:34Z")

</div>

I an trying to set up some unit tests using ESIntegTestCase. It seems that RandomizedRunner uses jboss servlet jars. This is causing jar hell for me. Where is this dependency? I need to exclude it.

java.lang.RuntimeException: found jar hell in test classpath  
at org.elasticsearch.bootstrap.BootstrapForTesting.(BootstrapForTesting.java:90)  
at org.elasticsearch.test.ESTestCase.(ESTestCase.java:168)  
at java.lang.Class.forName0(Native Method)  
at java.lang.Class.forName(Class.java:348)  
at com.carrotsearch.randomizedtesting.RandomizedRunner$2.run(RandomizedRunner.java:592)  
Caused by: java.lang.IllegalStateException: jar hell!  
class: javax.servlet.annotation.WebFilter  
jar1: /xx/.m2/repository/org/jboss/spec/javax/servlet/jboss-servlet-api\_3.0\_spec/1.0.1.Final/jboss-servlet-api\_3.0\_spec-1.0.1.Final.jar  
jar2: /xx/.m2/repository/org/jboss/spec/javax/servlet/jboss-servlet-api\_3.1\_spec/1.0.0.Final/jboss-servlet-api\_3.1\_spec-1.0.0.Final.jar  
at org.elasticsearch.bootstrap.JarHell.checkClass(JarHell.java:277)  
at org.elasticsearch.bootstrap.JarHell.checkJarHell(JarHell.java:187)  
at org.elasticsearch.bootstrap.JarHell.checkJarHell(JarHell.java:88)  
at org.elasticsearch.bootstrap.BootstrapForTesting.(BootstrapForTesting.java:88)

---

<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 18, 2017, 4:32pm UTC](https://discuss.elastic.co/t/jar-hell-for-unit-testing-with-jboss-projects/86304/2 "2017-05-18T16:32:36Z")

</div>

Are you sure those libs are coming from randomized testing framework ?

---

<div class="post-metadata">

**Author:** ![elastic\_boston](https://avatars.discourse-cdn.com/v4/letter/e/a183cd/32.png) [@elastic\_boston](https://discuss.elastic.co/u/elastic_boston)\
**Post date:** [May 18, 2017, 6:18pm UTC](https://discuss.elastic.co/t/jar-hell-for-unit-testing-with-jboss-projects/86304/3 "2017-05-18T18:18:47Z")

</div>

Good point. I'm not sure. But I don't know how to find out. The Eclipse dependency tree does not show up the jar.

---

<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 18, 2017, 7:24pm UTC](https://discuss.elastic.co/t/jar-hell-for-unit-testing-with-jboss-projects/86304/4 "2017-05-18T19:24:18Z")

</div>

May be share your `pom.xml` if it makes any sense.  
But I'm sure there are other eclipse users here who might have ideas...

---

<div class="post-metadata">

**Author:** ![elastic\_boston](https://avatars.discourse-cdn.com/v4/letter/e/a183cd/32.png) [@elastic\_boston](https://discuss.elastic.co/u/elastic_boston)\
**Post date:** [May 18, 2017, 8:06pm UTC](https://discuss.elastic.co/t/jar-hell-for-unit-testing-with-jboss-projects/86304/5 "2017-05-18T20:06:02Z")

</div>

I narrowed the problem down to a dependency on another project. Am including the pom for that project.

```
	<!-- Spec APIs provided by JBoss AS -->
	<dependency>
		<groupId>org.jboss.spec.javax.annotation</groupId>
		<artifactId>jboss-annotations-api_1.1_spec</artifactId>
		<scope>provided</scope>
	</dependency>
	<dependency>
		<groupId>org.jboss.spec.javax.resource</groupId>
		<artifactId>jboss-connector-api_1.7_spec</artifactId>
		<scope>provided</scope>
	</dependency>
	<dependency>
		<groupId>org.jboss.spec.javax.ejb</groupId>
		<artifactId>jboss-ejb-api_3.2_spec</artifactId>
		<scope>provided</scope>
	</dependency>
	<dependency>
		<groupId>javax.enterprise</groupId>
		<artifactId>cdi-api</artifactId>
		<scope>provided</scope>
	</dependency>
	<dependency>
		<groupId>javax.mail</groupId>
		<artifactId>mail</artifactId>
		<scope>provided</scope>
	</dependency>
	
	<!-- JBoss AS components -->
	<dependency>
		<groupId>org.hibernate</groupId>
		<artifactId>hibernate-core</artifactId>
		<scope>provided</scope>
	</dependency>
	<dependency>
		<groupId>org.hibernate</groupId>
		<artifactId>hibernate-envers</artifactId>
		<scope>provided</scope>
	</dependency>
	
	<!-- 3rd party libraries -->
	<dependency>
		<groupId>com.fasterxml.jackson.core</groupId>
		<artifactId>jackson-core</artifactId>
		<scope>provided</scope>
	</dependency>
	<dependency>
		<groupId>com.fasterxml.jackson.core</groupId>
		<artifactId>jackson-annotations</artifactId>
		<scope>provided</scope>
	</dependency>
	<dependency>
		<groupId>com.fasterxml.jackson.core</groupId>
		<artifactId>jackson-databind</artifactId>
		<scope>provided</scope>
	</dependency>
	<dependency>
        <groupId>org.apache.cxf</groupId>
		<artifactId>cxf-rt-frontend-simple</artifactId>
		<scope>provided</scope>
	</dependency>
	<dependency>
        <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-rt-frontend-jaxws</artifactId>
        <scope>provided</scope>
	</dependency>
	<dependency>
        <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-rt-core</artifactId>
        <scope>provided</scope>
	</dependency>
	<dependency>
        <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-rt-ws-security</artifactId>
        <scope>provided</scope>
        <exclusions>
        	<exclusion>
        		<groupId>org.opensaml</groupId>
        		<artifactId>opensaml</artifactId>
        	</exclusion>
        </exclusions>
	</dependency>
	<dependency>
        <groupId>org.apache.ws.security</groupId>
        <artifactId>wss4j</artifactId>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.jboss.ws</groupId>
        <artifactId>jbossws-api</artifactId>
        <scope>provided</scope>
    </dependency>
    <dependency>
	    <groupId>org.elasticsearch.client</groupId>
	    <artifactId>transport</artifactId>
        <scope>provided</scope>
        <exclusions>
        	<exclusion>
        		<groupId>com.fasterxml.jackson.core</groupId>
        		<artifactId>jackson-core</artifactId>
        	</exclusion>
        	<exclusion>
        		<groupId>com.fasterxml.jackson.core</groupId>
        		<artifactId>jackson-annotations</artifactId>
        	</exclusion>
        	<exclusion>
        		<groupId>com.fasterxml.jackson.dataformat</groupId>
        		<artifactId>jackson-dataformat-smile</artifactId>
        	</exclusion>
        	<exclusion>
        		<groupId>com.fasterxml.jackson.dataformat</groupId>
        		<artifactId>jackson-dataformat-yaml</artifactId>
        	</exclusion>
        	<exclusion>
        		<groupId>com.fasterxml.jackson.dataformat</groupId>
        		<artifactId>jackson-dataformat-cbor</artifactId>
        	</exclusion>
        </exclusions>
	</dependency>
	
	
	
	
	
	<!-- testing -->
	<dependency>
		<groupId>junit</groupId>
		<artifactId>junit</artifactId>
		<scope>test</scope>
	</dependency>
	<dependency>
		<groupId>org.hamcrest</groupId>
		<artifactId>hamcrest-all</artifactId>
		<scope>test</scope>
	</dependency>
	
	<dependency>
		<groupId>javax.xml.rpc</groupId>
		<artifactId>javax.xml.rpc-api</artifactId>
		<version>1.1.1</version>
		<scope>test</scope>
	</dependency>
	<dependency>
		<groupId>org.jboss.spec.javax.el</groupId>
		<artifactId>jboss-el-api_3.0_spec</artifactId>
		<scope>test</scope>
	</dependency>
	<dependency>
		<groupId>org.apache.neethi</groupId>
		<artifactId>neethi</artifactId>
		<scope>test</scope>
	</dependency>
</dependencies>

<build>
	<finalName>${project.artifactId}</finalName>

	<plugins>
		<plugin>
			<artifactId>maven-antrun-plugin</artifactId>
			<executions>
				<execution>
					<id>gis-build-properties</id>
					<phase>prepare-package</phase>
					<configuration>
						<target>
							<hostinfo prefix="buildhost" />
							
							<mkdir dir="${project.build.outputDirectory}/META-INF" />
							
								<propertyset>
									<propertyref prefix="java." />
								</propertyset>
								<propertyset>
									<propertyref prefix="os." />
								</propertyset>
							</echoproperties>

						</target>
					</configuration>
					<goals>
						<goal>run</goal>
					</goals>
				</execution>
			</executions>
		</plugin>
		<plugin>
			<artifactId>maven-ejb-plugin</artifactId>
			<configuration>
				<!-- Tell Maven we are using EJB 3.1 -->
				<ejbVersion>3.1</ejbVersion>
			</configuration>
		</plugin>
		<plugin>
			<artifactId>maven-shade-plugin</artifactId>
			<executions>
				<execution>
					<phase>package</phase>
					<goals>
						<goal>shade</goal>
					</goals>
					<configuration>
						<shadedArtifactAttached>true</shadedArtifactAttached>
						<shadedClassifierName>merged</shadedClassifierName>
						<artifactSet>
							<includes>
								<!-- matching resources will be overwritten in the order of processing 
									defined by the include list below (impacts META-INF/*.xml files) -->
								
							</includes>
						</artifactSet>
					</configuration>
				</execution>
			</executions>
		</plugin>

		<!-- Attach test-jar -->
		<plugin>
			<groupId>org.apache.maven.plugins</groupId>
			<artifactId>maven-jar-plugin</artifactId>
			<executions>
				<execution>
					<id>default-test-jar</id>
					<phase>package</phase>
					<goals>
						<goal>test-jar</goal>
					</goals>
				</execution>
			</executions>
		</plugin>
	</plugins>
</build>

```

---

<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 18, 2017, 8:21pm UTC](https://discuss.elastic.co/t/jar-hell-for-unit-testing-with-jboss-projects/86304/6 "2017-05-18T20:21:55Z")

</div>

So you probably exclude some conflicting libs in your own `pom` I believe.

Good luck 🙂

---

<div class="post-metadata">

**Author:** ![elastic\_boston](https://avatars.discourse-cdn.com/v4/letter/e/a183cd/32.png) [@elastic\_boston](https://discuss.elastic.co/u/elastic_boston)\
**Post date:** [May 18, 2017, 10:18pm UTC](https://discuss.elastic.co/t/jar-hell-for-unit-testing-with-jboss-projects/86304/7 "2017-05-18T22:18:11Z")

</div>

Is there a way to find where a jar is being called from? I have tried maven-duplicate-finder and tattletale, and they both don't work for me. Any other way to locate errant jars?

---

<div class="post-metadata">

**Author:** ![jasontedor](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jasontedor/32/66992_2.png) [@jasontedor](https://discuss.elastic.co/u/jasontedor)\
**Post date:** [May 19, 2017, 2:22am UTC](https://discuss.elastic.co/t/jar-hell-for-unit-testing-with-jboss-projects/86304/8 "2017-05-19T02:22:50Z")

</div>

> [@elastic\_boston](#):
>
> It seems that RandomizedRunner uses jboss servlet jars.

You are misunderstanding the stack trace. You have JAR hell with two of your own dependencies, versions 3.0 and 3.1 of the servlet spec. These are not coming from randomized runner but they are simply on the stack trace since randomized runner is our test runner and we have JAR hell checks in our base test class.

---

<div class="post-metadata">

**Author:** ![elastic\_boston](https://avatars.discourse-cdn.com/v4/letter/e/a183cd/32.png) [@elastic\_boston](https://discuss.elastic.co/u/elastic_boston)\
**Post date:** [May 24, 2017, 12:24pm UTC](https://discuss.elastic.co/t/jar-hell-for-unit-testing-with-jboss-projects/86304/9 "2017-05-24T12:24:38Z")

</div>

How do I locate which dependancies are pointing to these jars? I have tried

- Various exclusions in my pom
- Viewing the classpath in Eclipse (this shows only one of the jars being loaded)
- mvn dependency:tree -Dverbose=true (does not show these jars)

What else can I do?

It seems that jar hell that ESIntegTestCase is something a lot of users run into, so it would be good to figure out a solution to this.

---

<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:** [June 21, 2017, 12:24pm UTC](https://discuss.elastic.co/t/jar-hell-for-unit-testing-with-jboss-projects/86304/10 "2017-06-21T12:24:59Z")

</div>

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