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 with asset-pipeline:5.0.4 #367

Open
jamesfredley opened this issue Dec 17, 2024 · 2 comments

Comments

@jamesfredley
Copy link

jamesfredley commented Dec 17, 2024

Grails Issue: grails/grails-core#13913

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"
}

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"

the error:

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 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.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:63)
	at java.base/java.lang.Thread.run(Thread.java:840)

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

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

static processors = [JsProcessor,JsNodeInjectProcessor,BabelJsProcessor,JsRequireProcessor]

static processors = [JsxProcessor, JsProcessor, BabelJsProcessor, JsRequireProcessor]

static processors = [JsProcessor, JsNodeInjectProcessor,BabelJsProcessor, JsRequireProcessor]

static processors = [JsProcessor, TypeScriptProcessor,JsNodeInjectProcessor,BabelJsProcessor,JsRequireProcessor]

static processors = [JsxProcessor,JsProcessor, TypeScriptProcessor,BabelJsProcessor, JsRequireProcessor]

@jamesfredley
Copy link
Author

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.

@jamesfredley
Copy link
Author

Changes for grails 7.0.0-SNAPSHOT grails/grails-core#13971

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

No branches or pull requests

1 participant