Java 1.6在后台Symfony任务调用时中断 [英] Java 1.6 Broken when called by background Symfony task

查看:205
本文介绍了Java 1.6在后台Symfony任务调用时中断的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Symfony任务,它生成一些文件调用exec到jar然后解析输出。 jar从命令行运行正常,任务从命令行运行正常。

I have a Symfony task that generates some files calls exec to a jar and then parses the output. The jar runs fine from the command line, the task runs fine from the command line.

问题:

我在基于表单提交的操作中调用该任务。我有动作在后台启动一个新的php进程来运行任务,无论它现在生成的页面是什么。

I call the task in an action based on a form submission. I have the action start a new php process in the background to run the task regardless of what the page the spawned it does now.

当它进入java调用时,比如说exec(java -version);它输出:

When it gets to the java call, say exec(java -version); it outputs this:

Error occurred during initialization of VM
Unable to load native library: libjava.jnilib

我觉得这与我在启动任务时调用php的方式有关但我迷路了为什么它不会像我使用命令行时那样拥有相同的库。

I feel like it has to do with the way I call php when I start the task but I'm lost as to why it wouldn't have the same libraries as when I use the command line.

如何从'背景'Symfony任务中运行java?

How can I make java run from the 'background' Symfony task?

注意

在我将mamp从1.9提升之前,它曾经毫无障碍地工作。 6到2.0.3。

It used to work with no hitch until I upraded mamp from 1.9.6 to 2.0.3.

我看过:
破碎的Java Mac 10.6
但是因为我可以从命令行运行它,这似乎是一个不同的问题。

I've looked at: Broken Java Mac 10.6 but since I can run it fine from the command line it seems to be a different issue.

我还看过执行来自shell_exec()permis的symfony task命令sion拒绝了但我不认为权限是这里的问题。

I've also looked at Execute symfony task command from the shell_exec() permission denied but I don't think permissions are the issue here.

更新:

我已经将问题缩小到MAMP并从浏览器转到php。

I've narrowed down the problem to MAMP and getting to php from the browser.

<?php
echo exec("java -version")
...

从命令行调用时工作,但通过浏览器打开php文件时不工作。所以MAMP的配置方式导致问题。

Will work when called from the command line but not when the php file is opened through the browser. So the way MAMP is configured is causing the issue.

这是环境信息:


  • 变量值

  • SHELL / bin / bash

  • TMPDIR / var / folders / YH / YH + uW3hDHZyxQ5AiUtr0T ++++ TI / - Tmp - /

  • Apple_PubSub_Socket_Render / tmp / launch-3rr9ZI / Render

  • USER myuser

  • COMMAND_MODE unix2003

  • SSH_AUTH_SOCK / tmp / launch-zinaMI / Listeners

  • __ CF_USER_TEXT_ENCODING 0x1F5:0:0

  • PATH / usr / bin:/ bin:/ usr / sbin:/ sbin

  • PWD /

  • HOME / Users / myuser

  • SHLVL 2

  • DYLD_LIBRARY_PATH / Applications / MAMP / Library / lib:

  • LOGNAME myuser

  • DISPLAY /tmp/launch-FYrw70/org.x:0

  • _ / Applications / MAMP / Library / bin / httpd

  • Variable Value
  • SHELL /bin/bash
  • TMPDIR /var/folders/YH/YH+uW3hDHZyxQ5AiUtr0T++++TI/-Tmp-/
  • Apple_PubSub_Socket_Render /tmp/launch-3rr9ZI/Render
  • USER myuser
  • COMMAND_MODE unix2003
  • SSH_AUTH_SOCK /tmp/launch-zinaMI/Listeners
  • __CF_USER_TEXT_ENCODING 0x1F5:0:0
  • PATH /usr/bin:/bin:/usr/sbin:/sbin
  • PWD /
  • HOME /Users/myuser
  • SHLVL 2
  • DYLD_LIBRARY_PATH /Applications/MAMP/Library/lib:
  • LOGNAME myuser
  • DISPLAY /tmp/launch-FYrw70/org.x:0
  • _ /Applications/MAMP/Library/bin/httpd

Dyld似乎出现在这里。我需要找到一种方法来摆脱mamp的环境。

Dyld seems to be present in here. I need to find a way to unset it from mamp's environment.

解决

我找到了解决方案。这似乎是一个黑客,但它的工作原理。我会在这里发布它只是因为其他人遇到同样的问题。

I've figured out a solution. It seems like a hack but it worked. I'll post it here just incase anyone else runs into the same problem.

作为 Broken Java Mac 10.6 提到必须取消设置DYLD_LIBRARY_PATH。不知道为什么,似乎在Unix系统上需要它而不是MacOSX。

As Broken Java Mac 10.6 mentions the DYLD_LIBRARY_PATH must be unset. Not sure why, it seems to be needed on Unix systems but not MacOSX.

如果MAMP设置为/ Applications / MAMP / Library / lib,那么如何禁用它:
编辑 / Applications / MAMP / Library / bin / envvars 并注释掉以下行

If MAMP sets to /Applications/MAMP/Library/lib here's how to disable it: Edit /Applications/MAMP/Library/bin/envvars and comment out the following lines

DYLD_LIBRARY_PATH="/Applications/MAMP/Library/lib:$DYLD_LIBRARY_PATH"
export DYLD_LIBRARY_PATH

所以看起来像这样:

#DYLD_LIBRARY_PATH="/Applications/MAMP/Library/lib:$DYLD_LIBRARY_PATH"
#export DYLD_LIBRARY_PATH

这应解决问题,java 1.6可以正常运行。

This should fix the problem and java 1.6 can run fine.

这是一个黑客吗?或者这是MAMP中的错误?如果您知道解决此问题的更好方法,请回答。

Is this a hack? or is this a bug in MAMP? Please answer if you know a better way to solve this issue.

推荐答案

这是@paaat添加的解决方案。我只是张贴来从未答复的列表中提出这个问题。

This is the solution of @paaat added. Im just posting to get this question out of the unanswered list.


我找到了一个解决方案。这似乎是一个黑客,但它的工作原理。我将
发布在这里只是因为其他人遇到同样的问题。

I've figured out a solution. It seems like a hack but it worked. I'll post it here just incase anyone else runs into the same problem.

由于Broken Java Mac 10.6提到必须取消设置DYLD_LIBRARY_PATH。
不知道为什么,它似乎在Unix系统上需要而不是MacOSX。

As Broken Java Mac 10.6 mentions the DYLD_LIBRARY_PATH must be unset. Not sure why, it seems to be needed on Unix systems but not MacOSX.

如果MAMP设置为/ Applications / MAMP / Library / lib这里是如何禁用
it:编辑/应用程序/ MAMP / Library / bin / envvars并注释掉
以下行

If MAMP sets to /Applications/MAMP/Library/lib here's how to disable it: Edit /Applications/MAMP/Library/bin/envvars and comment out the following lines



DYLD_LIBRARY_PATH="/Applications/MAMP/Library/lib:$DYLD_LIBRARY_PATH"
export DYLD_LIBRARY_PATH

所以它看起来像这样:

#DYLD_LIBRARY_PATH="/Applications/MAMP/Library/lib:$DYLD_LIBRARY_PATH"
#export DYLD_LIBRARY_PATH

这应解决问题和java 1.6可以正常运行。

This should fix the problem and java 1.6 can run fine.

请务必重新启动MAMP安装,以使更改生效。

Be sure to restart your installation of MAMP for the changes to take effect.

这篇关于Java 1.6在后台Symfony任务调用时中断的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