title: java.lang.NoClassDefFoundError: io/jsonwebtoken/SignatureAlgorithm
body: <p>i have the following code that tries to create a jwt token. there will always be an error as shown below whenever it tries to execute SignatureAlgorithm signatureAlgorithm = SignatureAlgorithm.HS256; </p>
  
  <p>I have manually deleted the jwt jar file and update maven again to reinstall the jar but the issue still persist. </p>
  
  <p>Any help will be greatly appreciated!</p>
  
  <pre><code>//Sample method to construct a JWT
  public static String createJWT(String id, String issuer, String subject, 
          String payload, String role, String name, long ttlMillis) {
      String jwt = "";
  
      try {
          //The JWT signature algorithm we will be using to sign the token
          SignatureAlgorithm signatureAlgorithm = SignatureAlgorithm.HS256;
  
          long nowMillis = System.currentTimeMillis();
          Date now = new Date(nowMillis);
  
          //We will sign our JWT with our ApiKey secret
          byte[] apiKeySecretBytes = DatatypeConverter.parseBase64Binary(apiKey.getSecret());
          Key signingKey = new SecretKeySpec(apiKeySecretBytes, signatureAlgorithm.getJcaName());
  
          //Let's set the JWT Claims
          JwtBuilder builder = Jwts.builder()
                                      .setIssuedAt(now)
                                      .setSubject("test")
                                      .claim("role", role)
                                      .claim("name", name)
                                      .setIssuer("tester")
                                      .signWith(io.jsonwebtoken.SignatureAlgorithm.HS256, signingKey);
                                      //.signWith(signatureAlgorithm, apiKey.getSecret().getBytes("UTF-8"));
                                      //
  
          //if it has been specified, let's add the expiration
          if (ttlMillis &gt;= 0) {
          long expMillis = nowMillis + ttlMillis;
              Date exp = new Date(expMillis);
              builder.setExpiration(exp);
          }
  
          //Builds the JWT and serializes it to a compact, URL-safe string
          jwt = builder.compact();
  
      } catch (Exception ex) {
  
      }
      return jwt;
  }
  </code></pre>
  
  <p><strong>Error Log</strong></p>
  
  <p>java.lang.NoClassDefFoundError: io/jsonwebtoken/SignatureAlgorithm
      at com.test.service.JWTToken.createJWT(JWTToken.java:21)
      at com.test.controller.AccountController.authenticateUser(AccountController.java:82)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:498)
      at org.glassfish.jersey.server.internal.routing.SubResourceLocatorRouter$1.run(SubResourceLocatorRouter.java:158)
      at org.glassfish.jersey.server.internal.routing.SubResourceLocatorRouter.getResource(SubResourceLocatorRouter.java:178)
      at org.glassfish.jersey.server.internal.routing.SubResourceLocatorRouter.apply(SubResourceLocatorRouter.java:109)
      at org.glassfish.jersey.server.internal.routing.RoutingStage._apply(RoutingStage.java:109)
      at org.glassfish.jersey.server.internal.routing.RoutingStage._apply(RoutingStage.java:112)
      at org.glassfish.jersey.server.internal.routing.RoutingStage._apply(RoutingStage.java:112)
      at org.glassfish.jersey.server.internal.routing.RoutingStage._apply(RoutingStage.java:112)
      at org.glassfish.jersey.server.internal.routing.RoutingStage._apply(RoutingStage.java:112)
      at org.glassfish.jersey.server.internal.routing.RoutingStage.apply(RoutingStage.java:92)
      at org.glassfish.jersey.server.internal.routing.RoutingStage.apply(RoutingStage.java:61)
      at org.glassfish.jersey.process.internal.Stages.process(Stages.java:197)
      at org.glassfish.jersey.server.ServerRuntime$2.run(ServerRuntime.java:301)
      at org.glassfish.jersey.internal.Errors$1.call(Errors.java:271)
      at org.glassfish.jersey.internal.Errors$1.call(Errors.java:267)
      at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
      at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
      at org.glassfish.jersey.internal.Errors.process(Errors.java:267)
      at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:317)
      at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:292)
      at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:1139)
      at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:460)
      at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:386)
      at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:334)
      at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:221)
      at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1682)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:318)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160)
      at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:734)
      at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:673)
      at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:174)
      at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:416)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:283)
      at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:459)
      at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:167)
      at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:206)
      at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:180)
      at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:235)
      at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
      at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:283)
      at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:200)
      at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:132)
      at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:111)
      at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
      at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:536)
      at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:112)
      at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:117)
      at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:56)
      at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:137)
      at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:591)
      at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:571)
      at java.lang.Thread.run(Thread.java:745)</p>
  
  <p><strong>POM Dependencies</strong></p>
  
  <pre><code>&lt;dependencies&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;com.fasterxml.jackson.core&lt;/groupId&gt;
              &lt;artifactId&gt;jackson-databind&lt;/artifactId&gt;
              &lt;version&gt;2.8.8&lt;/version&gt;
          &lt;/dependency&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.25.1&lt;/version&gt;
          &lt;/dependency&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.25&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.json&lt;/groupId&gt;
              &lt;artifactId&gt;json&lt;/artifactId&gt;
              &lt;version&gt;20160810&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;commons-beanutils&lt;/groupId&gt;
              &lt;artifactId&gt;commons-beanutils&lt;/artifactId&gt;
              &lt;version&gt;1.9.3&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;com.fasterxml.jackson.jaxrs&lt;/groupId&gt;
              &lt;artifactId&gt;jackson-jaxrs-json-provider&lt;/artifactId&gt;
              &lt;version&gt;2.8.6&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;com.fasterxml.jackson.core&lt;/groupId&gt;
              &lt;artifactId&gt;jackson-annotations&lt;/artifactId&gt;
              &lt;version&gt;2.8.9&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.glassfish.jersey.media&lt;/groupId&gt;
              &lt;artifactId&gt;jersey-media-json-jackson&lt;/artifactId&gt;
              &lt;version&gt;2.25.1&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.eclipse.persistence&lt;/groupId&gt;
              &lt;artifactId&gt;org.eclipse.persistence.moxy&lt;/artifactId&gt;
              &lt;version&gt;2.6.4&lt;/version&gt;
          &lt;/dependency&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.22.1&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;io.jsonwebtoken&lt;/groupId&gt;
              &lt;artifactId&gt;jjwt&lt;/artifactId&gt;
              &lt;version&gt;0.7.0&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;mysql&lt;/groupId&gt;
              &lt;artifactId&gt;mysql-connector-java&lt;/artifactId&gt;
              &lt;version&gt;5.1.42&lt;/version&gt;
          &lt;/dependency&gt;
  
      &lt;/dependencies&gt;
  </code></pre>