title: Dropwizard, swagger and in-memory hiverunner/hiveqlunit integration
body: <p>I am having some trouble trying to run an in-memory <code>hive</code> while writing tests for a <code>dropwizard</code> <code>swagger</code> app. I have tried both <code>hiverunner</code> and <code>hiveqlunit</code>. </p>
  
  <p>There are 2 types of tests. One is for testing <code>dropwizard</code>/<code>swagger</code> API endpoints using <code>dropwizard</code> integration testing (no need for <code>hive</code> here) and the other is for testing the <code>hive</code> integration where I need to hit the api and setup an in-memory <code>hive</code> to query and verify data is stored in <code>hiveDB</code> (psql).</p>
  
  <p>The two in-memory <code>hive</code> dependencies (Note that I am using one at a time) always have some kind of conflict with the existing <code>dropwizard</code> and <code>swagger</code> dependencies. I am guessing it has something to do with <code>jersey</code> but I've tried a lot of things and still no luck.</p>
  
  <p>I can run in-memory <code>hive</code> just fine and do all <code>CRUD</code> if I am not hitting the <code>dropwizard/swagger</code> api. But I just can't get the two services to play along at the moment.</p>
  
  <p>Versions in <code>Maven</code>:</p>
  
  <pre><code>io.dropwizard:dropwizard-core version: 0.9.2
  com.smoketurner:dropwizard-swagger version: 0.9.2-3
  com.facebook.presto.hive:hive-apache-jdbc version: 0.13.1-3
  
  com.klarna:hiverunner version: 3.0.0
  OR
  org.finra.hiveqlunit:hiveQLUnit version: 1.0
  </code></pre>
  
  <p><code>dropwizard-swagger</code> uses <code>org.reflections:reflections:jar:0.9.10</code> and <code>com.klarna:hiverunner</code> uses <code>org.reflections:reflections:jar:0.9.8</code>.</p>
  
  <p>When I didn't exclude anything, I got the following:</p>
  
  <pre><code>java.lang.NoSuchMethodError: org.reflections.util.ClasspathHelper.forPackage(Ljava/lang/String;[Ljava/lang/ClassLoader;)Ljava/util/Collection;
  </code></pre>
  
  <p>So I tried excluding <code>org.reflections:reflections</code> from <code>hiverunner</code> and I got the 3 <code>Exceptions</code>:</p>
  
  <pre><code>java.lang.RuntimeException: javax.servlet.ServletException: io.dropwizard.jersey.setup.JerseyServletContainer-73437222@8a344094==io.dropwizard.jersey.setup.JerseyServletContainer,1,false
  Caused by: A MultiException has 3 exceptions.  They are:
  1. java.lang.NullPointerException
  2. java.lang.IllegalStateException: Unable to perform operation: method inject on com.sun.jersey.json.impl.provider.entity.JSONRootElementProvider$App
  3. java.lang.IllegalStateException: Unable to perform operation: create on org.glassfish.jersey.message.internal.MessageBodyFactory
  </code></pre>
  
  <p>Then I tried excluding <code>org.reflections:reflections</code> from <code>dropwizard-swagger</code> and added a separate dependency for <code>org.reflections:reflections</code> by adding the following dependency to my <code>pom.xml</code>:</p>
  
  <pre><code>&lt;dependency&gt;
      &lt;groupId&gt;org.reflections&lt;/groupId&gt;
      &lt;artifactId&gt;reflections&lt;/artifactId&gt;
      &lt;version&gt;0.9.10&lt;/version&gt;
  &lt;/dependency&gt;
  </code></pre>
  
  <p>And got the following:</p>
  
  <pre><code>java.lang.NoClassDefFoundError: com/google/common/base/MoreObjects
  </code></pre>
  
  <p>So I added the latest <code>guava</code> (version 20.0) and then it gives me another error. This seems like dependency hell.</p>
  
  <p>Has anyone ever encountered this problem before? It seems like <code>dropwizard</code> and <code>hiverunner</code> do not play along well. Maybe it has to do with the versioning of <code>jersey</code> 1 &amp; 2.</p>
  
  <p>I got some other error regarding <code>jackson-databind</code>, so I did some research and found out I had to have the same version for the following dependencies:</p>
  
  <pre><code>com.fasterxml.jackson.core:jackson-databind (from `dropwizard`)
  com.fasterxml.jackson.module:jackson-module-scala (from `hiverunner/hiveqlunit`)
  </code></pre>
  
  <p>And now I am back to the previous 3 <code>Exceptions</code>...</p>
  
  <p>Any help will be appreciated.</p>
  
  <hr>
  
  <p><strong><em>Edit:</em></strong> Found out that <code>hiveqlunit</code> is using the following:</p>
  
  <pre><code>com.sun.jersey:jersey-server:jar:1.9
  </code></pre>
  
  <p>Which is one of the last versions before moving to the following <code>maven</code> dependency:</p>
  
  <pre><code>org.glassfish.jersey.core:jersey-server
  </code></pre>
  
  <p>It is having conflicts with <code>dropwizard</code>'s <code>org.glassfish.jersey.core:jersey-server:jar:2.22.</code></p>
  
  <p>How can i resolve this conflict?</p>