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

Error when loading js dependency from a path with a space #570

Open
contrapost opened this issue Mar 11, 2022 · 8 comments
Open

Error when loading js dependency from a path with a space #570

contrapost opened this issue Mar 11, 2022 · 8 comments
Assignees

Comments

@contrapost
Copy link

contrapost commented Mar 11, 2022

We get following error when path to the jar contains a space in it:

java.lang.AssertionError: Cannot locate js language home due to Illegal character in path at index 18: file:/C:/Users/Clark Nielsen/.m2/repository/org/graalvm/js/js/21.1.0/js-21.1.0.jar
@chumer
Copy link
Member

chumer commented Mar 11, 2022

Sorry we need at least a stack trace or some way to reproduce this issue.
It would also be good if you describe the environment you run in.

@contrapost
Copy link
Author

contrapost commented Mar 13, 2022

@chumer, here is the example project you can run to reproduce the error (see README).
We observe the error when running code in macOS, but expect to get the same result in Windows as well.
Here is the stacktrace:

org.graalvm.polyglot.PolyglotException: java.lang.AssertionError: Cannot locate js language home due to Illegal character in path at index 86: file:/Users/christian/Greenbird/git/github/utilihive/graalvm-space-error-example/maven repo/org/graalvm/js/js/22.0.0.2/js-22.0.0.2.jar
        at com.oracle.truffle.polyglot.LanguageCache.getLanguageHomeFromURLConnection(LanguageCache.java:360)
        at com.oracle.truffle.polyglot.LanguageCache.loadLanguageImpl(LanguageCache.java:305)
        at com.oracle.truffle.polyglot.LanguageCache.createLanguages(LanguageCache.java:234)
        at com.oracle.truffle.polyglot.LanguageCache.loadLanguages(LanguageCache.java:211)
        at com.oracle.truffle.polyglot.LanguageCache.languages(LanguageCache.java:201)
        at com.oracle.truffle.polyglot.PolyglotEngineImpl.initializeLanguages(PolyglotEngineImpl.java:883)
        at com.oracle.truffle.polyglot.PolyglotEngineImpl.<init>(PolyglotEngineImpl.java:252)
        at com.oracle.truffle.polyglot.PolyglotImpl.buildEngine(PolyglotImpl.java:276)
        at org.graalvm.polyglot.Engine$Builder.build(Engine.java:620)
        at org.graalvm.polyglot.Context$Builder.build(Context.java:1822)
        at org.graalvm.polyglot.Context.create(Context.java:971)
        at SimpleScriptTest.GIVEN correct input THEN data returned as expected(SimpleScriptTest.kt:10)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:566)
        at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59)
        at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
        at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56)
        at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
        at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
        at org.junit.runners.BlockJUnit4ClassRunner$1.evaluate(BlockJUnit4ClassRunner.java:100)
        at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366)
        at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:103)
        at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:63)
        at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
        at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
        at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
        at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
        at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
        at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
        at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
        at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:364)
        at org.apache.maven.surefire.junit4.JUnit4Provider.executeWithRerun(JUnit4Provider.java:272)
        at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:237)
        at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:158)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:566)
        at org.apache.maven.surefire.api.util.ReflectionUtils.invokeMethodWithArray2(ReflectionUtils.java:167)
        at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:161)
        at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:84)
        at org.apache.maven.plugin.surefire.InPluginVMSurefireStarter.runSuitesInProcess(InPluginVMSurefireStarter.java:87)
        at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeProvider(AbstractSurefireMojo.java:1295)
        at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeAfterPreconditionsChecked(AbstractSurefireMojo.java:1159)
        at org.apache.maven.plugin.surefire.AbstractSurefireMojo.execute(AbstractSurefireMojo.java:932)
        at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:137)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:210)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:156)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:148)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81)
        at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:56)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:305)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:192)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:105)
        at org.apache.maven.cli.MavenCli.execute(MavenCli.java:957)
        at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:289)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:193)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:566)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:282)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:225)
        at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:406)
        at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:347)

NB! We observed that changing setup of maven surefire plugin affects the build outcome (see the comment in pom.xml).

@tzezula
Copy link
Member

tzezula commented Apr 4, 2022

The URL to the js language jar file file:/C:/Users/Clark Nielsen/.m2/repository/org/graalvm/js/js/21.1.0/js-21.1.0.jar is wrongly encoded. It contains a space character that should be encoded as %20. I've tried both JDK-11 and JDK-18, the classloaders in both JDKs encode URLs for files with spaces correctly.
The attached test project fails only when you specify the <forkCount>0</forkCount>. If you remove the surefire plugin forkCount option the test passes fine.
The problem is that in the case of forkCount=0 maven uses org.apache.maven.surefire.booter.IsolatedClassLoader which produces URLs with wronlgy encoded spaces. In my case file:/Users/tom/Downloads/03/graalvm-space-error-example/maven repo/org/graalvm/js/js/22.0.0.2/js-22.0.0.2.jar. Without the forkCount=0 the jdk.internal.loader.ClassLoaders$AppClassLoader is used to create the URL and the URL is correcly encoded as file:/Users/tom/Downloads/03/graalvm-space-error-example/maven%20repo/org/graalvm/js/js/22.0.0.2/js-22.0.0.2.jar.

@contrapost
Copy link
Author

contrapost commented Apr 4, 2022

@tzezula, I've mentioned already the problem with surefire plugin in my previous comment.
What is your conclusion? Do you mean this is a surefire bug?

@tzezula
Copy link
Member

tzezula commented Apr 4, 2022

@contrapost, I will remove the assertion error, we should not fail when the ClassLoader returns wrongly encoded URL. I will also report an issue to Maven's IsolatedClassLoader.

@contrapost
Copy link
Author

@tzezula, thank you for the explanation. Do you have any ETA when the assertion error can be removed?

@contrapost
Copy link
Author

contrapost commented Jun 15, 2022

@tzezula, I wonder if there are any progression in this issue? Maybe I can help somehow?

@tzezula
Copy link
Member

tzezula commented Nov 29, 2023

Fixed by oracle/graal@afc3b55

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

3 participants