Kettle launched inside java 函数更改系统属性
Kettle lauched inside java function change system properties
我在 Wildfly 上的 EJB 中 运行 Kettle。
它运行良好,但是,当我 re-deploy 我的 EAR 应用程序时,wildfly 给我很多交易错误:
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.run(PersistenceUnitServiceImpl.java:172)
at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.run(PersistenceUnitServiceImpl.java:117)
at org.wildfly.security.manager.WildFlySecurityManager.doChecked(WildFlySecurityManager.java:665)
at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.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
如果我重新启动 wildfly,那么我可以毫无问题地部署该应用程序。
这是用于执行作业的代码:
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);
}
转换和 JPA 都正确插入了数据。如果我在不调用任何转换的情况下使用该项目,则 EAR 是 re-deployed 没有问题。如果我使用水壶功能,我不能 re-deploy EAR。
Eclipselink按照linkhttps://docs.jboss.org/author/display/WFLY10/JPA+Reference+Guide#JPAReferenceGuide-UsingEclipseLink
的流程在Wildfly中注册
编辑:
使用 wildfly 的 CLI,我用命令检查了系统属性:
/core-service=platform-mbean/type=runtime:read-attribute(name=system-properties)
我做了什么:
- 启动 Wildfly;
- 检查属性;
- 从我的 ejb 启动 kettle 程序;
- Re-Check属性;
在第 4 步,我添加了 Kettle 的新属性,例如 org.osjava.sj.root 更改 Wildfly 的默认值。
所以解决方案是如何更改 kettle 使用的属性名称或删除自动添加的属性。我正在朝这个方向寻找。
我已经编辑了标题,所以它太接近真正的问题了
我想先声明一下,我对水壶一无所知。
java.io.File parameter must be a directory. [/opt/wildfly-9.0.2.Final/bin/simple-jndi]
查看上面的错误消息,虽然看起来 kettle 可能正在寻找名为 simple-jndi
的目录。查看 source 似乎可以使用 org.osjava.sj.root
系统 属性 设置此目录。
在 WildFly 中,您可以使用以下 CLI 命令设置系统 属性。
/system-property=org.osjava.sj.root:add(value="/some/path")
我不知道 kettle 在寻找什么样的配置文件,但指向一个有效的目录可以帮助您解决这个特定问题。
问题是:
Wildfly 有自己的 org.osjava.sf.root 属性 叶黑,所以它使用标准的。
Kettle,你在设置环境的时候,加上他的org.osjava.sf.root。
当 Kettle 关闭时,属性 仍然存在,所以 Wildfly 使用新的,但没有任何效果。
解决方法是:当你设置环境时,而不是
KettleEnvironment.init();
使用
KettleEnvironment.init(false);
因此,属性 未创建。
我在 Wildfly 上的 EJB 中 运行 Kettle。
它运行良好,但是,当我 re-deploy 我的 EAR 应用程序时,wildfly 给我很多交易错误:
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.run(PersistenceUnitServiceImpl.java:172)
at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.run(PersistenceUnitServiceImpl.java:117)
at org.wildfly.security.manager.WildFlySecurityManager.doChecked(WildFlySecurityManager.java:665)
at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.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
如果我重新启动 wildfly,那么我可以毫无问题地部署该应用程序。
这是用于执行作业的代码:
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);
}
转换和 JPA 都正确插入了数据。如果我在不调用任何转换的情况下使用该项目,则 EAR 是 re-deployed 没有问题。如果我使用水壶功能,我不能 re-deploy EAR。
Eclipselink按照linkhttps://docs.jboss.org/author/display/WFLY10/JPA+Reference+Guide#JPAReferenceGuide-UsingEclipseLink
的流程在Wildfly中注册编辑:
使用 wildfly 的 CLI,我用命令检查了系统属性:
/core-service=platform-mbean/type=runtime:read-attribute(name=system-properties)
我做了什么:
- 启动 Wildfly;
- 检查属性;
- 从我的 ejb 启动 kettle 程序;
- Re-Check属性;
在第 4 步,我添加了 Kettle 的新属性,例如 org.osjava.sj.root 更改 Wildfly 的默认值。 所以解决方案是如何更改 kettle 使用的属性名称或删除自动添加的属性。我正在朝这个方向寻找。 我已经编辑了标题,所以它太接近真正的问题了
我想先声明一下,我对水壶一无所知。
java.io.File parameter must be a directory. [/opt/wildfly-9.0.2.Final/bin/simple-jndi]
查看上面的错误消息,虽然看起来 kettle 可能正在寻找名为 simple-jndi
的目录。查看 source 似乎可以使用 org.osjava.sj.root
系统 属性 设置此目录。
在 WildFly 中,您可以使用以下 CLI 命令设置系统 属性。
/system-property=org.osjava.sj.root:add(value="/some/path")
我不知道 kettle 在寻找什么样的配置文件,但指向一个有效的目录可以帮助您解决这个特定问题。
问题是: Wildfly 有自己的 org.osjava.sf.root 属性 叶黑,所以它使用标准的。 Kettle,你在设置环境的时候,加上他的org.osjava.sf.root。 当 Kettle 关闭时,属性 仍然存在,所以 Wildfly 使用新的,但没有任何效果。
解决方法是:当你设置环境时,而不是
KettleEnvironment.init();
使用
KettleEnvironment.init(false);
因此,属性 未创建。