JPPF Issue Tracker
star_faded.png
Please log in to bookmark issues
bug_report_small.png
CLOSED  Bug report JPPF-325  -  Dynamic classloading problem with Scala REPL
Posted Sep 12, 2014 - updated Aug 15, 2018
icon_info.png This issue has been closed with status "Closed" and resolution "RESOLVED".
Issue details
  • Type of issue
    Bug report
  • Status
     
    Closed
  • Assigned to
     lolo4j
  • Progress
       
  • Type of bug
    Not triaged
  • Likelihood
    Not triaged
  • Effect
    Not triaged
  • Posted by
     zorba128
  • Owned by
    Not owned by anyone
  • Category
    Core
  • Resolution
    RESOLVED
  • Priority
    Normal
  • Reproducability
    Always
  • Severity
    Normal
  • Targetted for
    icon_milestones.png JPPF 4.2.x
Issue description
I'm unable to submit task from Scala (v2.11.2) interactive shell due to classloading problem. It seems it is caused by mismatch of workaround provided in JPPF-180 and scala interpreter's classloader. Shortly: - scala interpreter's classloader successfully returns class definition when accessed using getResource or getResourceAsStream - it returns empty collection when using getResources - workaround changed behavior from straightforward getResource to iteration over getResources' result

Corresponding Scala issue was reported as SI-8843

Steps to reproduce this issue
Following scala code runs successfully when executed as application, and ends with exception when run from REPL.
object ClassLoadingTest extends App {
  import org.jppf.client.{JPPFJob, JPPFClient}
  import org.jppf.node.protocol.AbstractTask
 
  class MyTask extends AbstractTask[String] { def run(): Unit = setResult("success") }
  val job = new JPPFJob
  job.setName("MyJob")
  job.add(new MyTask)
 
  val client = new JPPFClient
  val result = client.submitJob(job).get(0)
  println(s"result: '${result.getResult}'\nexception: '${result.getThrowable}")
  // 'java.lang.ClassNotFoundException: Could not load class '$line5.$read$$iw$$iw$MyTask'
  client.close()
}

#2
Comment posted by
 lolo4j
Sep 12, 11:10
Ok, I can try and implement a workaround by checking the enumeration returned by getResources() and, if it's empty fetching the result of getResource(). I'll publish a patch as soon as it is resolved, I guess it'll be faster than to wait for a Scala bug fix.
#5
Comment posted by
 zorba128
Sep 12, 13:30
Confirmed that additional check:
if(is == null) {
  is = cl.getResourceAsStream(resName);
}


added to ResourceProvider.getResource fixed scala console/JPPF issue. Looks like quite cheap and safe workaround...

#6
Comment posted by
 lolo4j
Sep 13, 07:09
Fixed in: