title: Nested References of Jar file libraries - java.lang.NoClassDefFoundError
body: <p>We are working on a web service created on Java 8. It references two jar files in its classpath. These two jar files are custom libraries created in order to make our common classes reusable among different web services we make.</p>
  
  <pre><code>Web Service Classpath:
  &gt; Jar 1
  &gt; Jar 2
  &gt; other jar files in its lib folder
  
  
  Jar 1 Classpath:
  &gt; /lib/httpclient-4.5.6.jar
  &gt; /lib/httpcore-4.4.4.jar
  ...others
  
  Jar 2 Classpath
  &gt; Jar 1
  &gt; other jar files in its lib folder
  </code></pre>
  
  <p>The web service calls a class in jar 2, and that class in jar 2 calls a utility class in jar 1. No compilation errors but when the function is executed, the ff. error is seen:</p>
  
  <pre><code>java.lang.NoClassDefFoundError: org.apache.http.HttpEntity
  </code></pre>
  
  <p>The httpEntity class is already in Jar 1 classpath via httpclient-4.5.6.jar. How come the web service cannot see it upon execution?</p>
  
  <p>Any idea what causes this? or how should we correctly do our references from custom libraries we create?</p>