-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
graal support? #637
Comments
We'd welcome a pull request for this, but it's low priority for the core JJWT team until 1.0 is released. |
This issue has been automatically marked as stale due to inactivity for 60 or more days. It will be closed in 7 days if no further activity occurs. |
Only adding DefaultJwtBuilder will not be sufficient if you want to parse a JWT. I've got jjwt working in a Graal native image build now. Parsing a JWT can be done like this:
You'll also need some config files to get compression to work - which unfortunately you currently can't get rid of as it's always getting statically initialized even when not needed. META-INF/native-image/someprojectname/resource-config.json
META-INF/native-image/someprojectname/reflect-config.json
These files could also be bundled with the jjwt artifact and then it would work more out of the box. Alternatively, it would be great if jjwt would use less dynamic classloading logic. |
Thanks for the update @MarkusKramer . Is it possible to declare DefaultJwtParserBuilder and DefaultJwtBuilder in Nothing in the |
Yes, you can use
Just tested with Graal. And similar for the builder and other classes. When including theses configs in jjwt-impl it should work out of the box. |
A We have discussed at times moving the A |
This issue has been automatically marked as stale due to inactivity for 60 or more days. It will be closed in 7 days if no further activity occurs. |
Looks like significant work to support something like this will have to wait until after 1.0 - highest priority is to get JWE released. |
(at least unless someone submits a PR that can facilitate this for the current module structure) |
|
@linghengqian thanks for the comment and insight! I think we could leave this open just to ensure we can track it until after the 1.0 release. JJWT's There will be final API changes after the I do agree that, if someone wants this now, adding a PR to the https://github.com/oracle/graalvm-reachability-metadata repository would be the way to go, and then issue another PR after the JJWT 1.0 release. |
|
|
This comment was marked as outdated.
This comment was marked as outdated.
Hey! Worked fine with 0.11.5 but to be broken/unsupported since 0.12.x again.
@linghengqian any chance you would want to make this happen again? 🙏 |
|
Hello. I'm facing this issue with JJWT 0.12.6. This is my first time working with GraalVM and reachability-metadata. Could someone point me in the right direction, on how to modify my project in order to make it work? Thanks in advance. |
I've found a way of make it work: You can add the classes you need into your create a file named import org.springframework.aot.hint.annotation.RegisterReflectionForBinding;
import org.springframework.context.annotation.Configuration;
@Configuration
@RegisterReflectionForBinding({
io.jsonwebtoken.Claims.class,
io.jsonwebtoken.Jwts.class,
io.jsonwebtoken.Jwts.SIG.class,
io.jsonwebtoken.impl.security.StandardSecureDigestAlgorithms.class,
io.jsonwebtoken.impl.security.StandardKeyOperations.class,
/* ... more classes... */
})
public class CloudNativeConfig {} This worked for me with |
@RMCampos confirming, works well on |
I use jjwt generate token for my micronaut app,I use graalvm build native-image, when generate token, I get this error:
io.jsonwebtoken.lang.UnknownClassException: Unable to load class named [io.jsonwebtoken.impl.DefaultJwtBuilder] from the thread context, current, or system/application ClassLoaders. All heuristics have been exhausted. Class could not be found. Have you remembered to include the jjwt-impl.jar in your runtime classpath?
I already setting jjwt-impl.jar in build.gradle, but because of native-image has limitation with reflection, so dynamic class loading can not work, I follow the graal manual add reflection-config.json in META-INF and its working!
[ { "name" : "io.jsonwebtoken.impl.DefaultJwtBuilder", "allDeclaredFields" : true, "allPublicMethods" : true, "allDeclaredConstructors" : true } ]
so can we just put the graal config in jjwt-impl.jar to support graal native-image?
The text was updated successfully, but these errors were encountered: