【问题标题】:PHP JavaBridge Not Finding Java Classes Ubuntu 12.0.4 Precise PHP 5.3 Tomcat7PHP JavaBridge 找不到 Java 类 Ubuntu 12.0.4 Precise PHP 5.3 Tomcat7
【发布时间】:2014-03-14 18:33:59
【问题描述】:

我下载了 JavaBridge.war 文件并将其压缩到我的 Apache www 文件夹内名为“JavaBridge”的文件夹中。所以路径将是:

http://myhost.com/JavaBridge/

所有“hello.php”和“test.php”或“excel.php”都包含在该文件夹的根目录中。一世。即: http://myhost.com/JavaBridge/index.php

PHP 正在工作,因为如果我转到该路径,phpinfo() 函数会显示我的 PHP 配置。问题是 Java 类没有被拾取。

Apache、Tomcat7 和 Java 都在运行。我已经安装了默认的 jdk。

java -version
java version "1.6.0_30"
OpenJDK Runtime Environment (IcedTea6 1.13.1) (6b30-1.13.1-1ubuntu2~0.12.04.1)
OpenJDK 64-Bit Server VM (build 23.25-b01, mixed mode)

当我访问该目录中的 hello.php 文件时,Apache 日志显示如下:

[error] [client myhost] PHP Notice:  Undefined index: language in /var/www/JavaBridge/hello.php on line 11

这是这个文件的内容:

<?php header("Content-type: text/html; charset=UTF-8"); ?>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<title>Hello</title>
<body>
<TABLE border='1'>
<tr>
<th>English</th>
<th><?php
 $lang=$_GET['language'];
 if(!isset($lang)) $lang="cs_CZ";
 echo $lang?>
</th>
</tr>
<tr>
<td>Hello</td>
<td>
<?php
if(!function_exists("bindtextdomain")) die("function bindtextdomain not found. Please       install language support, see http://php.net for details");
bindtextdomain("hello", "./locale");
textdomain("hello");
setlocale(LC_ALL, $lang);
echo _("hello");
?>
</td>
</tr>
</TABLE>
<form>
<p>
<select name='language'>
<option value="cs_CZ">cs_CZ (Czech)</option>
<option value="de_DE">de_DE (German)</option>
<option value="he_IL">he_IL (Hebrew)</option>
<option value="ja_JP">ja_JP (Japanese)</option>
</select>
<p>
<input type="submit" default="cs_CZ" value="Update"></input>
</form>
</body>
</html>

按照一些教程中的建议,在将 JavaBridge.war 压缩到 /usr/share/tomcat7/lib 之后,我已经从 WEB-INF 放置了 3 个库文件。

我已经按照其他教程中的建议在 /etc/tomcat7/web.xml 中添加了一个 webapp 配置。

有人能解释一下为什么让 JavaBridge 工作如此困难以及该怎么做吗?

【问题讨论】:

  • 能否将您从 Apache 日志中看到的错误也包括在内。
  • 是否存在:[error] [client myhost] PHP 注意:未定义索引:第 11 行 /var/www/JavaBridge/hello.php 中的语言
  • 你真的请求.../hello.php?language=blah吗?如果不是,您为什么认为$_GET['language'] 会被定义?
  • 没有。我请求myhost.com/JavaBridge/hello.php。在该页面中,有一个包含预定义语言的下拉列表可供选择。我不需要在查询字符串中请求语言。它应该工作。如果 PHP 会找到定义它的 Java 类路径,它就会被定义,但它不是。

标签: java php class tomcat php-java-bridge


【解决方案1】:

正如 Carsten 所说,“如果您的查询字符串中没有 language=SOMETHING,$lang=$_GET['language']; 会发出通知”。

附:尽量不要留下未回答的问题。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-02-15
    • 2012-03-21
    • 2013-07-28
    • 2015-04-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多