maven-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Guillaume Boué (JIRA) <j...@apache.org>
Subject [jira] [Commented] (MANTRUN-200) Scriptdef tasks fail to load when running on Java9
Date Wed, 23 Aug 2017 17:31:00 GMT

    [ https://issues.apache.org/jira/browse/MANTRUN-200?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16138712#comment-16138712
] 

Guillaume Boué commented on MANTRUN-200:
----------------------------------------

[~rfscholte] Yes, the parent used by ServiceLoader to delegate is returned by {{getParent()}},
and this is {{null}}. Just considering modules, it means only services present in modules
loaded by the bootstrap classloader are found. I think Nashorn is loaded with the system classloader
in Java 9 (and was previously loaded with bootstrap classloader). So from what I gathered,
passing the system classloader, instead of {{null}}, in {{world.newRealm( realmId, null )}}
would solve this Jira issue, meaning the Nashorn implementation would be found (I tested this
previously and it really solves it).

But I'm afraid it would just hide another issue: a module loaded by the Maven core extension
classloader still would not be found. For that, I believe you would need to pass Core Ext
classloader as parent in {{world.newRealm( realmId, null )}}, or even pass whatever {{parent}}
was passed to {{createRealm}} in {{DefaultClassRealmManager}}, but I tested that this has
bad consequences for plugins using the Site Plugin. The problem was that the search for a
given class would now delegate to the parent first and then plugin classloader. In the case
of the Site Plugin, the parent would be the Site Plugin's realm, and this would mean that
it is the classes loaded by maven-site that are found before the ones of the plugin itself...and
this quickly turned into version conflicts and ClassNotFoundException when the plugin overrides
a dependency...

> Scriptdef tasks fail to load when running on Java9
> --------------------------------------------------
>
>                 Key: MANTRUN-200
>                 URL: https://issues.apache.org/jira/browse/MANTRUN-200
>             Project: Maven Antrun Plugin
>          Issue Type: Bug
>    Affects Versions: 1.8
>            Reporter: Dan Berindei
>
> I have a Maven project using maven-antrun-plugin:
> {code}
> <?xml version='1.0' encoding='UTF-8'?>
> <project>
>    <modelVersion>4.0.0</modelVersion>
>    <artifactId>my-test-app</artifactId>
>    <groupId>my-test-group</groupId>
>    <version>1.0-SNAPSHOT</version>
>    <build>
>       <plugins>
>          <plugin>
>             <groupId>org.apache.maven.plugins</groupId>
>             <artifactId>maven-antrun-plugin</artifactId>
>             <version>1.8</version>
>             <executions>
>                <execution>
>                   <id>compile</id>
>                   <phase>compile</phase>
>                   <configuration>
>                      <target>
>                         <ant antfile="build.xml" inheritRefs="true">
>                            <target name="all"/>
>                         </ant>
>                      </target>
>                   </configuration>
>                   <goals>
>                      <goal>run</goal>
>                   </goals>
>                </execution>
>             </executions>
>          </plugin>
>       </plugins>
>    </build>
> </project>
> {code}
> The Ant build file uses a script:
> {code}
> <?xml version='1.0' encoding='UTF-8'?>
> <project name="scriptdef-test-build">
>    <scriptdef name="test-script" language="javascript">
>       <![CDATA[
>            var System = Java.type('java.lang.System');
>            System.out.println("Working!");
>         ]]>
>    </scriptdef>
>    <target name="all">
>       <test-script/>
>    </target>
> </project>
> {code}
> On Java 8 it works, but on Java 9 (9-ea+162) it can't find the script engine:
> {noformat}
> org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-antrun-plugin:1.8:run
(compile) on project my-test-app: An Ant BuildException has occured: The following error occurred
while executing this line:
> /home/dan/scriptdef-test/build.xml:10: Unable to create javax script engine for javascript
> around Ant part ...<ant antfile="build.xml" inheritRefs="true">... @ 4:47 in /home/dan/scriptdef-test/target/antrun/build-main.xml
> ...    
> Caused by: /home/dan/scriptdef-test/build.xml:10: Unable to create javax script engine
for javascript
>     at org.apache.tools.ant.util.optional.JavaxScriptRunner.evaluateScript(JavaxScriptRunner.java:84)
>     at org.apache.tools.ant.util.optional.JavaxScriptRunner.executeScript(JavaxScriptRunner.java:67)
>     at org.apache.tools.ant.taskdefs.optional.script.ScriptDef.executeScript(ScriptDef.java:350)
>     at org.apache.tools.ant.taskdefs.optional.script.ScriptDefBase.execute(ScriptDefBase.java:50)
>     at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
>     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:547)
>     at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
>     at org.apache.tools.ant.Task.perform(Task.java:348)
>     at org.apache.tools.ant.Target.execute(Target.java:435)
>     at org.apache.tools.ant.Target.performTasks(Target.java:456)
>     at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1393)
>     at org.apache.tools.ant.helper.SingleCheckExecutor.executeTargets(SingleCheckExecutor.java:38)
>     at org.apache.tools.ant.Project.executeTargets(Project.java:1248)
>     at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:441)
>     ... 34 more
> {noformat}
> I have attached a debugger and I saw that the {{ScriptEngineManager}} used by {{JavaxScriptRunner}}
doesn't have any script engines, because the service loader it uses doesn't find any {{ScriptEngineFactory}}
implementations. I have tried {{\--add-modules jdk.scripting.nashorn}} and {{\--add-opens
jdk.scripting.nashorn/jdk.nashorn.api.scripting=ALL-UNNAMED}}, but neither helped.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Mime
View raw message