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

Running Java code with no class produces a cryptic stack trace #393

Open
ctrueden opened this issue Aug 7, 2020 · 1 comment
Open

Running Java code with no class produces a cryptic stack trace #393

ctrueden opened this issue Aug 7, 2020 · 1 comment

Comments

@ctrueden
Copy link
Member

ctrueden commented Aug 7, 2020

Start a new Java script in the Script Editor. Add (only!) the following code:

System.out.println("Hello");

And save it as Hello.java. Then try to run it. The following exception is printed:

Started Hello.java at Fri Aug 07 13:52:47 CDT 2020
java.lang.NullPointerException
	at org.scijava.minimaven.MavenProject$XMLHandler.endElement(MavenProject.java:1531)
	at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source)
	at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanEndElement(Unknown Source)
	at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
	at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
	at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
	at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
	at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
	at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
	at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
	at org.scijava.minimaven.MavenProject.parse(MavenProject.java:1480)
	at org.scijava.minimaven.BuildEnvironment.parse(BuildEnvironment.java:217)
	at org.scijava.plugins.scripting.java.JavaEngine.fakePOM(JavaEngine.java:748)
	at org.scijava.plugins.scripting.java.JavaEngine.writeTemporaryProject(JavaEngine.java:630)
	at org.scijava.plugins.scripting.java.JavaEngine.getMavenProject(JavaEngine.java:530)
	at org.scijava.plugins.scripting.java.JavaEngine.access$700(JavaEngine.java:96)
	at org.scijava.plugins.scripting.java.JavaEngine$Builder.initialize(JavaEngine.java:405)
	at org.scijava.plugins.scripting.java.JavaEngine$Builder.access$100(JavaEngine.java:364)
	at org.scijava.plugins.scripting.java.JavaEngine.compile(JavaEngine.java:197)
	at org.scijava.plugins.scripting.java.JavaEngine.eval(JavaEngine.java:136)
	at org.scijava.script.ScriptModule.run(ScriptModule.java:157)
	at org.scijava.module.ModuleRunner.run(ModuleRunner.java:165)
	at org.scijava.module.ModuleRunner.call(ModuleRunner.java:124)
	at org.scijava.module.ModuleRunner.call(ModuleRunner.java:63)
	at org.scijava.thread.DefaultThreadService.lambda$wrap$2(DefaultThreadService.java:225)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)
java.lang.IllegalArgumentException: Unknown code type: null
	at org.scijava.run.RunService.run(RunService.java:60)
	at org.scijava.plugins.scripting.java.JavaEngine.eval(JavaEngine.java:137)
	at org.scijava.script.ScriptModule.run(ScriptModule.java:157)
	at org.scijava.module.ModuleRunner.run(ModuleRunner.java:165)
	at org.scijava.module.ModuleRunner.call(ModuleRunner.java:124)
	at org.scijava.module.ModuleRunner.call(ModuleRunner.java:63)
	at org.scijava.thread.DefaultThreadService.lambda$wrap$2(DefaultThreadService.java:225)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)

Certainly the java.lang.IllegalArgumentException: Unknown code type: null at org.scijava.run.RunService.run(RunService.java:60) part is a bug here in SJC. The first part, an NPE in minimaven, may need to be addressed there instead.

@imagejan
Copy link
Member

imagejan commented Aug 7, 2020

I wonder if this line is correct:

else if (code instanceof String) scriptFile = new File((String) code);

If we get a String, do we want to interpret it as a filename here? What if the String contains the actual script code?

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

2 participants