title: Cannot maven build spring boot application with elastic search
body: <p>I am trying to use elastic search in my spring boot application. The project runs fine when I run it with the IDE, i.e. with the embedded tomcat server of spring boot application.
  When I try to run "mvn clean install" to package it for deployment,the build prompts me with </p>
  
  <p><code>NoClassDefFoundError</code> Exception</p>
  
  <p>Here lies my stack trace that caused the problem</p>
  
  <pre><code>Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'elasticService' defined in file [/home/abiral/apps/elastic-project/target/classes/com/elastic/project/elasticproject/elastic/ElasticService.class]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.elastic.project.elasticproject.elastic.ElasticService]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: org/elasticsearch/script/ScriptEngine
  </code></pre>
  
  <p>My Pom dependencies</p>
  
  <pre><code>&lt;dependencies&gt;
  
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-web&lt;/artifactId&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-test&lt;/artifactId&gt;
  
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;com.google.code.gson&lt;/groupId&gt;
          &lt;artifactId&gt;gson&lt;/artifactId&gt;
          &lt;version&gt;2.8.5&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.elasticsearch.client&lt;/groupId&gt;
          &lt;artifactId&gt;transport&lt;/artifactId&gt;
          &lt;version&gt;6.3.2&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-data-elasticsearch&lt;/artifactId&gt;
      &lt;/dependency&gt;
  
  
  
  
  
  
  &lt;/dependencies&gt;
  </code></pre>
  
  <p>Has anybody faced this issue before?
  I googled, but couldn't find a solution that worked for me.
  Please suggest me a solution.</p>
  
  <p><code>mvn dependency:tree</code></p>
  
  <pre><code>[INFO] com.elastic.project:elastic-project:jar:0.0.1-SNAPSHOT
  [INFO] +- org.springframework.boot:spring-boot-starter-     web:jar:2.0.4.RELEASE:compile
  [INFO] |  +- org.springframework.boot:spring-boot-starter:jar:2.0.4.RELEASE:compile
  [INFO] |  |  +- org.springframework.boot:spring-boot:jar:2.0.4.RELEASE:compile
  [INFO] |  |  +- org.springframework.boot:spring-boot-autoconfigure:jar:2.0.4.RELEASE:compile
  [INFO] |  |  +- org.springframework.boot:spring-boot-starter-logging:jar:2.0.4.RELEASE:compile
  [INFO] |  |  |  +- ch.qos.logback:logback-classic:jar:1.2.3:compile
  [INFO] |  |  |  |  \- ch.qos.logback:logback-core:jar:1.2.3:compile
  [INFO] |  |  |  +- org.apache.logging.log4j:log4j-to-slf4j:jar:2.10.0:compile
  [INFO] |  |  |  \- org.slf4j:jul-to-slf4j:jar:1.7.25:compile
  [INFO] |  |  +- javax.annotation:javax.annotation-api:jar:1.3.2:compile
  [INFO] |  |  \- org.yaml:snakeyaml:jar:1.19:compile
  [INFO] |  +- org.springframework.boot:spring-boot-starter-json:jar:2.0.4.RELEASE:compile
  [INFO] |  |  +- com.fasterxml.jackson.core:jackson-databind:jar:2.9.6:compile
  [INFO] |  |  |  \- com.fasterxml.jackson.core:jackson-annotations:jar:2.9.0:compile
  [INFO] |  |  +- com.fasterxml.jackson.datatype:jackson-datatype-jdk8:jar:2.9.6:compile
  [INFO] |  |  +- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:jar:2.9.6:compile
  [INFO] |  |  \- com.fasterxml.jackson.module:jackson-module-parameter-names:jar:2.9.6:compile
  [INFO] |  +- org.springframework.boot:spring-boot-starter-tomcat:jar:2.0.4.RELEASE:compile
  [INFO] |  |  +- org.apache.tomcat.embed:tomcat-embed-core:jar:8.5.32:compile
  [INFO] |  |  +- org.apache.tomcat.embed:tomcat-embed-el:jar:8.5.32:compile
  [INFO] |  |  \- org.apache.tomcat.embed:tomcat-embed-websocket:jar:8.5.32:compile
  [INFO] |  +- org.hibernate.validator:hibernate-validator:jar:6.0.11.Final:compile
  [INFO] |  |  +- javax.validation:validation-api:jar:2.0.1.Final:compile
  [INFO] |  |  +- org.jboss.logging:jboss-logging:jar:3.3.2.Final:compile
  [INFO] |  |  \- com.fasterxml:classmate:jar:1.3.4:compile
  [INFO] |  +- org.springframework:spring-web:jar:5.0.8.RELEASE:compile
  [INFO] |  |  \- org.springframework:spring-beans:jar:5.0.8.RELEASE:compile
  [INFO] |  \- org.springframework:spring-webmvc:jar:5.0.8.RELEASE:compile
  [INFO] |     +- org.springframework:spring-aop:jar:5.0.8.RELEASE:compile
  [INFO] |     +- org.springframework:spring-context:jar:5.0.8.RELEASE:compile
  [INFO] |     \- org.springframework:spring-expression:jar:5.0.8.RELEASE:compile
  [INFO] +- org.springframework.boot:spring-boot-starter-test:jar:2.0.4.RELEASE:compile
  [INFO] |  +- org.springframework.boot:spring-boot-test:jar:2.0.4.RELEASE:compile
  [INFO] |  +- org.springframework.boot:spring-boot-test-autoconfigure:jar:2.0.4.RELEASE:compile
  [INFO] |  +- com.jayway.jsonpath:json-path:jar:2.4.0:compile
  [INFO] |  |  +- net.minidev:json-smart:jar:2.3:compile
  [INFO] |  |  |  \- net.minidev:accessors-smart:jar:1.2:compile
  [INFO] |  |  |     \- org.ow2.asm:asm:jar:5.0.4:compile
  [INFO] |  |  \- org.slf4j:slf4j-api:jar:1.7.25:compile
  [INFO] |  +- junit:junit:jar:4.12:compile
  [INFO] |  +- org.assertj:assertj-core:jar:3.9.1:compile
  [INFO] |  +- org.mockito:mockito-core:jar:2.15.0:compile
  [INFO] |  |  +- net.bytebuddy:byte-buddy:jar:1.7.11:compile
  [INFO] |  |  +- net.bytebuddy:byte-buddy-agent:jar:1.7.11:compile
  [INFO] |  |  \- org.objenesis:objenesis:jar:2.6:compile
  [INFO] |  +- org.hamcrest:hamcrest-core:jar:1.3:compile
  [INFO] |  +- org.hamcrest:hamcrest-library:jar:1.3:compile
  [INFO] |  +- org.skyscreamer:jsonassert:jar:1.5.0:compile
  [INFO] |  |  \- com.vaadin.external.google:android-json:jar:0.0.20131108.vaadin1:compile
  [INFO] |  +- org.springframework:spring-core:jar:5.0.8.RELEASE:compile
  [INFO] |  |  \- org.springframework:spring-jcl:jar:5.0.8.RELEASE:compile
  [INFO] |  +- org.springframework:spring-test:jar:5.0.8.RELEASE:compile
  [INFO] |  \- org.xmlunit:xmlunit-core:jar:2.5.1:compile
  [INFO] +- com.google.code.gson:gson:jar:2.8.5:compile
  [INFO] +- org.elasticsearch.client:transport:jar:6.3.2:compile
  [INFO] |  +- org.elasticsearch:elasticsearch:jar:5.6.10:compile
  [INFO] |  |  +- org.apache.lucene:lucene-core:jar:6.6.1:compile
  [INFO] |  |  +- org.apache.lucene:lucene-analyzers-common:jar:6.6.1:compile
  [INFO] |  |  +- org.apache.lucene:lucene-backward-codecs:jar:6.6.1:compile
  [INFO] |  |  +- org.apache.lucene:lucene-grouping:jar:6.6.1:compile
  [INFO] |  |  +- org.apache.lucene:lucene-highlighter:jar:6.6.1:compile
  [INFO] |  |  +- org.apache.lucene:lucene-join:jar:6.6.1:compile
  [INFO] |  |  +- org.apache.lucene:lucene-memory:jar:6.6.1:compile
  [INFO] |  |  +- org.apache.lucene:lucene-misc:jar:6.6.1:compile
  [INFO] |  |  +- org.apache.lucene:lucene-queries:jar:6.6.1:compile
  [INFO] |  |  +- org.apache.lucene:lucene-queryparser:jar:6.6.1:compile
  [INFO] |  |  +- org.apache.lucene:lucene-sandbox:jar:6.6.1:compile
  [INFO] |  |  +- org.apache.lucene:lucene-spatial:jar:6.6.1:compile
  [INFO] |  |  +- org.apache.lucene:lucene-spatial-extras:jar:6.6.1:compile
  [INFO] |  |  +- org.apache.lucene:lucene-spatial3d:jar:6.6.1:compile
  [INFO] |  |  +- org.apache.lucene:lucene-suggest:jar:6.6.1:compile
  [INFO] |  |  +- org.elasticsearch:securesm:jar:1.2:compile
  [INFO] |  |  +- net.sf.jopt-simple:jopt-simple:jar:5.0.2:compile
  [INFO] |  |  +- com.carrotsearch:hppc:jar:0.7.1:compile
  [INFO] |  |  +- joda-time:joda-time:jar:2.9.9:compile
  [INFO] |  |  +- com.fasterxml.jackson.core:jackson-core:jar:2.9.6:compile
  [INFO] |  |  +- com.fasterxml.jackson.dataformat:jackson-dataformat-smile:jar:2.9.6:compile
  [INFO] |  |  +- com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:jar:2.9.6:compile
  [INFO] |  |  +- com.fasterxml.jackson.dataformat:jackson-dataformat-cbor:jar:2.9.6:compile
  [INFO] |  |  +- com.tdunning:t-digest:jar:3.0:compile
  [INFO] |  |  +- org.hdrhistogram:HdrHistogram:jar:2.1.9:compile
  [INFO] |  |  +- org.apache.logging.log4j:log4j-api:jar:2.10.0:compile
  [INFO] |  |  \- org.elasticsearch:jna:jar:4.4.0-1:compile
  [INFO] |  +- org.elasticsearch.plugin:transport-netty4-client:jar:5.6.10:compile
  [INFO] |  |  +- io.netty:netty-buffer:jar:4.1.27.Final:compile
  [INFO] |  |  +- io.netty:netty-codec:jar:4.1.27.Final:compile
  [INFO] |  |  +- io.netty:netty-codec-http:jar:4.1.27.Final:compile
  [INFO] |  |  +- io.netty:netty-common:jar:4.1.27.Final:compile
  [INFO] |  |  +- io.netty:netty-handler:jar:4.1.27.Final:compile
  [INFO] |  |  +- io.netty:netty-resolver:jar:4.1.27.Final:compile
  [INFO] |  |  +- io.netty:netty-transport:jar:4.1.27.Final:compile
  [INFO] |  |  +- org.locationtech.spatial4j:spatial4j:jar:0.6:compile
  [INFO] |  |  +- com.vividsolutions:jts:jar:1.13:compile
  [INFO] |  |  \- org.apache.logging.log4j:log4j-core:jar:2.10.0:compile
  [INFO] |  +- org.elasticsearch.plugin:reindex-client:jar:6.3.2:compile
  [INFO] |  |  \- org.elasticsearch.client:elasticsearch-rest-client:jar:6.3.2:compile
  [INFO] |  |     +- org.apache.httpcomponents:httpclient:jar:4.5.6:compile
  [INFO] |  |     +- org.apache.httpcomponents:httpcore:jar:4.4.10:compile
  [INFO] |  |     +- org.apache.httpcomponents:httpasyncclient:jar:4.1.3:compile
  [INFO] |  |     +- org.apache.httpcomponents:httpcore-nio:jar:4.4.10:compile
  [INFO] |  |     +- commons-codec:commons-codec:jar:1.11:compile
  [INFO] |  |     \- commons-logging:commons-logging:jar:1.1.3:compile
  [INFO] |  +- org.elasticsearch.plugin:lang-mustache-client:jar:6.3.2:compile
  [INFO] |  |  \- com.github.spullara.mustache.java:compiler:jar:0.9.3:compile
  [INFO] |  +- org.elasticsearch.plugin:percolator-client:jar:6.3.2:compile
  [INFO] |  +- org.elasticsearch.plugin:parent-join-client:jar:6.3.2:compile
  [INFO] |  \- org.elasticsearch.plugin:rank-eval-client:jar:6.3.2:compile
  [INFO] \- org.springframework.boot:spring-boot-starter-data-elasticsearch:jar:2.0.4.RELEASE:compile
  [INFO]    \- org.springframework.data:spring-data-elasticsearch:jar:3.0.9.RELEASE:compile
  [INFO]       +- org.springframework:spring-tx:jar:5.0.8.RELEASE:compile
  [INFO]       \- org.springframework.data:spring-data-commons:jar:2.0.9.RELEASE:compile
  </code></pre>