gpt4 book ai didi

java - Kettle launched inside java函数更改系统属性

转载 作者:行者123 更新时间:2023-11-30 08:30:23 25 4
gpt4 key购买 nike

我在 Wildfly 上的 EJB 中运行 Kettle。

它运行良好,但是,当我重新部署我的 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$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

如果我重新启动 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。如果我使用水壶功能,我无法重新部署 EAR。

Eclipselink 已根据链接 https://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)

我做了什么:

  1. 启动 Wildfly;
  2. 检查属性;
  3. 从我的 ejb 启动 kettle 程序;
  4. 重新检查属性;

在第 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 在寻找什么样的配置文件,但指向一个有效的目录可以帮助您解决这个特定问题。

关于java - Kettle launched inside java函数更改系统属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41248351/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com