Free Support Forum - aspose.com

Problem with websphere (possibly IBM JDK)

This one is a weird problem. I don’t actually think it’s necessarily a problem with Aspose, but wondered if anyone had come across it and/or found a workaround…

One of our installations requires us to deploy our application on WebSphere 5 on Windows which seems to have a weird interaction with Aspose Slides and which seems to boil down to its use of ByteArrayInputStream in some way.

When cloning a slide for instance, we get the following exception:

com.aspose.slides.PptEditException: Slide cloning error.
at com.aspose.slides.Presentation.cloneSlide(SourceFile:1480)
at org.apache.jsp._ralf._jspService(_ralf.java(Compiled Code))
at com.ibm.ws.webcontainer.jsp.runtime.HttpJspBase.service(HttpJspBase.java:89)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.ibm.ws.webcontainer.jsp.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:344)
at com.ibm.ws.webcontainer.jsp.servlet.JspServlet.serviceJspFile(JspServlet.java:662)
at com.ibm.ws.webcontainer.jsp.servlet.JspServlet.service(JspServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.ibm.ws.webcontainer.servlet.StrictServletInstance.doService(StrictServletInstance.java:110)
at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet._service(StrictLifecycleServlet.java:174)
at com.ibm.ws.webcontainer.servlet.IdleServletState.service(StrictLifecycleServlet.java:313)
at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet.service(StrictLifecycleServlet.java:116)
at com.ibm.ws.webcontainer.servlet.ServletInstance.service(ServletInstance.java:283)
at com.ibm.ws.webcontainer.servlet.ValidServletReferenceState.dispatch(ValidServletReferenceState.java:42)
at com.ibm.ws.webcontainer.servlet.ServletInstanceReference.dispatch(ServletInstanceReference.java:40)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.handleWebAppDispatch(WebAppRequestDispatcher.java:974)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.dispatch(WebAppRequestDispatcher.java:555)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:200)
at com.ibm.ws.webcontainer.srt.WebAppInvoker.doForward(WebAppInvoker.java:119)
at com.ibm.ws.webcontainer.srt.WebAppInvoker.handleInvocationHook(WebAppInvoker.java:276)
at com.ibm.ws.webcontainer.cache.invocation.CachedInvocation.handleInvocation(CachedInvocation.java:71)
at com.ibm.ws.webcontainer.srp.ServletRequestProcessor.dispatchByURI(ServletRequestProcessor.java:182)
at com.ibm.ws.webcontainer.oselistener.OSEListenerDispatcher.service(OSEListener.java:334)
at com.ibm.ws.webcontainer.http.HttpConnection.handleRequest(HttpConnection.java:56)
at com.ibm.ws.http.HttpConnection.readAndHandleRequest(HttpConnection.java:618)
at com.ibm.ws.http.HttpConnection.run(HttpConnection.java:439)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:593)
Caused by: java.lang.ArrayIndexOutOfBoundsException: 92
at java.io.ByteArrayInputStream.read(ByteArrayInputStream.java(Inlined Compiled Code))
at com.aspose.slides.aP.do(SourceFile(Compiled Code))
at com.aspose.slides.aP.do(SourceFile:57)
at com.aspose.slides.dS.(SourceFile:43)
at com.aspose.slides.eo.(SourceFile:38)
at com.aspose.slides.aP.(SourceFile:45)
at com.aspose.slides.bB.do(SourceFile:19)
at com.aspose.slides.aS.do(SourceFile(Compiled Code))
at com.aspose.slides.ag.do(SourceFile(Inlined Compiled Code))
at com.aspose.slides.dn.do(SourceFile(Compiled Code))
at com.aspose.slides.ci.do(SourceFile:82)
at com.aspose.slides.aS.do(SourceFile(Compiled Code))
at com.aspose.slides.ag.do(SourceFile(Inlined Compiled Code))
at com.aspose.slides.dn.do(SourceFile(Compiled Code))
at com.aspose.slides.ci.do(SourceFile:82)
at com.aspose.slides.aS.do(SourceFile(Compiled Code))
at com.aspose.slides.ag.do(SourceFile(Inlined Compiled Code))
at com.aspose.slides.dn.do(SourceFile(Compiled Code))
at com.aspose.slides.ci.do(SourceFile:82)
at com.aspose.slides.aS.do(SourceFile(Compiled Code))
at com.aspose.slides.ag.do(SourceFile(Inlined Compiled Code))
at com.aspose.slides.dn.do(SourceFile(Compiled Code))
at com.aspose.slides.ci.do(SourceFile:82)
at com.aspose.slides.aS.do(SourceFile(Compiled Code))
at com.aspose.slides.ag.do(SourceFile:23)
at com.aspose.slides.eD.do(SourceFile:34)
at com.aspose.slides.dS.(SourceFile(Inlined Compiled Code))
at com.aspose.slides.eo.(SourceFile(Inlined Compiled Code))
at com.aspose.slides.eD.(SourceFile(Inlined Compiled Code))
at com.aspose.slides.an.do(SourceFile(Compiled Code))
at com.aspose.slides.an.do(SourceFile:51)
at com.aspose.slides.an.do(SourceFile:38)
at com.aspose.slides.Z.do(SourceFile:79)
at com.aspose.slides.dS.(SourceFile:43)
at com.aspose.slides.eo.(SourceFile:38)
at com.aspose.slides.Z.(SourceFile:56)
at com.aspose.slides.Slide.do(SourceFile:564)
at com.aspose.slides.Presentation.do(SourceFile:1322)
at com.aspose.slides.Presentation.cloneSlide(SourceFile:1467)
… 26 more

