[R] [rJava] RJavaClassLoader and system classloader
Mohan Radhakrishnan
radhakrishnan.mohan at gmail.com
Tue Sep 30 12:23:25 CEST 2014
Hi,
You could ask the author or post an issue here .(
https://github.com/s-u/rJava)
I had faced a problem and I got a response from him.
In my case I am streaming JVM data and this(
http://www.openanalytics.eu/r-service-bus) may be a better idea. I haven't
still tried this.
Thanks,
Mohan
On Fri, Sep 26, 2014 at 5:25 PM, Benoît Thiébault <thiebault at artenum.com>
wrote:
> Hi everyone,
>
> I want to call a Java application from R and have encountered some
> problems with the way rJava deals with the system class loader.
>
> To run my application, I use the following R script:
>
> > library(rJava)
> > .jinit()
> > .jaddClassPath("myApp.jar")
> > rWrapper <- .jnew("org/test/RWrapper")
> > .jcall(rWrapper,"V","start")
>
> My Java application has a plugins loading mechanism that uses a specific
> PluginClassLoader to load plugins stored in additional JAR files (e.g.
> plugin.jar). This PluginClassLoader is programed so that it knows and loads
> the plugins JARs. As any Java classloader, it is a child of the system
> class loader.
>
> Finally, plugins not only use classes stored in their plugin.jar file,
> they also depend on classes contained in the main myApp.jar file (the
> Plugin interface is for example defined in the myApp.far)
>
> In a pure Java environment, myApp.jar is known from the system class
> loader (it is in the classpath) and thus the PluginClassLoader can load
> classes from the plugin (it knows both about the plugin.jar and the
> myApp.jar files)
>
> In the R context however, using the above script, its the RJavaClassLoader
> that knows about the myApp.jar file. The org.test.RWrapper class is
> instatiated by the RJavaClassLoader. The system class loader however does
> not know about myApp.jar anymore. Neither does the PluginClassLoader. So
> when the PluginClassLoader loads a plugin class, it can only load classes
> that are in the plugin.jar file and as soon as a class from the myApp.jar
> file is required by the plugin, it crashes with a
> java.lang.NoClassDefFoundError message.
>
> My question is: how can I force rJava to load the classpath in the system
> classloader and not only in the RJavaClassLoader?
>
> I cannot make the PluginClassLoader know the RJavaClassLoader as my
> application also has to run in a non-R environment.
>
> Thanks for your time,
>
> Kind regards,
>
> Ben
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
[[alternative HTML version deleted]]
More information about the R-help
mailing list