具有 RPGLE 界面的 iSeries JAVA 程序在处理图像时崩溃

发布于 2024-11-18 00:19:38 字数 1494 浏览 4 评论 0原文

我制作了一个基于 GnuPdf 创建 PDF 文件的 java 程序。当使用本机 java 代码(在 Windows 或 iSeries QSH 上)运行时,它可以完美运行,但是,当通过 RPGLE 界面运行时,程序会在处理图像时崩溃(看起来像是随机间隔)。我找到了其中之一,从 .jar 文件加载图像,并从代码中删除了调用。它工作了一段时间,但现在从 IFS 加载图像时崩溃了。也许 RPGLE 以某种方式锁定文件,有什么想法吗?该代码是从服务程序调用的。

这是堆栈跟踪

java.lang.NullPointerException
    at gnu.jpdf.PDFImage.write(PDFImage.java:286)
    at gnu.jpdf.PDFOutput.write(PDFOutput.java:114)
    at gnu.jpdf.PDFDocument.write(PDFDocument.java:307)
    at gnu.jpdf.PDFJob.end(PDFJob.java:182)
    at com.mysite.pdf.PdfDocumentStateValid.endDocument(PdfDocumentStateValid.java:657)
    at com.mysite.pdf.PdfDocument.endDocument(PdfDocument.java:36)
java.io.IOException: Descriptor not valid.
    at java.lang.Throwable.<init>(Throwable.java:196)
    at java.lang.Exception.<init>(Exception.java:41)
    at java.io.IOException.<init>(IOException.java:40)
    at java.io.FileOutputStream.writeBytes(Native Method)
    at java.io.FileOutputStream.write(FileOutputStream.java:260)
    at java.io.ByteArrayOutputStream.writeTo(ByteArrayOutputStream.java:112)
    at gnu.jpdf.PDFOutput.<init>(PDFOutput.java:96)
    at gnu.jpdf.PDFDocument.write(PDFDocument.java:302)
    at gnu.jpdf.PDFJob.end(PDFJob.java:182)
    at java.awt.PrintJob.finalize(PrintJob.java:60)
    at java.lang.ref.Finalizer.runFinalizer(Finalizer.java:116)
    at java.lang.ref.Finalizer.access$100(Finalizer.java:47)
    at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:193)

I have made a java program that creates PDF files based to GnuPdf. It runs perfectly when run using native java code (on windows or iSeries QSH), however, when run through an RPGLE interface, the program crashes (at what seems like random intervals) when processing images. I tracked down one of these down to loading an image from a .jar file and removed the call from the code. It worked for a while but is now crashing for images loaded from IFS. Maybe RPGLE is locking the files somehow, and ideas? The code is called from a Service Program.

Here is the stacktrace

java.lang.NullPointerException
    at gnu.jpdf.PDFImage.write(PDFImage.java:286)
    at gnu.jpdf.PDFOutput.write(PDFOutput.java:114)
    at gnu.jpdf.PDFDocument.write(PDFDocument.java:307)
    at gnu.jpdf.PDFJob.end(PDFJob.java:182)
    at com.mysite.pdf.PdfDocumentStateValid.endDocument(PdfDocumentStateValid.java:657)
    at com.mysite.pdf.PdfDocument.endDocument(PdfDocument.java:36)
java.io.IOException: Descriptor not valid.
    at java.lang.Throwable.<init>(Throwable.java:196)
    at java.lang.Exception.<init>(Exception.java:41)
    at java.io.IOException.<init>(IOException.java:40)
    at java.io.FileOutputStream.writeBytes(Native Method)
    at java.io.FileOutputStream.write(FileOutputStream.java:260)
    at java.io.ByteArrayOutputStream.writeTo(ByteArrayOutputStream.java:112)
    at gnu.jpdf.PDFOutput.<init>(PDFOutput.java:96)
    at gnu.jpdf.PDFDocument.write(PDFDocument.java:302)
    at gnu.jpdf.PDFJob.end(PDFJob.java:182)
    at java.awt.PrintJob.finalize(PrintJob.java:60)
    at java.lang.ref.Finalizer.runFinalizer(Finalizer.java:116)
    at java.lang.ref.Finalizer.access$100(Finalizer.java:47)
    at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:193)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

独夜无伴 2024-11-25 00:19:38

现在我可以看到堆栈跟踪了,在这里更改我的答案。当您点击本机代码时(本机意味着您基本上是在深入了解操作系统级别或操作系统自定义代码),就会出现问题。

您收到 Descriptor not valid 的 IOException(我假设它指的是文件描述符(即 FileDescriptor)。现在在 QShell 中运行它和从 RPG 运行它之间的最大区别在于从 RPG 调用的 Java 代码可能会在不同的 ID 和/或权限级别下调用。您可能需要对程序进行修改,以授予 Java 执行其所需操作的正确权限(我知道您会认为这是这样)。某事Java 中的 SecurityManager 会接受...但我知道当您在自定义操作系统(i5/OS)上使用自定义 JVM(例如 IBM 的)时,有时会发生奇怪的事情,您只能听从供应商的摆布。尝试一下(权限问题),看看是否能解决您的问题。

另外...我用 google 搜索了一下,发现这与 iSeries 相关:https://www-304.ibm.com/support/docview.wss?uid=nas379538999e744aad1862575b0006e28ab
因此,操作系统使用的 jt400 库可能存在缺陷,您可能也需要对其和/或 JVM 进行 PTF。只是又想到了一些要尝试的事情。

Changing my answer here now that I can see the stack trace. The problem happens when you hit native code (native meaning you are basically drilling into OS level or OS custom code).

You are getting an IOException of Descriptor not valid (and by that I'm assuming it means the file descriptor (ie, FileDescriptor). Now the big difference between running it in QShell and running it from RPG is that the Java code invoked from RPG is probably invoked under a different ID and/or privilege level. You may have to make modifications to the iSeries to your program to grant it authority for Java to have the right authorities to do what it needs. (I know you would think that is something the SecurityManager in Java would have picked up...but I know wierd things can happens sometimes when you are using a custom JVM (read IBM's) on a custom OS (i5/OS). You are left to the mercy of the vendor (in this case IBM). Give that a shot (the permissions thing) and see if that solves your problem.

Also...I googled and just found this related to iSeries: https://www-304.ibm.com/support/docview.wss?uid=nas379538999e744aad1862575b0006e28ab
So it might be that the jt400 library used by the OS may have a flaw and you may need to PTF it and/or your JVM too. Just another thought of something to try.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文