every subsequent attempt to load a presentation results in this error:

com.aspose.slides.PptReadException: Couldn’t read “PowerPoint Document” record.
at com.aspose.slides.Presentation.do(SourceFile:278)
at com.aspose.slides.Presentation.(SourceFile:568)
at org.apache.jsp._ralf._jspService(_ralf.java(Compiled Code))
at com.ibm.ws.webcontainer.jsp.runtime.HttpJspBase.service(HttpJspBase.java:89)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.ibm.ws.webcontainer.jsp.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:344)
at com.ibm.ws.webcontainer.jsp.servlet.JspServlet.serviceJspFile(JspServlet.java:662)
at com.ibm.ws.webcontainer.jsp.servlet.JspServlet.service(JspServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.ibm.ws.webcontainer.servlet.StrictServletInstance.doService(StrictServletInstance.java:110)
at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet._service(StrictLifecycleServlet.java:174)
at com.ibm.ws.webcontainer.servlet.IdleServletState.service(StrictLifecycleServlet.java:313)
at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet.service(StrictLifecycleServlet.java:116)
at com.ibm.ws.webcontainer.servlet.ServletInstance.service(ServletInstance.java:283)
at com.ibm.ws.webcontainer.servlet.ValidServletReferenceState.dispatch(ValidServletReferenceState.java:42)
at com.ibm.ws.webcontainer.servlet.ServletInstanceReference.dispatch(ServletInstanceReference.java:40)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.handleWebAppDispatch(WebAppRequestDispatcher.java:974)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.dispatch(WebAppRequestDispatcher.java:555)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:200)
at com.ibm.ws.webcontainer.srt.WebAppInvoker.doForward(WebAppInvoker.java:119)
at com.ibm.ws.webcontainer.srt.WebAppInvoker.handleInvocationHook(WebAppInvoker.java:276)
at com.ibm.ws.webcontainer.cache.invocation.CachedInvocation.handleInvocation(CachedInvocation.java:71)
at com.ibm.ws.webcontainer.cache.invocation.CacheableInvocationContext.invoke(CacheableInvocationContext.java:114)
at com.ibm.ws.webcontainer.srp.ServletRequestProcessor.dispatchByURI(ServletRequestProcessor.java:186)
at com.ibm.ws.webcontainer.oselistener.OSEListenerDispatcher.service(OSEListener.java:334)
at com.ibm.ws.webcontainer.http.HttpConnection.handleRequest(HttpConnection.java:56)
at com.ibm.ws.http.HttpConnection.readAndHandleRequest(HttpConnection.java:618)
at com.ibm.ws.http.HttpConnection.run(HttpConnection.java:439)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:593)
Caused by: java.lang.ArrayIndexOutOfBoundsException: 8
at java.io.ByteArrayInputStream.read(ByteArrayInputStream.java(Inlined Compiled Code))
at com.aspose.slides.aP.do(SourceFile(Compiled Code))
at com.aspose.slides.aP.do(SourceFile:57)
at com.aspose.slides.dS.(SourceFile(Inlined Compiled Code))
at com.aspose.slides.eo.(SourceFile(Inlined Compiled Code))
at com.aspose.slides.aP.(SourceFile(Inlined Compiled Code))
at com.aspose.slides.an.do(SourceFile(Compiled Code))
at com.aspose.slides.an.do(SourceFile:51)
at com.aspose.slides.an.do(SourceFile:38)
at com.aspose.slides.eo.do(SourceFile(Inlined Compiled Code))
at com.aspose.slides.dS.(SourceFile(Inlined Compiled Code))
at com.aspose.slides.eo.(SourceFile(Inlined Compiled Code))
at com.aspose.slides.et.(SourceFile(Inlined Compiled Code))
at com.aspose.slides.an.do(SourceFile(Compiled Code))
at com.aspose.slides.an.do(SourceFile:51)
at com.aspose.slides.Presentation.do(SourceFile:173)
… 28 more

This problem doesn’t occur with Tomcat (running on a Sun JRE) so it’s kind of hard to track down. I’m going to attempt to see if I can extract the JRE from websphere and test against that.

Other than that, I’m running out of ideas.

Done some more investigating and this JRE (shipped with Websphere) causes the problem:

java version "1.4.1"
Java™ 2 Runtime Environment, Standard Edition (build 1.4.1)
Classic VM (build 1.4.1, J2RE 1.4.1 IBM Windows 32 build cn1411-20031011 (JIT enabled: jitc))

and this one works fine:

java version "1.4.2_08"
Java™ 2 Runtime Environment, Standard Edition (build 1.4.2_08-b03)
Java HotSpot™ Client VM (build 1.4.2_08-b03, mixed mode)

This is the test code:

public static void main(String[] args) {
try {
InputStream inputStream = new FileInputStream(“D:\dev\code\branches\inexus_3-1b_branch\i-nexus\web\WEB-INF\project_context_template.ppt”);

Presentation presentation = new Presentation(inputStream);

Presentation newPresentation = new Presentation();
TreeMap idList = new TreeMap();
int firstNewSlidePosition = 1;
int lastPos = presentation.getSlides().getLastSlidePosition();
for (int i = 1; i <= lastPos; i++) {
Slide slide = presentation.getSlideByPosition(i);
Slide newSlide = presentation.cloneSlide(slide, firstNewSlidePosition++, newPresentation, idList);
}

ByteArrayOutputStream baos2 = new ByteArrayOutputStream();
newPresentation.write(baos2);

System.out.println(“All is good…”);
} catch (Exception e) {
System.out.println("Caught exception: " + e.getMessage());
e.printStackTrace(System.out);
}
}

I’m not sure but it looks like a bug in IBM Jit compiler.
Could you try to turn it off and test again?

May be it’s a good idea to update IBM jre.
I successfully tested Aspose.Slides with IBM jdk 5.0.

Further to that, I can confirm that I’ve got it to work on their 5.0 JDK (available with the Eclipse download), although the latest supported IBM JDK 1.4.2 I could find seems not to work. The versions I tested are:

(fails) java version "1.4.2"
Java™ 2 Runtime Environment, Standard Edition (build 1.4.2)
Classic VM (build 1.4.2, J2RE 1.4.2 IBM Windows 32 build cn142-20060421 (SR5) (JIT enabled: jitc))

(works) java version "1.5.0"
Java™ 2 Runtime Environment, Standard Edition (build pwi32pdev-20060919a (SR3))
IBM J9 VM (build 2.3, J2RE 1.5.0 IBM J9 2.3 Windows XP x86-32 j9vmwi3223-20060919 (JIT enabled)
J9VM - 20060915_08260_lHdSMR
JIT - 20060908_1811_r8
GC - 20060906_AA)
JCL - 20060919

So, probably unless Websphere 5 can use JDK 5.0 or Sun’s JDK, it looks like we’re out of luck… :frowning:

Also the JIT idea looks likely. With IBM JDK 1.4.1 and 1.4.2 there is no option to disable the JIT completely, although the -Xquickstart option prevents compilation for a short while and that too appears to work…

In theory I can try to recompile Aspose.Slides with IBM JDK 1.4.1 or 1.4.2 and publish it.
There is only one problem, I couldn’t find download link for 1.4 jdk (Win32) on IBM site…

The JDK is tough to track down! I found it in several levels deep of a JAR file for a WS JDK fixpack. I’m not sure recompiling with the IBM JDK will help, as it seems to be the inlining of compiled code within the JVM that actually causes the problem.

Possibly it’s a problem that relates to the obfuscating system you use, but I have a solution against testing the JDK from a DOS window that seems to work, so I’ll test that against WebSphere when the test server is available.

The workaround seems to be to a variety of hacks to disable inlining the compiled code either by disabling that option completely or disabling compilation of the problem method. Any of these environment variable settings seem to fix the problem:

To disable compiling the affected method:
JITC_COMPILEOPT=SKIP{java/io/ByteArrayInputStream}{read}

To disable method inlining:
JITC_COMPILEOPT=NINLINING

To disable intermediate code optimizations:
JITC_COMPILEOPT=NQOPTIMIZE

To disable both global and method-local optimizations:
JITC_COMPILEOPT=NALL

The reason I suspect the code obfustcator is that this method is being inlined into the Aspose method:

Caused by: java.lang.ArrayIndexOutOfBoundsException: 126
at java.io.ByteArrayInputStream.read(ByteArrayInputStream.java(Inlined Compiled Code))
at com.aspose.slides.aP.do(SourceFile(Compiled Code))
at com.aspose.slides.aP.do(SourceFile:57)
at com.aspose.slides.dS.(SourceFile:43)

although I’m guessing you are only allowed to released obfuscated versions of the library. I’ll feed back on whether this work around works when applied to WebSphere as this should be an adequate solution for our customer if so.

All shrinking and optimizations are turned off in the obfuscator so it can’t inline any classes or functions.
I think all these compilations and inlining made by jit compiler. Although I will try to update obfuscator.

I changed obfuscator. Could you test it please with websphere.
http://www.aspose.com/Products/Aspose.Slides/Releases/aspose.slides.zip
There are 2 versions. aspose.slides.jar - optimized
aspose.slides.no.jar - without any optimizations