Page 1 of 1

Error Running FOP

Posted: Tue May 23, 2006 12:21 pm
by ananth.india@gmail.com
Hi,
I'm using trying to convert a set of FO files to PDF using Java. And i'm using the FOP.jar file for the same, since i have only the Jar, i have to call the Fop class's main() method by passing the appropriate args. then i'm running the java class in a batch script on an AIX machine with Java 1.3.

Code: Select all


public class Sample{
[...]
public static void createPDF(String fo,String pdf){
String []args = new String[4];
args[0] = "-fo";
args[1] = fo;
args[2] = "-pdf";
args[3] = pdf;
[color=red]Fop.main(args);[/color]
}
}
The method

Code: Select all

createPDF()
is called within a loop inwhich the FO and PDF names are passed as arguments.
When i run the batch script, It runs perfectly fine, producing the desired result.

The problem arises when i use the same java class in a Web Application on IBM WSAD 5.1on Windows XP Test environment(The target system is AIX). I pass the args to the

Code: Select all

createPDF()
method from a servlet. An exception is encountered:

java.util.ConcurrentModificationException: concurrent access to HashMap attempted by Thread[Servlet.Engine.Transports : 0,5,main]
[color]

Here's the complete Stacktrace:

Code: Select all


java.util.ConcurrentModificationException: concurrent access to HashMap attempted by Thread[Servlet.Engine.Transports : 2,5,main]
at java.util.HashMap.onExit(HashMap.java(Inlined Compiled Code))
at java.util.HashMap.rehash(HashMap.java(Inlined Compiled Code))
at java.util.HashMap.put(HashMap.java(Compiled Code))
at org.krysalis.barcode4j.fop0205.BarcodeElementMapping.setupBarcodeElements(BarcodeElementMapping.java:63)
at org.krysalis.barcode4j.fop0205.BarcodeElementMapping.addToBuilder(BarcodeElementMapping.java:69)
at org.apache.fop.apps.Driver.addElementMapping(Driver.java:439)
at org.apache.fop.apps.Driver.addElementMapping(Driver.java:450)
at org.apache.fop.apps.Driver.setupDefaultMappings(Driver.java:324)
at org.apache.fop.apps.Driver.<init>(Driver.java:222)
at org.apache.fop.apps.CommandLineStarter.run(CommandLineStarter.java:92)
at org.apache.fop.apps.Fop.main(Fop.java:62)
at com.phl.wm.as.perform.util.XML2FO.createPdf(XML2FO.java:250)
at com.phl.wm.as.perform.web.SubAcctActionServlet.generate(SubAcctActionServlet.java:172)
at com.phl.wm.as.perform.web.SubAcctActionServlet.doPost(SubAcctActionServlet.java:49)
at javax.servlet.http.HttpServlet.service(HttpServlet.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:948)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.dispatch(WebAppRequestDispatcher.java:530)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:176)
at com.ibm.ws.webcontainer.srt.WebAppInvoker.doForward(WebAppInvoker.java:79)
at com.ibm.ws.webcontainer.srt.WebAppInvoker.handleInvocationHook(WebAppInvoker.java:201)
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:610)
at com.ibm.ws.http.HttpConnection.run(HttpConnection.java:431)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:593)
It happens only when i run it from the web. There's absolutely no problem when i run the batch script. Can anybody tell me on why this is happening? Also, All the Print Statements sent to the Console through the java code is being displayed twice, one after the other in succession.

Also is there any alternate method by which the Fop Utility can be called?

Please Advice.

Thank you,
-- Ananth