pentaho / pdi-sdk-plugins

PDI SDK plugins
111 stars 154 forks source link

Exceptions of FTP and Javascript plugins when run jobs in Java. #39

Open nicholas-geek opened 7 years ago

nicholas-geek commented 7 years ago

I modified the funciton runJobFromFileSystem() in the class RunningJobs, and execute my examples, but get some exceptions, why? (These examples are called OK by spoon.bat and spoon.sh)

1. FTP job: java.lang.NoClassDefFoundError: com/enterprisedt/net/ftp/FTPException at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Unknown Source) at org.pentaho.di.core.plugins.PluginRegistry.loadClass(PluginRegistry.java:488) at org.pentaho.di.job.entry.JobEntryCopy.(JobEntryCopy.java:136) at org.pentaho.di.job.JobMeta.loadXML(JobMeta.java:1132) at org.pentaho.di.job.JobMeta.(JobMeta.java:779) at org.pentaho.di.job.JobMeta.(JobMeta.java:758) at org.pentaho.di.job.JobMeta.(JobMeta.java:733) at org.pentaho.di.sdk.samples.embedding.RunningComJobs.runJobFromFileSystem(RunningComJobs.java:90) at org.pentaho.di.sdk.samples.embedding.RunningComJobs.main(RunningComJobs.java:43) Caused by: java.lang.ClassNotFoundException: com.enterprisedt.net.ftp.FTPException at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) ... 10 more org.pentaho.di.core.exception.KettleXMLException: Unable to load the job from XML file [E:\Pdispace\cime\ftp_download.kjb]

Unable to load job info from XML node

Unable to read Job Entry copy info from XML node : org.pentaho.di.core.exception.KettlePluginException: Unexpected error loading class: com/enterprisedt/net/ftp/FTPException

2. another Job: java.lang.NoClassDefFoundError: org/mozilla/javascript/JavaScriptException at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Unknown Source) at org.pentaho.di.core.plugins.PluginRegistry.loadClass(PluginRegistry.java:488) at org.pentaho.di.core.plugins.PluginRegistry.loadClass(PluginRegistry.java:366) at org.pentaho.di.trans.step.StepMeta.(StepMeta.java:303) at org.pentaho.di.trans.TransMeta.loadXML(TransMeta.java:3020) at org.pentaho.di.trans.TransMeta.(TransMeta.java:2757) at org.pentaho.di.job.entries.trans.JobEntryTrans.getTransMeta(JobEntryTrans.java:1264) at org.pentaho.di.job.entries.trans.JobEntryTrans.execute(JobEntryTrans.java:681) at org.pentaho.di.job.Job.execute(Job.java:724) at org.pentaho.di.job.Job.execute(Job.java:865) at org.pentaho.di.job.Job.execute(Job.java:865) at org.pentaho.di.job.Job.execute(Job.java:609) at org.pentaho.di.job.entries.job.JobEntryJobRunner.run(JobEntryJobRunner.java:69) at java.lang.Thread.run(Unknown Source) Caused by: java.lang.ClassNotFoundException: org.mozilla.javascript.JavaScriptException at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) ... 15 more

my code of runJobFromFileSystem() : public Job runJobFromFileSystem( String filename ) {

    try {
      System.out.println( "***************************************************************************************" );
      System.out.println( "Attempting to run job " + filename + " from file system" );
      System.out.println( "***************************************************************************************\n" );
      // Loading the job file from file system into the JobMeta object.
      // The JobMeta object is the programmatic representation of a job
      // definition.
      JobMeta jobMeta = new JobMeta( filename, null );

      // Creating a Job object which is the programmatic representation of
      // a job
      // A Job object can be executed, report success, etc.
      Job job = new Job( null, jobMeta );

      // adjust the log level
      job.setLogLevel( LogLevel.MINIMAL );

      System.out.println( "\nStarting job" );

      // starting the job thread, which will execute asynchronously
      job.start();

      // waiting for the job to finish
      job.waitUntilFinished();

      // retrieve the result object, which captures the success of the job
      Result result = job.getResult();

      // report on the outcome of the job
      String outcome = String.format( "\nJob %s executed with result: %s and %d errors\n",
        filename, result.getResult(), result.getNrErrors() );
      System.out.println( outcome );

      return job;
    } catch ( Exception e ) {
      // something went wrong, just log and return
      e.printStackTrace();
      return null;
    }
  }
nicholas-geek commented 7 years ago

Branch: pdi-sdk-plugins-master