Hitachi Vantara Pentaho Community Forums
Results 1 to 2 of 2

Thread: Transformation cannot use JNDI Datasource from Tomcat

  1. #1

    Default Transformation cannot use JNDI Datasource from Tomcat

    Hi,

    I'm trying to run Kettle Jobs from within a servlet deployed on a Tomcat 7.0

    The connection to the database is defined as a JNDI resource in Tomcat's conf/context.xml

    However when I run the Job inside my Servlet, I get the following exception:

    Code:
    javax.naming.NoInitialContextException: Cannot instantiate class: org.osjava.sj.SimpleContextFactory [Root exception is java.lang.ClassNotFoundException: org.osjava.sj.SimpleContextFactory]
    Cannot instantiate class: org.osjava.sj.SimpleContextFactory
    Why is it trying to instantiate the SimpleJndi environment? Tomcat does supply the proper JNDI DataSource already.

    When I add simple-jndi.jar to my Webapplication then I don't get the ClassNotFoundException but PDI tries to use "jndi.properties" to find the connection details (which of course isn't there) instead of the DataSource supplied by the Tomcat container.

    This is how I initialize the Job in my Servlet:

    Code:
    File kjb = new File("my_job_definition.kjb");
    JobMeta jobMeta = new JobMeta(kjb.getAbsolutePath(), null, null);
    Job job = new Job(null, jobMeta);
    job.setVariable("foo", someValue);
    ...
    job.activateParameters();
    job.addJobListener(this);
    job.addJobEntryListener(this);
    job.start();
    job.waitUntilFinished();
    Do I need to tell the Job that it's running in a Servlet Container and that it doesn't need the SimpleJndi stuff?
    If so, how can I do that?

    I'm aware that I could supply the jndi.properties file, but I don't want to maintain the DB connection information in two different places.

    Am I missing something?

  2. #2

    Default

    Found it myself.

    Instead of calling:
    Code:
    KettleEnvironment.init()
    I have to call
    Code:
    KettleEnvironment.init(false)
    to initialize the Kettle Environment in my Servlet.

    The parameter controls the usage of the SimpleJNDI Library and false means "do not use it"

Tags for this Thread

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.