Bug 54484 - Its's impossible execute java applications from ant when this applications use JSR223.
Summary: Its's impossible execute java applications from ant when this applications us...
Status: NEW
Alias: None
Product: Ant
Classification: Unclassified
Component: Core (show other bugs)
Version: 1.9.1
Hardware: All All
: P2 minor (vote)
Target Milestone: ---
Assignee: Ant Notifications List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-01-25 10:26 UTC by Ángel Cervera Claudio
Modified: 2013-05-22 03:39 UTC (History)
2 users (show)



Attachments
Example for testing (4.30 KB, application/zip)
2013-01-25 10:26 UTC, Ángel Cervera Claudio
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ángel Cervera Claudio 2013-01-25 10:26:39 UTC
Created attachment 29896 [details]
Example for testing

When an application uses JSR223 and is executed from ant, it's not possible obtain ScriptEngine for "JavaScript".
Same application, from command line, works perfectly.

This error is obtain:
ScriptEngineManager providers.next(): javax.script.ScriptEngineFactory: Provider com.sun.script.javascript.RhinoScriptEngineFactory not found

I attach an eclipse project with this very simple example:

Class:
package testing;

import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;

public class TestingGetEngineJavascript {

	public static void main(String[] args) {
		new TestingGetEngineJavascript().test();

	}
	
	public void test() {
		ScriptEngineManager manager = new ScriptEngineManager();
        ScriptEngine engine = manager.getEngineByName("JavaScript");
        if(engine == null) {
        	throw new RuntimeException("Upps!!!!!!! Not ScriptEngine found for JavaScript");
        } else {
        	System.out.println("ScriptEngine found for JavaScript");
        }
	}

}


Ant:
<project name="test" default="test" basedir=".">
	<target name="test">
		<java classpath="dist/testAntJSR223.jar" classname="testing.TestingGetEngineJavascript">
		</java>
	</target>
</project>
Comment 1 Ángel Cervera Claudio 2013-01-25 10:58:41 UTC
There are a "temporal" workaround: use fork="true"

But I think that it's a bug.
Comment 2 Jesse Glick 2013-01-25 18:44:02 UTC
You should always use fork="true" for user programs. fork="false" is only appropriate for running things that you expect to interact with the live Ant internal data structures.

Whether it is a (fixable) bug that ScriptEngineFactory behaves this way for JS inside Ant, I am not sure.
Comment 3 Ángel Cervera Claudio 2013-01-26 07:49:32 UTC
This JSR223 application is an utility to process files. At the moment, I execute this directly as an application, but my idea is build an ANT Plugin (Now I'm busy, but in a short time I must to do).

In other cases, when I built a ANT Plugin, I didn't have to modified my code.
I suppose that I could force execution of the plugin as a fork. Is this supposition correct?