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

java.lang.ClassNotFoundException: org.graalvm.polyglot.Context #13913

Open
jamesfredley opened this issue Dec 9, 2024 · 3 comments
Open

java.lang.ClassNotFoundException: org.graalvm.polyglot.Context #13913

jamesfredley opened this issue Dec 9, 2024 · 3 comments

Comments

@jamesfredley
Copy link
Contributor

jamesfredley commented Dec 9, 2024

Issue description

Occurs on Grails 6.2.2+ and Grails 7.0.x

Grails 6.2.2 uses asset-pipeline-gradle:4.5.1
Grails 7.0.x uses asset-pipeline-gradle:5.0.4+

Discussion and PR: bertramdev/asset-pipeline#352

Workaround:

This will end up being a somewhat frequent occurrence for those upgrading to Grails 7, that had been loading asset-pipeline-gradle in buildSrc or buildscript{} vs the new way in plugins{} by id/version only.

remove com.bertramlabs.plugins:asset-pipeline-gradle from buildSrc/build.gradle or buildscript{} in build.gradle:

implementation "com.bertramlabs.plugins:asset-pipeline-gradle:5.0.4"
classpath "com.bertramlabs.plugins:asset-pipeline-gradle:5.0.4"

also remove it from settings.gradle, if present

then define in build.gradle only with id and version:

plugins {
     id "com.bertramlabs.asset-pipeline" version "5.0.4"
}
Grails application running at http://localhost:8080 in environment: development
2024-10-11T09:19:27.912-04:00 ERROR 7768 --- [io-8080-exec-10] .C.[.[.[.[dispatcherServletRegistration] : Servlet.service() for servlet [dispatcherServletRegistration] in context with path [] threw exception [Filter execution threw an exception] with root cause

java.lang.ClassNotFoundException: org.graalvm.polyglot.Context
	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
	at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:525)
	at java.base/java.lang.Class.getDeclaredMethods0(Native Method)
	at java.base/java.lang.Class.privateGetDeclaredMethods(Class.java:3402)
	at java.base/java.lang.Class.privateGetPublicMethods(Class.java:3427)
	at java.base/java.lang.Class.getMethods(Class.java:2019)
	at java.desktop/com.sun.beans.introspect.MethodInfo.get(MethodInfo.java:70)
	at java.desktop/com.sun.beans.introspect.ClassInfo.getMethods(ClassInfo.java:80)
	at java.desktop/java.beans.Introspector.getTargetMethodInfo(Introspector.java:1029)
	at java.desktop/java.beans.Introspector.getBeanInfo(Introspector.java:446)
	at java.desktop/java.beans.Introspector.getBeanInfo(Introspector.java:195)
	at groovy.lang.MetaClassImpl.lambda$addProperties$25(MetaClassImpl.java:3466)
	at java.base/java.security.AccessController.doPrivileged(AccessController.java:569)
	at groovy.lang.MetaClassImpl.doPrivileged(MetaClassImpl.java:3519)
	at groovy.lang.MetaClassImpl.addProperties(MetaClassImpl.java:3466)
	at groovy.lang.MetaClassImpl.reinitialize(MetaClassImpl.java:3448)
	at groovy.lang.MetaClassImpl.initialize(MetaClassImpl.java:3441)
	at org.codehaus.groovy.reflection.ClassInfo.getMetaClassUnderLock(ClassInfo.java:272)
	at org.codehaus.groovy.reflection.ClassInfo.getMetaClass(ClassInfo.java:314)
	at org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl.getMetaClass(MetaClassRegistryImpl.java:269)
	at org.codehaus.groovy.runtime.InvokerHelper.getMetaClass(InvokerHelper.java:596)
	at org.codehaus.groovy.runtime.callsite.CallSiteArray.createCallStaticSite(CallSiteArray.java:69)
	at org.codehaus.groovy.runtime.callsite.CallSiteArray.createCallSite(CallSiteArray.java:159)
	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
	at org.codehaus.groovy.runtime.callsite.StaticMetaMethodSite.call(StaticMetaMethodSite.java:95)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:139)
	at asset.pipeline.AbstractAssetFile.processedStream(AbstractAssetFile.groovy:180)
	at asset.pipeline.AbstractAssetFile.processedStream(AbstractAssetFile.groovy)
	at asset.pipeline.DirectiveProcessor.fileContents(DirectiveProcessor.groovy:320)
	at asset.pipeline.DirectiveProcessor$fileContents$2.call(Unknown Source)
	at asset.pipeline.AssetPipeline.serveUncompiledAsset(AssetPipeline.groovy:67)
	at asset.pipeline.AssetPipelineFilter.doFilterInternal(AssetPipelineFilter.groovy:288)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:164)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:140)
	at org.springframework.web.filter.ServerHttpObservationFilter.doFilterInternal(ServerHttpObservationFilter.java:113)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:164)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:140)
	at org.springframework.web.filter.CorsFilter.doFilterInternal(CorsFilter.java:91)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:164)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:140)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:167)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:90)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:483)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:115)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:93)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:344)
	at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:384)
	at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:63)
	at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:905)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1741)
	at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:52)
	at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1190)
	at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:63)
	at java.base/java.lang.Thread.run(Thread.java:840)
@jamesfredley
Copy link
Contributor Author

jamesfredley commented Dec 10, 2024

It is this line that errors during runtime:
https://github.com/bertramdev/asset-pipeline/blob/5a7b347295a7d6901d1772763b467404[…]ne-core/src/main/groovy/asset/pipeline/AbstractAssetFile.groovy

and loading the plugin with implementation or classpath seems to be adding https://github.com/bertramdev/asset-pipeline/blob/5a7b347295a7d6901d1772763b467404af9ba955/asset-pipeline-core/src/main/groovy/asset/pipeline/processors/BabelJsProcessor.groovy#L30 to the list of processors. BabelJsProcessor.groovy is the only class using org.graalvm.polyglot.Context

https://github.com/search?q=repo%3Abertramdev%2Fasset-pipeline+%22processors+%3D%22&type=code - code setting the list of processors and one of these that is adding BabelJsProcessor is likely the root cause

@jdaugherty jdaugherty added the relates-to: v6 Grails 6 label Dec 11, 2024
@jdaugherty
Copy link
Contributor

This issue is also in the latest 6.2.2 release for the Asset Pipeline upgrade from 4.3.0 to 4.5.1

@jamesfredley
Copy link
Contributor Author

jamesfredley commented Dec 12, 2024

This is also occurring in projects that do not include asset-pipeline-gradle in buildSrc/build.gradle or buildscript{} and just the following in build.gradle:

runtimeOnly "com.bertramlabs.plugins:asset-pipeline-grails"

running ./gradlew build on https://github.com/grails/gorm-mongodb/tree/more-grails-7-updates is a good current example. The tests do pass, but the exceptions are logged.

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

2 participants