Skip to content
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

Micronaut Okta integration with GraalVM Native Image error #257

Open
amitpal-source opened this issue Jul 30, 2021 · 2 comments
Open

Micronaut Okta integration with GraalVM Native Image error #257

amitpal-source opened this issue Jul 30, 2021 · 2 comments

Comments

@amitpal-source
Copy link

amitpal-source commented Jul 30, 2021

Issue description

I am running the Micronaut Okta integration
https://guides.micronaut.io/latest/micronaut-oauth2-okta-gradle-java.html

Current OS Mac Catalina
GraalVM 20.3 and 21.2 EE
Micronaut 2.5.11

a) i cannot get the logout uri to work although the uri is the same in the app.yml and the okta settings,
endpoints:
logout:
path: '/oauth/logout' # should match Okta's Logout redirect URI in App settings
error Identity Provider:
Error Code: invalid_request
Description: The 'post_logout_redirect_uri' parameter must be a Logout redirect URI in the client app settings: https://dev-81797895-admin.okta.com/admin/app/oidc_client/instance/0oa1cvvtvsjhYqjM95d7#tab-general
this is now fixed i removed path and just kept it as
endpoints:
logout:
get-allowed: true
and it okta app settings as the following 'http://localhost:8080/logout'

b) with native image I get the following error

