【问题标题】:Kettle lauched inside java function change system propertiesKettle 在 java 函数中启动更改系统属性
【发布时间】:2017-05-06 00:36:38
【问题描述】:

我在 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 启动水壶程序;
  4. 重新检查属性;

在第 4 步,我添加了 Kettle 添加的新属性,例如更改 Wildfly 的默认值的 org.osjava.sj.root。 所以解决方案是如何更改kettle使用的属性名称或删除自动添加的属性。我正在朝这个方向寻找。 我已经编辑了 che 标题,所以它太接近真正的问题了

【问题讨论】:

  • 看起来您正在使用 EclipseLink。你是怎么安装的?
  • EclipseLink 2.6.0 作为模块安装在 wildfly 中。在我的 EAR 中,我使用 maven,eclipselink 被标记为“提供”
  • 您是否按照此处docs.jboss.org/author/display/WFLY10/…的说明进行操作?
  • 是的,我做到了。转换/作业有效,记录写入数据库。我也将 eclipselink 与 JPA 一起使用,它可以工作。我认为水壶留下一些连接或一些交易。如果我在没有调用任何转换的情况下运行软件,我没有问题。

标签: java transactions eclipselink wildfly kettle


【解决方案1】:

我想先声明一下我对水壶一无所知。

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,检查了属性,然后启动了kettle 并重新检查了属性:kettle 插入了覆盖wildfly 标准属性的新属性
【解决方案2】:

问题是: Wildfly 有他自己的 org.osjava.sf.root 属性留黑,所以它使用一个标准的。 Kettle,在设置环境的时候,添加他的org.osjava.sf.root。 Kettle 关闭时,属性还在,Wildfly 使用新的,但没有任何效果。

解决办法是:当你设置环境时,而不是

KettleEnvironment.init();

使用

KettleEnvironment.init(false);

所以,没有创建该属性。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2010-12-02
    • 1970-01-01
    • 1970-01-01
    • 2019-02-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-08-06
    相关资源
    最近更新 更多