Any way to ask AetherPackageLoader to download a resource that is not a library?

15 views
Skip to first unread message

Per Nyfelt

unread,
Jan 17, 2019, 1:07:40 PM1/17/19
to Renjin
Hi,

If i want to use RJDBC with the AetherPackageLoader as the package loader for the session this works fine:
library('org.renjin.cran:RJDBC')

However, when i load the driver (e.g. JDBC("org.postgresql.Driver") ) I have to have that loaded by maven prior to startup for it to work.

e.g. when i do 
drv <- JDBC("org.postgresql.Driver") 
I get org.renjin.eval.EvalException: Cannot find class 'org.postgresql.Driver'

Is there a way to also get the driver to load dynamically?

Even if i set the classloader to be aetherPackageLoader.getClassLoader()
import(org.postgresql.Driver) still throws the same exception

I was looking for something like:
library('org.renjin.cran:RJDBC')
library(DBI)

importClass("org.postgresql.Driver")
drv <- JDBC("org.postgresql.Driver") 


But importClass gives me org.renjin.eval.EvalException: could not find function 'importClass'. and I could not find any R package utilizing importClass in Jvmi in the renjin code.


Is there something similar to importClass that I can use within R in the ScriptEngine?

Best regards,
Per

Per Nyfelt

unread,
Jan 21, 2019, 3:05:13 PM1/21/19
to Renjin
It seems to me that AetherPackageloader.load() has the functionality needed so I injected the AetherPackageloader into the script engine (with the default renjin and central repos configured)
engine.put("packageLoader", getPackageLoader());


And then tried to fiddle with it in the R script to see if i could somehow use the load method to load the driver but unfortunately this did not work:

import(org.renjin.primitives.packaging.FqPackageName)
package <- packageLoader$load(FqPackageName$new("org.postgresql","postgresql"))
print(package$isPresent())

[1] FALSE
print(package$get())



Attaching some listeners to the AetherPackageloader to see some more info:

loader.setRepositoryListener(new ConsoleRepositoryListener(System.out));
loader
.setTransferListener(new ConsoleTransferListener(System.out));

I then get the following output when doing 
package <- packageLoader$load(FqPackageName$new("org.postgresql","postgresql"))


Jan 21, 2019 8:51:20 PM org.renjin.aether.ConsoleRepositoryListener artifactResolving
INFO: Resolving artifact null to null
Resolved package org.postgresql:postgresql (version 42.2.5.jre7) from nexus.bedatadriven.com
Jan 21, 2019 8:51:20 PM org.renjin.aether.ConsoleRepositoryListener artifactResolving
INFO: Resolving artifact null to null
Resolved package org.postgresql:pgjdbc-core-prevjre (version 1.1.5) from nexus.bedatadriven.com
Jan 21, 2019 8:51:20 PM org.renjin.aether.ConsoleRepositoryListener artifactResolving
INFO: Resolving artifact null to null
Jan 21, 2019 8:51:20 PM org.renjin.aether.ConsoleRepositoryListener artifactResolving
INFO: Resolving artifact null to null
Resolved package org.postgresql:pgjdbc-core-parent (version 1.1.5) from nexus.bedatadriven.com
Resolved package org.postgresql:pgjdbc-versions (version 1.1.5) from nexus.bedatadriven.com
Jan 21, 2019 8:51:20 PM org.renjin.aether.ConsoleRepositoryListener artifactResolving
INFO: Resolving artifact null to null
Jan 21, 2019 8:51:20 PM org.renjin.aether.ConsoleRepositoryListener artifactResolving
INFO: Resolving artifact null to null
Resolved package com.github.dblock.waffle:waffle-jna (version 1.7.5) from nexus.bedatadriven.com
Resolved package com.github.dblock.waffle:waffle-parent (version 1.7.5) from nexus.bedatadriven.com
Jan 21, 2019 8:51:20 PM org.renjin.aether.ConsoleRepositoryListener artifactResolving
Resolved package net.java.dev.jna:jna (version 4.2.1) from nexus.bedatadriven.com
INFO: Resolving artifact null to null
Resolved package net.java.dev.jna:jna-platform (version 4.2.1) from nexus.bedatadriven.com
Jan 21, 2019 8:51:20 PM org.renjin.aether.ConsoleRepositoryListener artifactResolving
INFO: Resolving artifact null to null
Jan 21, 2019 8:51:20 PM org.renjin.aether.ConsoleRepositoryListener artifactResolving
Resolved package org.slf4j:jcl-over-slf4j (version 1.7.12) from nexus.bedatadriven.com
INFO: Resolving artifact null to null
Resolved package org.slf4j:slf4j-parent (version 1.7.12) from nexus.bedatadriven.com
Jan 21, 2019 8:51:20 PM org.renjin.aether.ConsoleRepositoryListener artifactResolving
INFO: Resolving artifact null to null
Resolved package org.postgresql:postgresql (version 42.2.5.jre7) from nexus.bedatadriven.com
Jan 21, 2019 8:51:20 PM org.renjin.aether.ConsoleRepositoryListener artifactResolving
INFO: Resolving artifact null to null
Jan 21, 2019 8:51:20 PM org.renjin.aether.ConsoleRepositoryListener artifactResolving
INFO: Resolving artifact null to null
Resolved package com.github.dblock.waffle:waffle-jna (version 1.7.5) from nexus.bedatadriven.com
Resolved package net.java.dev.jna:jna (version 4.2.1) from nexus.bedatadriven.com
Resolved package net.java.dev.jna:jna-platform (version 4.2.1) from nexus.bedatadriven.com
Jan 21, 2019 8:51:20 PM org.renjin.aether.ConsoleRepositoryListener artifactResolving
Resolved package org.slf4j:jcl-over-slf4j (version 1.7.12) from nexus.bedatadriven.com
INFO: Resolving artifact null to null
Jan 21, 2019 8:51:20 PM org.renjin.aether.ConsoleRepositoryListener artifactResolving
INFO: Resolving artifact null to null
Jan 21, 2019 8:51:20 PM org.renjin.aether.ConsoleRepositoryListener artifactResolving
INFO: Resolving artifact null to null

So it seems that the ConsoleTransferListener reports something promising i.e.
Resolved package org.postgresql:postgresql (version 42.2.5.jre7) from nexus.bedatadriven.com

But I cannot figure out how to go from here. Any ideas?

Best regards,
Per
Reply all
Reply to author
Forward
0 new messages