Amitpals-MacBook-Pro-2:oktademo adhillon$ ./gradlew nativeImage Task :compileJava Note: Writing resource-config.json file to destination: META-INF/native-image/com.example/oktademo/resource-config.json
Note: Creating bean classes for 1 type elements
Task :nativeImage
[application:10157] classlist: 5,643.23 ms, 0.94 GB
[application:10157] (cap): 16,035.07 ms, 0.94 GB
[application:10157] setup: 18,697.41 ms, 0.94 GB
[application:10157] (clinit): 1,650.58 ms, 5.11 GB
[application:10157] (typeflow): 70,429.73 ms, 5.11 GB
[application:10157] (objects): 55,852.46 ms, 5.11 GB
[application:10157] (features): 5,306.78 ms, 5.11 GB
[application:10157] analysis: 138,257.03 ms, 5.11 GB`

Error: com.oracle.svm.hosted.substitute.DeletedElementException: Unsupported method java.lang.ClassLoader.defineClass(String, byte[], int, int, ProtectionDomain) is reachable
To diagnose the issue, you can add the option --report-unsupported-elements-at-runtime. The unsupported element is then reported at run time when it is accessed the first time.
Detailed message:
Trace:
at parsing ognl.security.OgnlSecurityManagerFactory.(OgnlSecurityManagerFactory.java:52)
Call path from entry point to ognl.security.OgnlSecurityManagerFactory.():
at ognl.security.OgnlSecurityManagerFactory.(OgnlSecurityManagerFactory.java:44)
at ognl.security.OgnlSecurityManagerFactory.getOgnlSecurityManager(OgnlSecurityManagerFactory.java:30)
at ognl.OgnlRuntime.invokeMethodInsideSandbox(OgnlRuntime.java:1243)
at ognl.OgnlRuntime.invokeMethod(OgnlRuntime.java:1211)
at ognl.OgnlRuntime.callAppropriateMethod(OgnlRuntime.java:1920)
at ognl.ObjectMethodAccessor.callStaticMethod(ObjectMethodAccessor.java:52)
at ognl.OgnlRuntime.callStaticMethod(OgnlRuntime.java:1945)
at ognl.ASTStaticMethod.getValueBody(ASTStaticMethod.java:77)
at ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:212)
at ognl.SimpleNode.getValue(SimpleNode.java:236)
at ognl.Ognl.getValue(Ognl.java:537)
at ognl.Ognl.getValue(Ognl.java:501)
at org.thymeleaf.standard.expression.OGNLVariableExpressionEvaluator.executeExpression(OGNLVariableExpressionEvaluator.java:328)
at org.thymeleaf.standard.expression.OGNLVariableExpressionEvaluator.evaluate(OGNLVariableExpressionEvaluator.java:170)
at org.thymeleaf.standard.expression.OGNLVariableExpressionEvaluator.evaluate(OGNLVariableExpressionEvaluator.java:95)
at org.thymeleaf.standard.expression.VariableExpression.executeVariableExpression(VariableExpression.java:166)
at org.thymeleaf.standard.expression.SimpleExpression.executeSimple(SimpleExpression.java:66)
at org.thymeleaf.standard.expression.Expression.execute(Expression.java:109)
at org.thymeleaf.standard.expression.Expression.execute(Expression.java:138)
at org.thymeleaf.standard.processor.StandardDefaultAttributesTagProcessor.processDefaultAttribute(StandardDefaultAttributesTagProcessor.java:165)
at org.thymeleaf.standard.processor.StandardDefaultAttributesTagProcessor.process(StandardDefaultAttributesTagProcessor.java:98)
at org.thymeleaf.engine.ProcessorTemplateHandler.handleOpenElement(ProcessorTemplateHandler.java:1314)
at org.thymeleaf.engine.OpenElementTag.beHandled(OpenElementTag.java:205)
at org.thymeleaf.engine.TemplateModel.process(TemplateModel.java:136)
at org.thymeleaf.engine.TemplateManager.process(TemplateManager.java:519)
at org.thymeleaf.util.LazyProcessingCharSequence.resolveText(LazyProcessingCharSequence.java:78)
at org.thymeleaf.util.AbstractLazyCharSequence.getText(AbstractLazyCharSequence.java:68)
at org.thymeleaf.util.AbstractLazyCharSequence.hashCode(AbstractLazyCharSequence.java:132)
at java.util.HashMap.hash(HashMap.java:339)
at java.util.HashMap.get(HashMap.java:552)
at com.oracle.svm.core.jdk.Target_java_nio_charset_Charset.lookup(CharsetSubstitutions.java:74)
at java.nio.charset.Charset.isSupported(Charset.java:503)
at com.oracle.svm.jni.JNIJavaCallWrappers.jniInvoke_VARARGS:Ljava_nio_charset_Charset_2_0002eisSupported_00028Ljava_lang_String_2_00029Z(generated:0)
found this oracle/graal#3123
so I got pass this and the native image built successfully by adding this to the build.gradle
nativeImage {
args('--verbose')
args('--report-unsupported-elements-at-runtime')
imageName('mn-graalvm-application')
}

c) but when I run the native image it starts but and serves the starting page and redirects via oauth to okta but does not complete authentication I get this error in the logs

21:29:23.241 [main] INFO io.micronaut.runtime.Micronaut - Startup completed in 57ms. Server Running: http://localhost:8080
21:29:41.603 [io-executor-thread-1] ERROR org.thymeleaf.TemplateEngine - [THYMELEAF][io-executor-thread-1] Exception processing template "home": Exception evaluating OGNL expression: "security.attributes.get('email')" (template: "home" - line 9, col 41)
org.thymeleaf.exceptions.TemplateProcessingException: Exception evaluating OGNL expression: "security.attributes.get('email')" (template: "home" - line 9, col 41)
at org.thymeleaf.standard.expression.OGNLVariableExpressionEvaluator.evaluate(OGNLVariableExpressionEvaluator.java:191)
at org.thymeleaf.standard.expression.OGNLVariableExpressionEvaluator.evaluate(OGNLVariableExpressionEvaluator.java:95)
at org.thymeleaf.standard.expression.VariableExpression.executeVariableExpression(VariableExpression.java:166)
at org.thymeleaf.standard.expression.SimpleExpression.executeSimple(SimpleExpression.java:66)
at org.thymeleaf.standard.expression.Expression.execute(Expression.java:109)
at org.thymeleaf.standard.expression.Expression.execute(Expression.java:138)
at org.thymeleaf.standard.processor.AbstractStandardExpressionAttributeTagProcessor.doProcess(AbstractStandardExpressionAttributeTagProcessor.java:144)
at org.thymeleaf.processor.element.AbstractAttributeTagProcessor.doProcess(AbstractAttributeTagProcessor.java:74)
at org.thymeleaf.processor.element.AbstractElementTagProcessor.process(AbstractElementTagProcessor.java:95)
at org.thymeleaf.util.ProcessorConfigurationUtils$ElementTagProcessorWrapper.process(ProcessorConfigurationUtils.java:633)
at org.thymeleaf.engine.ProcessorTemplateHandler.handleOpenElement(ProcessorTemplateHandler.java:1314)
at org.thymeleaf.engine.OpenElementTag.beHandled(OpenElementTag.java:205)
at org.thymeleaf.engine.TemplateModel.process(TemplateModel.java:136)
at org.thymeleaf.engine.TemplateManager.parseAndProcess(TemplateManager.java:592)
at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1098)
at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1067)
at io.micronaut.views.thymeleaf.ThymeleafViewsRenderer.render(ThymeleafViewsRenderer.java:109)
at io.micronaut.views.thymeleaf.ThymeleafViewsRenderer.lambda$render$1(ThymeleafViewsRenderer.java:96)
at io.micronaut.core.io.Writable.writeTo(Writable.java:77)
at io.micronaut.http.server.netty.RoutingInBoundHandler.lambda$encodeHttpResponse$7(RoutingInBoundHandler.java:1683)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.lang.Thread.run(Thread.java:834)
at com.oracle.svm.core.thread.JavaThreads.threadStartRoutine(JavaThreads.java:519)
at com.oracle.svm.core.posix.thread.PosixJavaThreads.pthreadStartRoutine(PosixJavaThreads.java:192)
Caused by: ognl.MethodFailedException: Method "get" failed for object {at_hash=ip1VStA189R1oNKL-yyXEA, sub=00u1cw8fb1ikFrlqL5d7, ver=1, amr=["pwd"], iss=https://dev-81797895.okta.com/oauth2/default, preferred_username=[email protected], nonce=67439e6e-ec8a-4342-a78c-0a17699acef7, aud=[0oa1cvvtvsjhYqjM95d7], idp=00o1cu312lN5yk3Qa5d7, auth_time=1627561658, name=Amit S, exp=Thu Jul 29 22:29:39 SGT 2021, iat=Thu Jul 29 21:29:39 SGT 2021, email=[email protected], jti=ID.8on_K83j5EmMGW6wOpHWQIxuK7cUd7i0cTcwfH5SliE}

@ilopmar
Copy link
Contributor

ilopmar commented Jul 30, 2021

Just in case, can you please try with GraalVM 21.1.0 or, even better, with 21.2.0? I think some issues like the one you mentioned were fixed in those versions.

@amitpal-source
Copy link
Author

amitpal-source commented Jul 30, 2021

Thanks I tried in 21.2 and here is the error

-H:Class=com.example.Application
-H:Name=mn-graalvm-application
-H:FallbackThreshold=0
-H:CLibraryPath=/Users/adhillon/Documents/graalvm-ee-java11-21.2.0/Contents/Home/lib/svm/clibraries/darwin-amd64
[mn-graalvm-application:4155] classlist: 8,794.64 ms, 1.19 GB
[mn-graalvm-application:4155] (cap): 3,700.75 ms, 1.19 GB
[mn-graalvm-application:4155] setup: 11,972.04 ms, 1.19 GB
[mn-graalvm-application:4155] (clinit): 10,987.78 ms, 5.98 GB
[mn-graalvm-application:4155] (typeflow): 199,245.39 ms, 5.98 GB
[mn-graalvm-application:4155] (objects): 235,614.96 ms, 5.98 GB
[mn-graalvm-application:4155] (features): 23,888.73 ms, 5.98 GB
[mn-graalvm-application:4155] analysis: 500,888.65 ms, 5.98 GB
[mn-graalvm-application:4155] universe: 27,540.74 ms, 5.98 GB
[mn-graalvm-application:4155] (parse): 48,911.83 ms, 5.88 GB
[mn-graalvm-application:4155] (inline): 25,753.79 ms, 6.18 GB
[mn-graalvm-application:4155] (compile): 459,644.96 ms, 6.48 GB
[mn-graalvm-application:4155] compile: 542,412.94 ms, 6.48 GB
[mn-graalvm-application:4155] image: 12,942.27 ms, 6.49 GB
[mn-graalvm-application:4155] write: 2,926.83 ms, 6.49 GB
[mn-graalvm-application:4155] [total]: 1,108,045.78 ms, 6.49 GB
Native Image written to: /Users/adhillon/secdemos/oktademo/build/native-image/mn-graalvm-application

BUILD SUCCESSFUL in 18m 40s
3 actionable tasks: 3 executed
Amitpals-MacBook-Pro-2:oktademo adhillon$ ./build/native-image/mn
bash: ./build/native-image/mn: No such file or directory

Amitpals-MacBook-Pro-2:oktademo adhillon$ ./build/native-image/mn-graalvm-application


| / () ___ _ __ ___ _ __ __ _ _ | |
| |/| | |/ | '/ _ | '
\ / ` | | | | |
| | | | | (
| | | (
) | | | | (| | || | |_
|| |||___|| ___/|| ||_,|_,|__|
Micronaut (v2.5.11)

17:16:23.869 [main] INFO io.micronaut.runtime.Micronaut - Startup completed in 44ms. Server Running: http://localhost:8080
`

17:16:53.054 [io-executor-thread-1] ERROR org.thymeleaf.TemplateEngine - [THYMELEAF][io-executor-thread-1] Exception processing template "home": Exception evaluating OGNL expression: "security.attributes.get('email')" (template: "home" - line 9, col 41)
org.thymeleaf.exceptions.TemplateProcessingException: Exception evaluating OGNL expression: "security.attributes.get('email')" (template: "home" - line 9, col 41)
at org.thymeleaf.standard.expression.OGNLVariableExpressionEvaluator.evaluate(OGNLVariableExpressionEvaluator.java:191)
at org.thymeleaf.standard.expression.OGNLVariableExpressionEvaluator.evaluate(OGNLVariableExpressionEvaluator.java:95)
at org.thymeleaf.standard.expression.VariableExpression.executeVariableExpression(VariableExpression.java:166)
at org.thymeleaf.standard.expression.SimpleExpression.executeSimple(SimpleExpression.java:66)
at org.thymeleaf.standard.expression.Expression.execute(Expression.java:109)
at org.thymeleaf.standard.expression.Expression.execute(Expression.java:138)
at org.thymeleaf.standard.processor.AbstractStandardExpressionAttributeTagProcessor.doProcess(AbstractStandardExpressionAttributeTagProcessor.java:144)
at org.thymeleaf.processor.element.AbstractAttributeTagProcessor.doProcess(AbstractAttributeTagProcessor.java:74)
at org.thymeleaf.processor.element.AbstractElementTagProcessor.process(AbstractElementTagProcessor.java:95)
at org.thymeleaf.util.ProcessorConfigurationUtils$ElementTagProcessorWrapper.process(ProcessorConfigurationUtils.java:633)
at org.thymeleaf.engine.ProcessorTemplateHandler.handleOpenElement(ProcessorTemplateHandler.java:1314)
at org.thymeleaf.engine.OpenElementTag.beHandled(OpenElementTag.java:205)
at org.thymeleaf.engine.TemplateModel.process(TemplateModel.java:136)
at org.thymeleaf.engine.TemplateManager.parseAndProcess(TemplateManager.java:592)
at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1098)
at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1067)
at io.micronaut.views.thymeleaf.ThymeleafViewsRenderer.render(ThymeleafViewsRenderer.java:109)
at io.micronaut.views.thymeleaf.ThymeleafViewsRenderer.lambda$render$1(ThymeleafViewsRenderer.java:96)
at io.micronaut.core.io.Writable.writeTo(Writable.java:77)
at io.micronaut.http.server.netty.RoutingInBoundHandler.lambda$encodeHttpResponse$7(RoutingInBoundHandler.java:1683)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.lang.Thread.run(Thread.java:834)
at com.oracle.svm.core.thread.JavaThreads.threadStartRoutine(JavaThreads.java:567)
at com.oracle.svm.core.posix.thread.PosixJavaThreads.pthreadStartRoutine(PosixJavaThreads.java:192)
Caused by: ognl.MethodFailedException: Method "get" failed for object {at_hash=JvUJAoCa_V0ZYQt-D9NcKg, sub=00u1cw8fb1ikFrlqL5d7, ver=1, amr=["pwd"], iss=https://dev-81797895.okta.com/oauth2/default, preferred_username=[email protected], nonce=31590e48-79c3-4ebf-bcb3-be7538d2eb1c, aud=[0oa1cvvtvsjhYqjM95d7], idp=00o1cu312lN5yk3Qa5d7, auth_time=1627636609, name=Amit S, exp=Fri Jul 30 18:16:51 SGT 2021, iat=Fri Jul 30 17:16:51 SGT 2021, email=[email protected], jti=ID.gAsbKa8K3K9zI5d-U0tZFaidz6PzjCdTLCLt_hCNvz4}
at ognl.OgnlRuntime.callAppropriateMethod(OgnlRuntime.java:1932)
at ognl.ObjectMethodAccessor.callMethod(ObjectMethodAccessor.java:68)
at ognl.OgnlRuntime.callMethod(OgnlRuntime.java:1996)
at ognl.ASTMethod.getValueBody(ASTMethod.java:91)
at ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:212)
at ognl.SimpleNode.getValue(SimpleNode.java:258)
at ognl.ASTChain.getValueBody(ASTChain.java:141)
at ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:212)
at ognl.SimpleNode.getValue(SimpleNode.java:258)
at ognl.Ognl.getValue(Ognl.java:537)
at ognl.Ognl.getValue(Ognl.java:501)
at org.thymeleaf.standard.expression.OGNLVariableExpressionEvaluator.executeExpression(OGNLVariableExpressionEvaluator.java:328)
at org.thymeleaf.standard.expression.OGNLVariableExpressionEvaluator.evaluate(OGNLVariableExpressionEvaluator.java:170)
... 24 common frames omitted
Caused by: java.lang.NoSuchMethodException: java.util.Collections$UnmodifiableMap.get(java.lang.String)
at ognl.OgnlRuntime.callAppropriateMethod(OgnlRuntime.java:1873)
... 36 common frames omitted
Exception in thread "io-executor-thread-1" io.micronaut.views.exceptions.ViewRenderingException: Error rendering Thymeleaf view [home]: Exception evaluating OGNL expression: "security.attributes.get('email')" (template: "home" - line 9, col 41)
at io.micronaut.views.thymeleaf.ThymeleafViewsRenderer.render(ThymeleafViewsRenderer.java:111)
at io.micronaut.views.thymeleaf.ThymeleafViewsRenderer.lambda$render$1(ThymeleafViewsRenderer.java:96)
at io.micronaut.core.io.Writable.writeTo(Writable.java:77)
at io.micronaut.http.server.netty.RoutingInBoundHandler.lambda$encodeHttpResponse$7(RoutingInBoundHandler.java:1683)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.lang.Thread.run(Thread.java:834)
at com.oracle.svm.core.thread.JavaThreads.threadStartRoutine(JavaThreads.java:567)
at com.oracle.svm.core.posix.thread.PosixJavaThreads.pthreadStartRoutine(PosixJavaThreads.java:192)
Caused by: org.thymeleaf.exceptions.TemplateProcessingException: Exception evaluating OGNL expression: "security.attributes.get('email')" (template: "home" - line 9, col 41)
at org.thymeleaf.standard.expression.OGNLVariableExpressionEvaluator.evaluate(OGNLVariableExpressionEvaluator.java:191)
at org.thymeleaf.standard.expression.OGNLVariableExpressionEvaluator.evaluate(OGNLVariableExpressionEvaluator.java:95)
at org.thymeleaf.standard.expression.VariableExpression.executeVariableExpression(VariableExpression.java:166)
at org.thymeleaf.standard.expression.SimpleExpression.executeSimple(SimpleExpression.java:66)
at org.thymeleaf.standard.expression.Expression.execute(Expression.java:109)
at org.thymeleaf.standard.expression.Expression.execute(Expression.java:138)
at org.thymeleaf.standard.processor.AbstractStandardExpressionAttributeTagProcessor.doProcess(AbstractStandardExpressionAttributeTagProcessor.java:144)
at org.thymeleaf.processor.element.AbstractAttributeTagProcessor.doProcess(AbstractAttributeTagProcessor.java:74)
at org.thymeleaf.processor.element.AbstractElementTagProcessor.process(AbstractElementTagProcessor.java:95)
at org.thymeleaf.util.ProcessorConfigurationUtils$ElementTagProcessorWrapper.process(ProcessorConfigurationUtils.java:633)
at org.thymeleaf.engine.ProcessorTemplateHandler.handleOpenElement(ProcessorTemplateHandler.java:1314)
at org.thymeleaf.engine.OpenElementTag.beHandled(OpenElementTag.java:205)
at org.thymeleaf.engine.TemplateModel.process(TemplateModel.java:136)
at org.thymeleaf.engine.TemplateManager.parseAndProcess(TemplateManager.java:592)
at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1098)
at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1067)
at io.micronaut.views.thymeleaf.ThymeleafViewsRenderer.render(ThymeleafViewsRenderer.java:109)
... 8 more
Caused by: ognl.MethodFailedException: Method "get" failed for object {at_hash=JvUJAoCa_V0ZYQt-D9NcKg, sub=00u1cw8fb1ikFrlqL5d7, ver=1, amr=["pwd"], iss=https://dev-81797895.okta.com/oauth2/default, preferred_username=[email protected], nonce=31590e48-79c3-4ebf-bcb3-be7538d2eb1c, aud=[0oa1cvvtvsjhYqjM95d7], idp=00o1cu312lN5yk3Qa5d7, auth_time=1627636609, name=Amit S, exp=Fri Jul 30 18:16:51 SGT 2021, iat=Fri Jul 30 17:16:51 SGT 2021, email=[email protected], jti=ID.gAsbKa8K3K9zI5d-U0tZFaidz6PzjCdTLCLt_hCNvz4} [java.lang.NoSuchMethodException: java.util.Collections$UnmodifiableMap.get(java.lang.String)]
at ognl.OgnlRuntime.callAppropriateMethod(OgnlRuntime.java:1932)
at ognl.ObjectMethodAccessor.callMethod(ObjectMethodAccessor.java:68)
at ognl.OgnlRuntime.callMethod(OgnlRuntime.java:1996)
at ognl.ASTMethod.getValueBody(ASTMethod.java:91)
at ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:212)
at ognl.SimpleNode.getValue(SimpleNode.java:258)
at ognl.ASTChain.getValueBody(ASTChain.java:141)
at ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:212)
at ognl.SimpleNode.getValue(SimpleNode.java:258)
at ognl.Ognl.getValue(Ognl.java:537)
at ognl.Ognl.getValue(Ognl.java:501)
at org.thymeleaf.standard.expression.OGNLVariableExpressionEvaluator.executeExpression(OGNLVariableExpressionEvaluator.java:328)
at org.thymeleaf.standard.expression.OGNLVariableExpressionEvaluator.evaluate(OGNLVariableExpressionEvaluator.java:170)
... 24 more
Caused by: java.lang.NoSuchMethodException: java.util.Collections$UnmodifiableMap.get(java.lang.String)
at ognl.OgnlRuntime.callAppropriateMethod(OgnlRuntime.java:1873)
... 36 more

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants