After upgrading GraalVM CE from RC11 to RC12, I get the following error in my Java app when attempting to evaluate JS code via the polyglot API. This was working fine with RC11 and earlier.
java.lang.IllegalArgumentException: A language with id 'js' is not installed. Installed languages are: [].
at com.oracle.truffle.polyglot.PolyglotEngineImpl.requirePublicLanguage(PolyglotEngineImpl.java:676)
at com.oracle.truffle.polyglot.PolyglotContextImpl.requirePublicLanguage(PolyglotContextImpl.java:773)
at com.oracle.truffle.polyglot.PolyglotContextImpl.eval(PolyglotContextImpl.java:744)
at org.graalvm.polyglot.Context.eval(Context.java:335)
at org.graalvm.polyglot.Context.eval(Context.java:361)
Hi @ispringer
thanks for your report. That is weird, it is working for us in the setups we test. The error message indicates that no languages are available, even though we ship js by default.
Can you please:
<GraalVM>/bin/js and see whether easy evaluations (1+2) are workingThanks,
Christian
@ispringer can you verify whether you have put the truffle-api.jar on your classpath on GraalVM? If you did, removing it should solve the problem you are seeing. We did change something in that regard that could explain the problem you are seeing. We are still investigating.
Indeed, the following dep was in my project's pom:
<dependency>
<groupId>org.graalvm.truffle</groupId>
<artifactId>truffle-api</artifactId>
<version>${graal.version}</version>
<scope>provided</scope>
</dependency>
This was causing the truffle-api jar to get added to my test classpath by InteeliJ.
Removing it did indeed fix the "js language not found" error I was seeing when running my tests.
Note, I do still have the following dep in my pom, which does not appear to be causing any issues:
<dependency>
<groupId>org.graalvm.sdk</groupId>
<artifactId>graal-sdk</artifactId>
<version>${graal.version}</version>
<scope>provided</scope>
</dependency>
It's interesting this issue just started occurring after upgrading to RC12. Perhaps you could throw an error, or at least log a warning, if truffle-api.jar is found on the system classpath.
Thanks for your help!
I've investigated this further and could identify the changes that caused this problem.
The problematic change is https://github.com/oracle/graal/commits/e38aa347e1de8f8f0474247eb90d193e5ea373d0
I will back that one out and add a regression test so this doesn't happen again.
As a workaround, don't put the truffle-api on the normal classpath if you run on GraalVM. This limitation will be lifted with the next RC. Sorry for the inconvenience this has caused.
@ispringer it is perfectly fine to use the sdk as dependency.
@chumer thanks for your responses. This issue helped me to make our Graal work inside OSGI on 1.0.0-rc11. On fresh versions I'm getting same problems @ispringer mentioned. Would you suggest any solution. For java 8. Also would it be ok if I compile by myself and rollback commit you mentioned, seems it's for Java > 8.
Also seems next piece of code probably requires else for if (JDK8_OR_EARLIER) condition. I haven't looked deeply but if we loaded engine for jdk8 we don't need to iterate again. Deeply sorry if I'm missing something, but we really want to use fresh version of Graal so I might help.
`if (JDK8_OR_EARLIER) {
try {
servicesClass = Class.forName("jdk.vm.ci.services.Services");
} catch (ClassNotFoundException e) {
}
if (servicesClass != null) {
try {
Method m = servicesClass.getDeclaredMethod("loadSingle", Class.class, boolean.class);
engine = (AbstractPolyglotImpl) m.invoke(null, AbstractPolyglotImpl.class, false);
} catch (Throwable e) {
// Fail fast for other errors
throw new InternalError(e);
}
}
}
// As of JDK9, the JVMCI Services class should only be used for service
// types
// defined by JVMCI. Other services types should use ServiceLoader directly.
Iterator<AbstractPolyglotImpl> providers = ServiceLoader.load(AbstractPolyglotImpl.class).iterator();
if (providers.hasNext()) {
engine = providers.next();
if (providers.hasNext()) {
throw new InternalError(String.format("Multiple %s providers found", AbstractPolyglotImpl.class.getName()));
}
}`
hi dmitry, i have exactly the same problem - all new versions does not work for me.
@thomaswue do we need to create a new ticket as this one has been closed?
thx,
florian
I have reopened and assigned to @chumer
@Florian79 Please open a new truffle issue.
This one is (exactly) one year old and if the provided workaround do not work it's likely not the same issue.
@boris-spas @Florian79 @chumer thank you, I raised #2131
Most helpful comment
I've investigated this further and could identify the changes that caused this problem.
The problematic change is https://github.com/oracle/graal/commits/e38aa347e1de8f8f0474247eb90d193e5ea373d0
I will back that one out and add a regression test so this doesn't happen again.
As a workaround, don't put the truffle-api on the normal classpath if you run on GraalVM. This limitation will be lifted with the next RC. Sorry for the inconvenience this has caused.