Java WS 应用程序偶尔忽略参数
我最近组装了一个 JWS 应用程序,它从动态创建的 JNLP 文件中获取参数(详细信息可以在 此处)。一切都很好,只是应用程序忽略了我的系统(linux x86_64)上的参数(在不加载指定数字的情况下启动)。然而,JWS 应用程序似乎完全符合我同事的 win_64 机器上的预期。这很有趣,因为我无法在另一个类似的 win_64 上复制他的成功。
为了让事情更令人兴奋,当我下载 JNLP 文件并在终端上通过 javaws 运行它时,同一个 JWS 应用程序运行得很好(换句话说,不会忽略参数)。
我比较了 java.policy 和 javaws.policy 文件,没有区别。 JNLP 文件清楚地给出了所有权限,并且 jar 文件都已正确签名(这不可能是问题的根源,否则应用程序将无法启动,对吧?)。
问题 1:那么这个问题可能取决于什么?
编辑:我刚刚设法从新的(在这种特殊意义上)得到了正确的回应win32机器,没有任何明显的java更新。 问题 2: 是否有 javaws 日志文件,我可以在其中检查发生了什么,或者我可以详细说明控制台的启动,以便我可以创建我自己的自定义日志?
编辑 2:顺便说一下,我忘了提及我也在 Oracle 论坛,我可能应该首先提到它,因为它在那里被礼貌地指出。不管怎样,线程上有关于 JNLP 文件的更多信息,以防相关。
编辑3:我认为问题可能源于生成JNLP文件时
标签的属性。最初的 jnlp
标签看起来像这样:
<jnlp spec="1.0+" codebase="http://mydomain/myapp/"
href="my.jnlp">
问题是代码库中声明的目录中没有 my.jnlp,而是 JNLP 代码是通过以下方式动态创建的: cgi-bin 目录中的 Perl 脚本并作为输出流返回(我认为)。所以我编辑了脚本来生成带有以下标签的JNLP:
<jnlp spec="1.0+" codebase="http://mydomain/myapp/"
href="http://mydomain/cgi-bin/my.jnlp">
这个实验的结果:这次连GUI都没有启动...... 我在 Oracle 论坛上找到了相关帖子,其中建议按以下方式定义 href
属性:
href="script.jsp?<%=request.getQueryString()%>">
不幸的是,这并不能解决我的问题。
问题3:此修改是否也适用于我的情况?那样的话怎么办?如果没有任何关于可能导致问题的原因的见解,我们将不胜感激,因为我现在的工作确实陷入了僵局
I have recently put together a JWS application which gets it's argument from a dynamically created JNLP file (details can be found here). It's all good except the application ignores the argument (starts without loading the specified number) on my system (linux x86_64). It seems however that the JWS application exactly as intended on the win_64 machine of a colleague of mine. This is rather interesting as I couldn't replicate his success on another similar win_64.
To make things more exciting, the same JWS application works just fine (in other words, doesn't ignore the argument) when I download the JNLP file and run it by javaws on the terminal.
I have compared the java.policy and javaws.policy files and there are no differences. The JNLP file clearly gives all-permissions, and the jar files are signed all fine (which can't be the source of the problem otherwise the application wouldn't start, right?).
Question 1: So what could this problem depend on?
EDIT: I just managed to get proper response from a new (in this particular sense) win32 machine, without any obvious java update. Question 2 : Is there a log file for javaws on which I can check what happens, or alternatively, can I verbose the launch to a console so I can create my own custom logs?
Edit 2: By the way, I have forgotten to mention that I have also posted this question at the Oracle forums, which I should have perhaps mentioned initially as it was politely pointed out there. Anyways, there is more information on the JNLP file there on the thread, in case it might be relevant.
Edit 3: I came to think that the problem could be originating from the properties of the <jnlp>
tag, upon generating the JNLP file. Originally the jnlp
tag looked like this like this:
<jnlp spec="1.0+" codebase="http://mydomain/myapp/"
href="my.jnlp">
The problem with this is the fact that there is no my.jnlp in the the directory declared in the codebase, instead the JNLP code is created on the fly by a Perl script in the cgi-bin directory and returned as an output stream (I think). So I edited the script to generate the JNLP with the following tag:
<jnlp spec="1.0+" codebase="http://mydomain/myapp/"
href="http://mydomain/cgi-bin/my.jnlp">
The result of this experiment: not even the GUI started this time...
I have found a relevant thread on Oracle forums, where it was advised to define the href
property in the following fashion:
href="script.jsp?<%=request.getQueryString()%>">
which unfortunately doesn't solve my problem.
Question 3: Could this modification be applicable to my situation as well? In that case how? If not any insights on what might be causing the problem would be seriously appreciated as I am really at a stalemate on my work right now
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
经过两周的 JNLP 文件语法和 CGI 脚本的研究,我想我终于找到了问题的症结所在。我在这里注意到这一点(冒着显得自命不凡的风险来回答我自己的问题)以防其他人遇到同样的问题。
在我的例子中,
标记的href
属性显然是不必要的,删除后应用程序开始在 Linux 和 Win 系统上按预期工作。我不是 100% 确定这是否是确切原因,但我的理解是,由于 jnlp 语法是从脚本生成并直接返回给用户而不是文件系统中某处的 jnlp 文件,因此href
属性指向错误的位置,可能导致某种冲突,在不同的操作系统中处理方式不同。After two weeks of wrestling with the JNLP file syntax and my CGI script, I think I finally found the crux of the problem. I am noting this down here (at the risk of looking pretentious enough to answer my own question) in case somebody else runs into the same problem.
The
href
property of the<jnlp>
tag, in my case was apparently unnecessary and when removed the application started working as intended on both linux and win systems. I am not 100% sure if this is the exact reason but my understanding is that as the jnlp syntax is generated from a script and directly returned to the user instead of a jnlp file somewhere in the filesystem, thehref
property was pointing to a wrong place and perhaps caused some sort of a clash that is handled differently in different OS.确保 JNLP 文件未缓存。即,每次尝试新的东西时,您是否重命名/重新定位了 JNLP 文件?
关于您的更新,
我想到的唯一问题是,您需要确保您的脚本以正确的 mime 类型进行响应: application/x-java-jnlp-file
也就是说,从您的 cgi 脚本中,您必须提供 HTTP 标头场地
Make sure the JNLP file is not cached. I.e., each time you try something new, have you renamed / relocated the JNLP file?
Regarding your updates,
The only ting that comes to my mind is that you need to make sure that your script responds with the correct mime type: application/x-java-jnlp-file
That is, from your cgi-script, you have to provide the HTTP header field