title: java.lang.NoClassDefFoundError: org/apache/logging/log4j/Logger
body: <p>I want to perform unit testing in Elasticsearch for that I am using <code>Java-test-framework</code><br>
  I am using <code>Elasticsearch-1.6.0</code>
  and referring to these link for help 
  <a href="https://www.elastic.co/guide/en/elasticsearch/reference/1.6/using-elasticsearch-test-classes.html" rel="nofollow noreferrer">https://www.elastic.co/guide/en/elasticsearch/reference/1.6/using-elasticsearch-test-classes.html</a>
  <a href="https://github.com/elastic/elasticsearch/blob/master/core/src/test/java/org/elasticsearch/action/search/SearchRequestBuilderTests.java" rel="nofollow noreferrer">https://github.com/elastic/elasticsearch/blob/master/core/src/test/java/org/elasticsearch/action/search/SearchRequestBuilderTests.java</a></p>
  
  <p>here is the code </p>
  
  <pre><code>class CampaignESTest extends ESTestCase {
  
    def getCLient():MockTransportClient={
       val settings = Settings.builder()
                  .put(Environment.PATH_HOME_SETTING.getKey(), Files.createTempDir().toString())
                  .build();
       val client = new MockTransportClient(settings);  
       client
    }
   }
  
  class CampaignTestSearch extends PlaySpec{
    val client=new CampaignESTest
  
  val response = client.prepareSearch("dbtest")
        .setTypes(CAMPAIGN_COLLECTION_NAME)
        .setSearchType(SearchType.DFS_QUERY_THEN_FETCH)
        .addFields("uuid","campaignName","artworkID","activationDate","_source")
        .setQuery(query)
        .execute()
        .actionGet()
    }
  </code></pre>
  
  <p>I am getting this exception </p>
  
  <pre><code>  DeferredAbortedSuite:
  [info] Exception encountered when attempting to run a suite with class name: org.scalatest.DeferredAbortedSuite *** ABORTED ***
  [info]   java.lang.NoClassDefFoundError: org/apache/logging/log4j/Logger
  [info]   at org.elasticsearch.common.logging.Loggers.getLogger(Loggers.java:101)
  [info]   at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:92)
  [info]   at org.elasticsearch.bootstrap.BootstrapForTesting.&lt;clinit&gt;(BootstrapForTesting.java:78)
  [info]   at org.elasticsearch.test.ESTestCase.&lt;clinit&gt;(ESTestCase.java:138)
  [info]   at testcontrollers.campaign.CampaignTestSerach.&lt;init&gt;(CampaignTestSerach.scala:40)
  [info]   at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
  [info]   at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
  [info]   at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
  [info]   at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
  [info]   at java.lang.Class.newInstance(Class.java:442)
  [info]   ...
  [info]   Cause: java.lang.ClassNotFoundException: org.apache.logging.log4j.Logger
  [info]   at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
  [info]   at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
  [info]   at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
  [info]   at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
  [info]   at org.elasticsearch.common.logging.Loggers.getLogger(Loggers.java:101)
  [info]   at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:92)
  [info]   at org.elasticsearch.bootstrap.BootstrapForTesting.&lt;clinit&gt;(BootstrapForTesting.java:78)
  [info]   at org.elasticsearch.test.ESTestCase.&lt;clinit&gt;(ESTestCase.java:138)
  [info]   at testcontrollers.campaign.CampaignTestSerach.&lt;init&gt;(CampaignTestSerach.scala:40)
  [info]   at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
  [info]   ...
  [error] Uncaught exception when running testcontrollers.campaign.CampaignTestSerach: java.lang.NoClassDefFoundError: org/apache/logging/log4j/Logger
  </code></pre>
  
  <p>getting an exception on this line </p>
  
  <pre><code>val client=new CampaignESTest
  </code></pre>
  
  <p>in class <code>CampaignTestSearch</code></p>
  
  <p>here are the dependencies in <code>build.sbt</code> file </p>
  
  <pre><code>   "org.slf4j" % "slf4j-api" % "1.6.4",
                  "org.elasticsearch" % "elasticsearch" % "1.6.0",
                  "org.elasticsearch.test" % "framework" % "5.0.0" % "test",
                  "org.apache.lucene" % "lucene-test-framework" % "4.10.4" % "test",
                  "com.carrotsearch.randomizedtesting" % "randomizedtesting-runner" % "1.6.0" % "test",
                  "org.apache.lucene" % "lucene-codecs" % "4.10.4" % "test",
                  "org.apache.logging.log4j" % "log4j-core" % "2.8.2" ,
  "org.apache.lucene" % "lucene-expressions" % "4.10.4",
  </code></pre>
  
  <p>i suspect the cause of the exception maybe due to some versions of the dependencies can anyone please help with the correct library dependency version to make it to work or is there something else which i am missing  </p>
  
  <p><strong>Edit</strong>
  removed "test" from "org.apache.logging.log4j" % "log4j-core" % "2.8.2"
  <strong>Update <code>build.sbt</code></strong></p>
  
  <pre><code>"org.slf4j" % "slf4j-api" % "1.6.4",
                  "org.elasticsearch" % "elasticsearch" % "1.6.0",
                  "org.elasticsearch.test" % "framework" % "5.0.0" % "test",
                  "org.apache.lucene" % "lucene-test-framework" % "4.10.4" % "test",
                  "com.carrotsearch.randomizedtesting" % "randomizedtesting-runner" % "1.6.0" % "test",
                  "org.apache.lucene" % "lucene-codecs" % "4.10.4" % "test",
                  "org.apache.logging.log4j" % "log4j-core" % "2.8.2",
                  "org.apache.logging.log4j" % "log4j-slf4j-impl" % "2.8.2" ,
                  "org.apache.lucene" % "lucene-expressions" % "4.10.4",
  </code></pre>