Hitachi Vantara Pentaho Community Forums
Results 1 to 4 of 4

Thread: Classloader problem

  1. #1

    Default Classloader problem

    Hello everybody.

    I'm trying to execute a transformation file (.ktr) from BI Server. I tried to do it by using a xaction file but it doesn't work. So I decided to write a custom Java code to do it.

    The KTR file seems to works, I tested it in Data integration and by using Pan in command line. But when I call it in my own code, some errors appears, error you can find here : http://jira.pentaho.com/browse/PDI-2172 except for the step : it's a [Constant] step that fails in my case.

    I really need it so if someone has an idea on how to solve this, I'm interested.

  2. #2

    Default

    After few days to work on it, I solved this problem.

    The first version of my java code was :
    Code:
    package net.delistage.tests;
    
    import java.util.List;
    
    import org.pentaho.di.trans.StepLoader;
    import org.pentaho.di.trans.StepPlugin;
    import org.pentaho.di.trans.Trans;
    import org.pentaho.di.trans.TransMeta;
    
    public class DataIntegrationManager {
        private static String transFile = "mytrans.ktr";
    
        public static void main(String[] args) throws Exception {
            TransMeta tm = new TransMeta(transFile);
            Trans trans = new Trans(tm);
            trans.execute(null);
        }
    }
    This one generate the error that block me. So I try to initialize by myself the plugin list. My new version which is working is :

    Code:
    import java.util.List;
    
    import org.pentaho.di.trans.StepLoader;
    import org.pentaho.di.trans.StepPlugin;
    import org.pentaho.di.trans.Trans;
    import org.pentaho.di.trans.TransMeta;
    
    public class DataIntegrationManager {
        private static String transFile = "mytrans.ktr";
    
        public static void main(String[] args) throws Exception {
    
            StepLoader sl = StepLoader.getInstance();
            StepLoader.init(new String[] { "org.pentaho.di.trans",
                    "net.delistage.pentaho.plugin"
    
            });
            String[] pp = sl.getPluginPackages();
            List<StepPlugin> ls = sl.getPluginList();
            System.out.println(pp.length);
            System.out.println(ls.size());
    
            TransMeta tm = new TransMeta(transFile);
            Trans trans = new Trans(tm);
            trans.execute(null);
        }
    }
    If you use a custom plugin like me, don't forget to copy it into the directory ".kettle/plugins" and import it into the classpath. The plugin must be compiled using the version 1.5 of the compiler otherwise an error "Invalid class version" appears.

    Regards.

  3. #3
    Join Date
    Nov 1999
    Posts
    9,729

    Default

    I'm simplifying it for 4.0:

    Code:
    KettleEnvironment.init()
    Should be all you need to do.

    In 3.x you actually need these to cover most situations:

    Code:
    EnvUtil.environmentInit();
    JndiUtil.initJNDI();
    StepLoader.init();
    JobEntryLoader.init();

  4. #4

    Thumbs up

    Indeed it's much easier by using these methods and it works as well.

    Code:
    package net.delistage.tests;
    
    import org.pentaho.di.core.JndiUtil;
    import org.pentaho.di.core.exception.KettleException;
    import org.pentaho.di.core.util.EnvUtil;
    import org.pentaho.di.job.JobEntryLoader;
    import org.pentaho.di.trans.StepLoader;
    import org.pentaho.di.trans.Trans;
    import org.pentaho.di.trans.TransMeta;
    
    public class DataIntegrationManager {
        private static String transFile = "mytrans.ktr";
    
        public static void main(String[] args) throws KettleException {
            EnvUtil.environmentInit();
            JndiUtil.initJNDI();
            StepLoader.init();
            JobEntryLoader.init();
    
            TransMeta tm = new TransMeta(transFile);
            Trans trans = new Trans(tm);
            trans.execute(null);
        }
    }
    Thank you for this tips.
    Last edited by SEB54; 07-10-2009 at 06:14 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Privacy Policy | Legal Notices | Safe Harbor Privacy Policy

Copyright © 2005 - 2019 Hitachi Vantara Corporation. All Rights Reserved.