Kettle lauched inside java function change system properties

697 views Asked by At

I'm running Kettle inside an EJB on Wildfly.

It works well but, when i re-deploy my EAR application, wildfly give me a lot of transaction errors:

Exception Description: Error obtaining the Transaction Manager
Internal Exception: Exception [EclipseLink-23001] (Eclipse Persistence Services - 2.6.0.v20150309-bf26070):
    org.eclipse.persistence.exceptions.TransactionException
Exception Description: Error looking up external Transaction resource under JNDI name [java:/TransactionManager]
Internal Exception: javax.naming.NamingException: WFLYNAM0027: Failed instantiate InitialContextFactory org.osjava.sj.SimpleContextFactory from classloader ModuleClassLoader for Module "deployment.XXXX_ear-1.0-SNAPSHOT.ear.XXXX_web.war:main" from Service Module Loader [Root exception is java.lang.IllegalArgumentException: java.io.File parameter must be a directory. [/opt/wildfly-9.0.2.Final/bin/simple-jndi]]
at
 org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:172)
at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:117)
at org.wildfly.security.manager.WildFlySecurityManager.doChecked(WildFlySecurityManager.java:665)
at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1.run(PersistenceUnitServiceImpl.java:182)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
at org.jboss.threads.JBossThread.run(JBossThread.java:320)

Caused by: javax.persistence.PersistenceException: Exception [EclipseLink-23004] (Eclipse Persistence Services - 2.6.0.v20150309-bf26070): org.eclipse.persistence.exceptions.TransactionException

If i restart wildfly, then i can deploy the app with no problem.

This is the code used for executing the job:

 public static KettleEnd executeJob(String filename, Map<String,String> parameters, String[] arguments) 
        throws KettleXMLException, KettleException{

    if(!KettleEnvironment.isInitialized())
        KettleEnvironment.init();

    JobMeta jobMeta = new JobMeta(filename, null);

    if(parameters != null){
        for(String key : parameters.keySet()){
            try {
                jobMeta.setParameterValue(key, parameters.get(key));
            } catch (UnknownParamException ex) {
                LOG.log(Level.SEVERE, null, ex);
            }
        }
    }
    Job job = new Job(null, jobMeta);

    if(arguments != null && arguments.length> 0 )
        job.setArguments(arguments);

    String logChannelId = job.getLogChannelId();
    job.start();
    job.waitUntilFinished();
    int errori = job.getErrors();
    List<KettleLoggingEvent> lkl = KettleLogStore.getLogBufferFromTo(logChannelId, true, 0, KettleLogStore.getLastBufferLineNr());
    String templog = kettleLogToString(lkl);
    KettleLogStore.discardLines(logChannelId, true);

    LOG.log(Level.INFO, "PDIExecutor : fine job, {0} errori",errori);
    KettleEnvironment.shutdown();
    return new KettleEnd(errori, templog);

}

The data are inserted correctly by the trasformation and also by JPA. If I use the project without calling any trasformation, the EAR is re-deployed without problem. If I use the kettle function, i can't re-deploy the EAR.

Eclipselink is registered in Wildfly according the procedure at the link https://docs.jboss.org/author/display/WFLY10/JPA+Reference+Guide#JPAReferenceGuide-UsingEclipseLink

EDIT:

Using the wildfly's CLI, i've checked the system properties with the command:

/core-service=platform-mbean/type=runtime:read-attribute(name=system-properties)

What i did:

  1. Start Wildfly;
  2. Check the properties;
  3. Launch kettle procedure from my ejb;
  4. Re-Check the properties;

At step 4 i've new properties added by Kettle, for instance org.osjava.sj.root that change Wildfly's default. So the solution is how to change the properties name used by kettle or to remove autoadded properties. I'am searching in this direction. I've edited che title so it's too close to the real problem

2

There are 2 answers

0
Daniele Licitra On BEST ANSWER

The problem is: Wildfly has his own org.osjava.sf.root property leaved black, so it use a standard one. Kettle, when you set the environment, add his org.osjava.sf.root. When Kettle shutdown, the property is still there, so Wildfly use the new one and nothing works well.

The solution is: when you set the environmente, instead of

KettleEnvironment.init();

use

KettleEnvironment.init(false);

so, that property is not created.

1
James R. Perkins On

I want to start with a disclaimer that I don't know anything about kettle.

java.io.File parameter must be a directory. [/opt/wildfly-9.0.2.Final/bin/simple-jndi]

Looking at the above error message though it looks like kettle might be looking for a directory called simple-jndi. Looking at the source it looks like you can use the org.osjava.sj.root system property to set this directory.

In WildFly you could set the system property with the following CLI command.

/system-property=org.osjava.sj.root:add(value="/some/path")

I don't know what kind of configuration file kettle is looking for, but pointing to a valid directory would get you around this specific issue.