title: Class cast exception in JWT
body: <p>I am creating a token string using <code>JwtBuilder</code>. But while extracting a value using a key, it is giving <code>ClassCastException</code>. For better understanding code snippet are provided below:</p>
  
  <p><strong>Token creation:</strong></p>
  
  <pre><code>private JwtBuilder getJwtBuilder(
          String jti,
          Long issuedAt,
          Long expiredAt,
          Long businessAccountId,
          Long consumerAccountId,
          String deviceId
  ) {
      JwtBuilder builder = Jwts.builder();
      builder.setIssuer("SO");
      builder.setSubject(TokenConstant.TOKEN_SUBJECT);
      builder.setId(jti);
      builder.setIssuedAt(new Date(issuedAt));
      builder.setExpiration(new Date(expiredAt));
      builder.claim(TokenConstant.BUSINESS_ACCOUNT_ID, businessAccountId);
      builder.claim(TokenConstant.DEVICE_ID, deviceId);
      builder.signWith(SignatureAlgorithm.HS512, secretKey);
      return builder;
  }
  </code></pre>
  
  <p><strong>Decoding token:</strong></p>
  
  <pre><code>private JsonWebToken decodeToken(String jsonWebToken) {
      try {
          Jws&lt;Claims&gt; map = Jwts.parser().setSigningKey(secretKey).parseClaimsJws(jsonWebToken);
          Claims claims = map.getBody();
          return getJsonWebTokenFromClaims(claims);
      } catch (SignatureException | MalformedJwtException e) {
          throw new InvalidTokenException(e.getMessage());
      }
  }
  
  private JsonWebToken getJsonWebTokenFromClaims(Claims claims) {
      JsonWebToken token = new JsonWebToken();
      token.jti = claims.getId();
      token.expirationTime = claims.getExpiration().getTime();
      token.issuedAt = claims.getIssuedAt().getTime();
      token.deviceId = (String) claims.get(TokenConstant.DEVICE_ID);
      token.businessAccountId =  (Long) claims.get(TokenConstant.BUSINESS_ACCOUNT_ID);
      return token;
  }
  </code></pre>
  
  <p><strong>Exception:</strong></p>
  
  <blockquote>
    <p>2018-04-23 10:27:04.476  ERROR b.c.i.s.c.MyExceptionHandler -
    Application error: {} java.lang.ClassCastException: java.lang.Integer
    cannot be cast to java.lang.Long</p>
  </blockquote>
  
  <p><strong>jwt version:</strong></p>
  
  <pre><code>&lt;dependency&gt;
      &lt;groupId&gt;io.jsonwebtoken&lt;/groupId&gt;
      &lt;artifactId&gt;jjwt&lt;/artifactId&gt;
      &lt;version&gt;0.6.0&lt;/version&gt;
  &lt;/dependency&gt;
  </code></pre>
  
  <p>As you can see that my code is getting an error while casting <code>Integer</code> type value to a <code>Long</code> type. I am unable to understand, why <code>Object</code> type is converted to <code>Integer</code> implicitly? </p>