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

Unable to execute Ruby script in JDK11 via JRuby 9.2.7.0 #5798

Open
Syed-SnapLogic opened this issue Jul 23, 2019 · 6 comments

Comments

@Syed-SnapLogic
Copy link

commented Jul 23, 2019

My source code is listed at https://github.com/Syed-SnapLogic/SyedsPublicRepo/tree/master/JrubyTest.

I unable to execute the code at https://github.com/Syed-SnapLogic/SyedsPublicRepo/blob/master/JrubyTest/src/main/java/com/syed/jrubytest/Test2.java.

I am getting the below error:

--- exec-maven-plugin:1.5.0:exec (default-cli) @ JrubyTest ---
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.headius.backport9.modules.Modules (file:/home/gaian/.m2/repository/com/headius/backport9/1.2/backport9-1.2.jar) to field java.io.FileDescriptor.fd
WARNING: Please consider reporting this to the maintainers of com.headius.backport9.modules.Modules
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
NilClass
NilClass
Exception in thread "main" org.jruby.exceptions.NoMethodError: (NoMethodError) undefined method `hasNext' for nil:NilClass
	at RUBY.execute(<script>:14)
Command execution failed.
org.apache.commons.exec.ExecuteException: Process exited with an error: 1 (Exit value: 1)
	at org.apache.commons.exec.DefaultExecutor.executeInternal(DefaultExecutor.java:404)
	at org.apache.commons.exec.DefaultExecutor.execute(DefaultExecutor.java:166)
	at org.codehaus.mojo.exec.ExecMojo.executeCommandLine(ExecMojo.java:764)
	at org.codehaus.mojo.exec.ExecMojo.executeCommandLine(ExecMojo.java:711)
	at org.codehaus.mojo.exec.ExecMojo.execute(ExecMojo.java:289)
	at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
	at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
	at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
	at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
	at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
	at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
	at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
	at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
	at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
	at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
	at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
	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:289)
	at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
	at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
	at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)

Any help to resolve the above error would be a great favour. Thanks.

@enebo

This comment has been minimized.

Copy link
Member

commented Jul 23, 2019

@Syed-SnapLogic try changing all global variables to constants (e.g. $input -> INPUT) and see if your example works.

@Syed-SnapLogic

This comment has been minimized.

Copy link
Author

commented Jul 24, 2019

@enebo, sorry, I didn't get what exactly you meant. Can you pls provide your suggestion in more details with an illustration?

@enebo

This comment has been minimized.

Copy link
Member

commented Jul 24, 2019

@Syed-SnapLogic on this line https://github.com/Syed-SnapLogic/SyedsPublicRepo/blob/master/JrubyTest/src/main/java/com/syed/jrubytest/Test2.java#L60 you use $input etc... which are global variables. Below you bind to constants (e.g. INPUT). I do not think $input can be anything other than nil.

@Syed-SnapLogic

This comment has been minimized.

Copy link
Author

commented Jul 25, 2019

@enebo, sorry, your point is invalid. If I simply use an older JRuby, 9.1.17.0, the program works fine and delivers output. I want to use latest version, 9.2.7.0, but its giving that problem. According to me, its a bug in JRuby or I am missing some correct configuration. Thats what I need help here for.

@enebo

This comment has been minimized.

Copy link
Member

commented Jul 25, 2019

@Syed-SnapLogic I did misread your code with the constant comment above. You are doing a setBinding("input", something). I do not see where yet but we changed binding to require the globals to be written as them:

    private static final String INPUT = "$input";

It you try changing those String to add a '$' in front I believe this script will work in 9.2. I will see if I can find which commit changed this. I am giving 50% odds this was intentional (and 9.2 is a major release in JRuby so this may be a required change to move to 9.2). I will comment again once I figure out when this changed.

@enebo

This comment has been minimized.

Copy link
Member

commented Jul 25, 2019

This appears to be the change: #5012 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.