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

New NullPointerException whith R installed on E: #25

Closed
thetg opened this Issue Dec 15, 2016 · 3 comments

Comments

Projects
None yet
3 participants
@thetg

thetg commented Dec 15, 2016

Hi,
I followed the discussion in NullPointerException on Windows if R not installed in C:\Program Files #22 closely as I had the same problem, and was very happy to see the fast presentation of a solution.
So I got the updated version, but unfortunately RCaller is still not working for me.
The simple code

import com.github.rcaller.rstuff.RCaller;
import com.github.rcaller.util.Globals;

public class Test{
	public static void main( String[] args ){
		Globals.setRPaths( "E:\\R\\R-3.1.1\\bin\\Rscript.exe" , "E:\\R\\R-3.1.1\\bin\\R.exe" );
		RCaller caller = RCaller.create();
	}
}

gives the following Exception:

Exception in thread "main" java.lang.NullPointerException
	at java.io.Reader.<init>(Unknown Source)
	at java.io.InputStreamReader.<init>(Unknown Source)
	at com.github.rcaller.rstuff.RCode.clear(RCode.java:77)
	at com.github.rcaller.rstuff.RCode.create(RCode.java:52)
	at com.github.rcaller.rstuff.RCaller.create(RCaller.java:83)
	at Test.main(Test.java:7)

Interestingly, when I delete the Globals.setRPaths(...) line, the Exception stays the same.
I also tried to install a new version of R in C:\Program Files, but still got the same problem.
As lines 76 and 77 of RCode.class are

InputStream is = this.getClass().getClassLoader().getResourceAsStream("runiversal.r");
InputStreamReader inputStreamReader = new InputStreamReader(is);

i double checked the installation of Runiversal and it is in E:\R\R-3.1.1\library\Runiversal as I guess it should be.
Thanks for reading this, any hint would be appreciated.

@paulcurcean

This comment has been minimized.

Show comment
Hide comment
@paulcurcean

paulcurcean Dec 16, 2016

Collaborator

Strange error you got there, it seems that there's a problem with the classLoader, because it's not able to find the needed resource.

Due to the fact that I'm not a Windows user and Jenkins is on Linux, I won't be able to reproduce your error.

Hopefully a Windows user will be able to help.

Collaborator

paulcurcean commented Dec 16, 2016

Strange error you got there, it seems that there's a problem with the classLoader, because it's not able to find the needed resource.

Due to the fact that I'm not a Windows user and Jenkins is on Linux, I won't be able to reproduce your error.

Hopefully a Windows user will be able to help.

@wongjoel

This comment has been minimized.

Show comment
Hide comment
@wongjoel

wongjoel Dec 19, 2016

Contributor

I'm not sure how to reproduce the problem either. How are you adding RCaller to the classpath? And would it be possible for you to step through the code to determine which part of line 77 is returns null first?

Edit 1: how are you building/compiling RCaller?

Edit 2: If you inspect the JAR file created from building RCaller (i.e. by unzipping it), is "runiversal.r" inside the JAR file? I don't think the code throwing the NullPointerException is aware of the libraries installed in the local R installation, and instead expects "runiversal.r" to be bundled with the JAR file.

Contributor

wongjoel commented Dec 19, 2016

I'm not sure how to reproduce the problem either. How are you adding RCaller to the classpath? And would it be possible for you to step through the code to determine which part of line 77 is returns null first?

Edit 1: how are you building/compiling RCaller?

Edit 2: If you inspect the JAR file created from building RCaller (i.e. by unzipping it), is "runiversal.r" inside the JAR file? I don't think the code throwing the NullPointerException is aware of the libraries installed in the local R installation, and instead expects "runiversal.r" to be bundled with the JAR file.

@thetg

This comment has been minimized.

Show comment
Hide comment
@thetg

thetg Dec 19, 2016

@wongjoel had the right idea and I could fix my mistake.
I created a new .jar with the updated Globals.class and missed to include "runiversal.r".
After creating the .jar properly it now works fine.
I'm happy that I now can start to explore RCaller.
Thank you so much for your answers.

thetg commented Dec 19, 2016

@wongjoel had the right idea and I could fix my mistake.
I created a new .jar with the updated Globals.class and missed to include "runiversal.r".
After creating the .jar properly it now works fine.
I'm happy that I now can start to explore RCaller.
Thank you so much for your answers.

@thetg thetg closed this Dec 19, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment