title: Getting java.lang.NoSuchMethodError: org.glassfish.hk2.utilities.reflection.ReflectionHelper.makeMe
body: <p>I am facing troubles in exposing RESTful Api from my application.
  The application is based on <code>java8</code> with <code>Tomcat7</code> and <code>Jersey2</code> is used for exposing RESTful api.</p>
  
  <p>For the moment, the code is quite easy, but still does not work.
  When I try to deploy the application on the server I get the following stacktrace:</p>
  
  <pre><code>Jun 08, 2017 3:02:06 PM org.apache.catalina.core.ApplicationContext log
  SEVERE: StandardWrapper.Throwable
  MultiException stack 1 of 2
  java.lang.NoSuchMethodError: org.glassfish.hk2.utilities.reflection.ReflectionHelper.makeMe(Ljava/lang/reflect/Constructor;[Ljava/lang/Object;)Ljava/lang/Object;
      at org.jvnet.hk2.internal.ClazzCreator.createMe(ClazzCreator.java:244)
      at org.jvnet.hk2.internal.ClazzCreator.create(ClazzCreator.java:319)
      at org.jvnet.hk2.internal.SystemDescriptor.create(SystemDescriptor.java:448)
      at org.jvnet.hk2.internal.SingletonContext.findOrCreate(SingletonContext.java:107)
      at org.jvnet.hk2.internal.Utilities.createService(Utilities.java:2203)
      at org.jvnet.hk2.internal.ServiceLocatorImpl.getService(ServiceLocatorImpl.java:579)
      at org.jvnet.hk2.internal.ServiceLocatorImpl.getService(ServiceLocatorImpl.java:566)
      at org.glassfish.hk2.utilities.ServiceLocatorUtilities.enablePerThreadScope(ServiceLocatorUtilities.java:86)
      at org.glassfish.jersey.internal.inject.Injections._createLocator(Injections.java:144)
      at org.glassfish.jersey.internal.inject.Injections.createLocator(Injections.java:137)
      at org.glassfish.jersey.server.ApplicationHandler.&lt;init&gt;(ApplicationHandler.java:265)
      at org.glassfish.jersey.servlet.WebComponent.&lt;init&gt;(WebComponent.java:262)
      at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:167)
      at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:349)
      at javax.servlet.GenericServlet.init(GenericServlet.java:160)
      at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1280)
      at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1193)
      at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1088)
      at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5176)
      at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5460)
      at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
      at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
      at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
      at java.util.concurrent.FutureTask.run(FutureTask.java:266)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
      at java.lang.Thread.run(Thread.java:748)
  MultiException stack 2 of 2
  java.lang.IllegalStateException: Unable to perform operation: create on org.jvnet.hk2.internal.DynamicConfigurationServiceImpl
      at org.jvnet.hk2.internal.ClazzCreator.create(ClazzCreator.java:346)
      at org.jvnet.hk2.internal.SystemDescriptor.create(SystemDescriptor.java:448)
      at org.jvnet.hk2.internal.SingletonContext.findOrCreate(SingletonContext.java:107)
      at org.jvnet.hk2.internal.Utilities.createService(Utilities.java:2203)
      at org.jvnet.hk2.internal.ServiceLocatorImpl.getService(ServiceLocatorImpl.java:579)
      at org.jvnet.hk2.internal.ServiceLocatorImpl.getService(ServiceLocatorImpl.java:566)
      at org.glassfish.hk2.utilities.ServiceLocatorUtilities.enablePerThreadScope(ServiceLocatorUtilities.java:86)
      at org.glassfish.jersey.internal.inject.Injections._createLocator(Injections.java:144)
      at org.glassfish.jersey.internal.inject.Injections.createLocator(Injections.java:137)
      at org.glassfish.jersey.server.ApplicationHandler.&lt;init&gt;(ApplicationHandler.java:265)
      at org.glassfish.jersey.servlet.WebComponent.&lt;init&gt;(WebComponent.java:262)
      at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:167)
      at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:349)
      at javax.servlet.GenericServlet.init(GenericServlet.java:160)
      at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1280)
      at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1193)
      at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1088)
      at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5176)
      at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5460)
      at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
      at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
      at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
      at java.util.concurrent.FutureTask.run(FutureTask.java:266)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
      at java.lang.Thread.run(Thread.java:748)
  
  Jun 08, 2017 3:02:06 PM org.apache.catalina.core.StandardContext loadOnStartup
  SEVERE: Servlet /SmartFabConnector threw load() exception
  java.lang.NoSuchMethodError: org.glassfish.hk2.utilities.reflection.ReflectionHelper.makeMe(Ljava/lang/reflect/Constructor;[Ljava/lang/Object;)Ljava/lang/Object;
      at org.jvnet.hk2.internal.ClazzCreator.createMe(ClazzCreator.java:244)
      at org.jvnet.hk2.internal.ClazzCreator.create(ClazzCreator.java:319)
      at org.jvnet.hk2.internal.SystemDescriptor.create(SystemDescriptor.java:448)
      at org.jvnet.hk2.internal.SingletonContext.findOrCreate(SingletonContext.java:107)
      at org.jvnet.hk2.internal.Utilities.createService(Utilities.java:2203)
      at org.jvnet.hk2.internal.ServiceLocatorImpl.getService(ServiceLocatorImpl.java:579)
      at org.jvnet.hk2.internal.ServiceLocatorImpl.getService(ServiceLocatorImpl.java:566)
      at org.glassfish.hk2.utilities.ServiceLocatorUtilities.enablePerThreadScope(ServiceLocatorUtilities.java:86)
      at org.glassfish.jersey.internal.inject.Injections._createLocator(Injections.java:144)
      at org.glassfish.jersey.internal.inject.Injections.createLocator(Injections.java:137)
      at org.glassfish.jersey.server.ApplicationHandler.&lt;init&gt;(ApplicationHandler.java:265)
      at org.glassfish.jersey.servlet.WebComponent.&lt;init&gt;(WebComponent.java:262)
      at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:167)
      at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:349)
      at javax.servlet.GenericServlet.init(GenericServlet.java:160)
      at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1280)
      at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1193)
      at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1088)
      at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5176)
      at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5460)
      at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
      at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
      at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
      at java.util.concurrent.FutureTask.run(FutureTask.java:266)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
      at java.lang.Thread.run(Thread.java:748)
  </code></pre>
  
  <p>This is my <code>pom.xml</code>:</p>
  
  <pre><code>&lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"&gt;
    &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
    &lt;groupId&gt;SmartFabConnector&lt;/groupId&gt;
    &lt;artifactId&gt;SmartFabConnector&lt;/artifactId&gt;
    &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
    &lt;packaging&gt;war&lt;/packaging&gt;
    &lt;name&gt;SmartFabConnector&lt;/name&gt;
    &lt;build&gt;
      &lt;sourceDirectory&gt;src&lt;/sourceDirectory&gt;
      &lt;resources&gt;
        &lt;resource&gt;
          &lt;directory&gt;src&lt;/directory&gt;
          &lt;excludes&gt;
            &lt;exclude&gt;**/*.java&lt;/exclude&gt;
          &lt;/excludes&gt;
        &lt;/resource&gt;
      &lt;/resources&gt;
      &lt;plugins&gt;
        &lt;plugin&gt;
          &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
          &lt;version&gt;3.5.1&lt;/version&gt;
          &lt;configuration&gt;
            &lt;source&gt;1.8&lt;/source&gt;
            &lt;target&gt;1.8&lt;/target&gt;
          &lt;/configuration&gt;
        &lt;/plugin&gt;
        &lt;plugin&gt;
          &lt;artifactId&gt;maven-war-plugin&lt;/artifactId&gt;
          &lt;version&gt;3.0.0&lt;/version&gt;
          &lt;configuration&gt;
            &lt;warSourceDirectory&gt;WebContent&lt;/warSourceDirectory&gt;
          &lt;/configuration&gt;
        &lt;/plugin&gt;
      &lt;/plugins&gt;
    &lt;/build&gt;
    &lt;repositories&gt;
      &lt;repository&gt;
          &lt;id&gt;maven2-repository.java.net&lt;/id&gt;
          &lt;name&gt;Java.net Repository for Maven&lt;/name&gt;
          &lt;url&gt;http://download.java.net/maven/2/&lt;/url&gt;
          &lt;layout&gt;default&lt;/layout&gt;
      &lt;/repository&gt;
    &lt;/repositories&gt;
    &lt;dependencies&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;javax.servlet&lt;/groupId&gt;
          &lt;artifactId&gt;javax.servlet-api&lt;/artifactId&gt;
          &lt;version&gt;3.1.0&lt;/version&gt;
          &lt;scope&gt;provided&lt;/scope&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.glassfish.jersey.containers&lt;/groupId&gt;
          &lt;artifactId&gt;jersey-container-servlet-core&lt;/artifactId&gt;
          &lt;version&gt;2.13&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;!-- https://mvnrepository.com/artifact/org.glassfish.jersey.core/jersey-common --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.glassfish.jersey.core&lt;/groupId&gt;
          &lt;artifactId&gt;jersey-common&lt;/artifactId&gt;
          &lt;version&gt;2.13&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;!-- https://mvnrepository.com/artifact/javax.annotation/javax.annotation-api --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;javax.annotation&lt;/groupId&gt;
          &lt;artifactId&gt;javax.annotation-api&lt;/artifactId&gt;
          &lt;version&gt;1.2&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;!-- https://mvnrepository.com/artifact/org.glassfish.jersey.bundles.repackaged/jersey-guava --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.glassfish.jersey.bundles.repackaged&lt;/groupId&gt;
          &lt;artifactId&gt;jersey-guava&lt;/artifactId&gt;
          &lt;version&gt;2.13&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;!-- https://mvnrepository.com/artifact/org.glassfish.hk2/hk2-api --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.glassfish.hk2&lt;/groupId&gt;
          &lt;artifactId&gt;hk2-api&lt;/artifactId&gt;
          &lt;version&gt;2.3.0-b10&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;!-- https://mvnrepository.com/artifact/org.glassfish.hk2/hk2-utils --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.glassfish.hk2&lt;/groupId&gt;
          &lt;artifactId&gt;hk2-utils&lt;/artifactId&gt;
          &lt;version&gt;2.3.0-b10&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;!-- https://mvnrepository.com/artifact/org.glassfish.hk2.external/javax.inject --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.glassfish.hk2.external&lt;/groupId&gt;
          &lt;artifactId&gt;javax.inject&lt;/artifactId&gt;
          &lt;version&gt;2.3.0-b10&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;!-- https://mvnrepository.com/artifact/org.glassfish.hk2.external/aopalliance-repackaged --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.glassfish.hk2.external&lt;/groupId&gt;
          &lt;artifactId&gt;aopalliance-repackaged&lt;/artifactId&gt;
          &lt;version&gt;2.3.0-b10&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;!-- https://mvnrepository.com/artifact/org.glassfish.hk2/hk2-locator --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.glassfish.hk2&lt;/groupId&gt;
          &lt;artifactId&gt;hk2-locator&lt;/artifactId&gt;
          &lt;version&gt;2.3.0-b10&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;!-- https://mvnrepository.com/artifact/org.javassist/javassist --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.javassist&lt;/groupId&gt;
          &lt;artifactId&gt;javassist&lt;/artifactId&gt;
          &lt;version&gt;3.18.1-GA&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;!-- https://mvnrepository.com/artifact/org.glassfish.hk2/osgi-resource-locator --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.glassfish.hk2&lt;/groupId&gt;
          &lt;artifactId&gt;osgi-resource-locator&lt;/artifactId&gt;
          &lt;version&gt;1.0.1&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;!-- https://mvnrepository.com/artifact/org.glassfish.jersey.core/jersey-server --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.glassfish.jersey.core&lt;/groupId&gt;
          &lt;artifactId&gt;jersey-server&lt;/artifactId&gt;
          &lt;version&gt;2.13&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;!-- https://mvnrepository.com/artifact/org.glassfish.jersey.core/jersey-client --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.glassfish.jersey.core&lt;/groupId&gt;
          &lt;artifactId&gt;jersey-client&lt;/artifactId&gt;
          &lt;version&gt;2.13&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;!-- https://mvnrepository.com/artifact/javax.validation/validation-api --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;javax.validation&lt;/groupId&gt;
          &lt;artifactId&gt;validation-api&lt;/artifactId&gt;
          &lt;version&gt;1.1.0.Final&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;!-- https://mvnrepository.com/artifact/javax.ws.rs/javax.ws.rs-api --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;javax.ws.rs&lt;/groupId&gt;
          &lt;artifactId&gt;javax.ws.rs-api&lt;/artifactId&gt;
          &lt;version&gt;2.0.1&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;!-- https://mvnrepository.com/artifact/org.glassfish.jersey.containers/jersey-container-servlet --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.glassfish.jersey.containers&lt;/groupId&gt;
          &lt;artifactId&gt;jersey-container-servlet&lt;/artifactId&gt;
          &lt;version&gt;2.13&lt;/version&gt;
      &lt;/dependency&gt;
    &lt;/dependencies&gt;
  &lt;/project&gt;
  </code></pre>
  
  <p>This is my <code>web.xml</code>:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0"&gt;
    &lt;display-name&gt;SmartFabConnector&lt;/display-name&gt;
    &lt;servlet&gt;
      &lt;servlet-name&gt;MyApplication&lt;/servlet-name&gt;
      &lt;servlet-class&gt;org.glassfish.jersey.servlet.ServletContainer&lt;/servlet-class&gt;
      &lt;init-param&gt;
          &lt;param-name&gt;javax.ws.rs.Application&lt;/param-name&gt;
          &lt;param-value&gt;com.rold.industry.rest.MyApplication&lt;/param-value&gt;
      &lt;/init-param&gt;
      &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
    &lt;/servlet&gt;
    &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;MyApplication&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/api/*&lt;/url-pattern&gt;
    &lt;/servlet-mapping&gt;
  &lt;/web-app&gt;
  </code></pre>
  
  <p>Then the classes. This is the binder:</p>
  
  <pre><code>package com.rold.industry.rest;
  
  import org.glassfish.hk2.utilities.binding.AbstractBinder;
  
  public class RestAppBinder extends AbstractBinder {
      @Override
      protected void configure() {
          bind(RESTful.class).to(RESTful.class);
      }
  }
  </code></pre>
  
  <p>This is the Resource Config:</p>
  
  <pre><code>package com.rold.industry.rest;
  
  import org.glassfish.jersey.server.ResourceConfig;
  
  public class MyApplication extends ResourceConfig {
      public MyApplication() {
          register(new RestAppBinder());
          packages(true, "com.rold.industry.rest");
      }
  }
  </code></pre>
  
  <p>And this is the class which expose the methods:</p>
  
  <pre><code>@Path("RESTfulService")
  public class RESTful {
  
      @GET
      @Path("/Dipendente/{id}")
      @Produces(MediaType.APPLICATION_JSON)
      public String getEmployeeName(@PathParam("id") String id){
          String accessToken = "";
          try {
              accessToken = ApiCaller.getAccessToken();
          } catch (UnirestException e) {
              System.out.println("Errore");
          }
          Unirest.setDefaultHeader("Authorization", "Bearer " + accessToken);
          Employee employee = EmployeeApi.getInstance().getEmployeeById(new Integer(id));
          return employee.getName();
      }
  }
  </code></pre>
  
  <p>Does anybody have clues on what I am doing wrong?
  Thanks in advance,
  Francesco</p>