Free Support Forum - aspose.com

ClassCastException on Form Fill

Hi! We are currently evaluating the Aspose.Pdf.Kit for our java application, and so far it looks really good. It’s the first framework that does not skew/move filled form elements on flatten.

However, when we tried to deploy this in our web application we get a ClassCastException:

2008-06-13 10:23:49,232 ERROR SocketListener0-6
|com.skagenfondene.common.util.PDFUtils|[db(49::ccc48b)@default(3::1809715)
httpParametersProcess] Exception in PDF merge!<o:p></o:p>

ExceptionConverter:

java.lang.ClassCastException: org.apache.xerces.parsers.SAXParser cannot be cast to com.aspose.sax.XMLReader

at com.aspose.sax.helpers.XMLReaderFactory.createXMLReader(Unknown Source)

at com.aspose.xmlparser.tree.XmlDocument.createXmlDocument(Unknown Source)

at com.aspose.xmlparser.tree.XmlDocument.createXmlDocument(Unknown Source)

at com.aspose.pdf.kit.om.(Unknown Source)

at com.aspose.pdf.kit.pl.(Unknown Source)

at com.aspose.pdf.kit.l5.az(Unknown Source)

at com.aspose.pdf.kit.b8.else(Unknown Source)

at com.aspose.pdf.kit.Form.(Unknown Source)

at com.skagenfondene.common.util.PDFUtils.merge(PDFUtils.java:111)

at com.skagenfondene.k3s.corelets.tabs.TransDrawTab.pdfMerger(TransDrawTab.java:1874)

at com.skagenfondene.k3s.corelets.tabs.TransDrawTab.postSaveTransactions(TransDrawTab.java:1989)

at com.skagenfondene.k3s.corelets.tabs.TransactionTab.process(TransactionTab.java:454)

at com.skagenfondene.k3s.corelets.tabs.TransDrawTab.process(TransDrawTab.java:1205)

at com.corelets.util.components.Component.process(Component.java:105)

at com.skagenfondene.common.components.tab.SFWebmacroTabHolder.processActiveTab(SFWebmacroTabHolder.java:260)

at com.skagenfondene.common.components.tab.SFWebmacroTabHolder.process(SFWebmacroTabHolder.java:189)

at com.corelets.util.components.Component.process(Component.java:105)

at com.skagenfondene.k3s.corelets.K3SMainCorelet.process(K3SMainCorelet.java:1034)

at com.corelets.servlets.helpers.CoreletLifecycle.invokeProcess(CoreletLifecycle.java:279)

at com.corelets.servlets.helpers.RequestAndResponse.process(RequestAndResponse.java:125)

at com.corelets.servlets.Renderer.process(Renderer.java:162)

at com.corelets.servlets.CCS_Servlet.invokeProcessWithContext(CCS_Servlet.java:308)

at com.corelets.servlets.CCS_MasterServlet.process(CCS_MasterServlet.java:108)

at com.corelets.servlets.CCS_Servlet.service(CCS_Servlet.java:204)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)

at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:428)

at org.mortbay.jetty.servlet.WebApplicationHandler$CachedChain.doFilter(WebApplicationHandler.java:830)

at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:173)

at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:77)

at org.mortbay.jetty.servlet.WebApplicationHandler$CachedChain.doFilter(WebApplicationHandler.java:821)

at com.skagenfondene.filters.GZIPFilter.doFilter(GZIPFilter.java:35)

at org.mortbay.jetty.servlet.WebApplicationHandler$CachedChain.doFilter(WebApplicationHandler.java:821)

at com.skagenfondene.filters.AddSynchronizeTokenFilter.doFilter(AddSynchronizeTokenFilter.java:83)

at org.mortbay.jetty.servlet.WebApplicationHandler$CachedChain.doFilter(WebApplicationHandler.java:821)

at org.mortbay.jetty.servlet.WebApplicationHandler.dispatch(WebApplicationHandler.java:471)

at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:568)

at org.mortbay.http.HttpContext.handle(HttpContext.java:1530)

at org.mortbay.jetty.servlet.WebApplicationContext.handle(WebApplicationContext.java:633)

at org.mortbay.http.HttpContext.handle(HttpContext.java:1482)

at org.mortbay.http.HttpServer.service(HttpServer.java:909)

at org.mortbay.http.HttpConnection.service(HttpConnection.java:816)

at org.mortbay.http.HttpConnection.handleNext(HttpConnection.java:982)

at org.mortbay.http.HttpConnection.handle(HttpConnection.java:833)

at org.mortbay.http.SocketListener.handleConnection(SocketListener.java:244)

at org.mortbay.util.ThreadedServer.handle(ThreadedServer.java:357)

at org.mortbay.util.ThreadPool$PoolThread.run(ThreadPool.java:534)



Obviously there seems to be a conflict between the apache SAXParser and your XMLReader. Is there a way around this?

The code where the exception is thrown is:

Form form = new Form(inputFile.getPath(), outputFile.getPath());

where inputFile and outputFile are normal java.io.File objects.

Thanks!
Egil Sørensen

Dear egil,

Thanks for considering Aspose.Pdf.Kit for Java.

If not violating your privacy, would you please provide the resouces to reproduce the problem? The related source code is also expected.

Thanks & Best regards.

I’m sorry to say that I can’t provide the entire web application. I’ll attach the PDFUtils class that I’m working on. The libraries that it seems to be in conflict with are:
xerces.jar
xercesImpl.jar

The application is run on a CMS system called CorePortal with Spring/Hibernate in bottom of it.

When I run the example from Eclipse it works like a charm, but it is first when we build it and run it from the web container we get the exception.

Dear egil,

It's a pitty that the problem cannot be reproduced. We will discuss and analyze it ASAP from the Exception information and those two libraries mentioned above.

Best regards.

Hi Egil,

We made a fix in the light of the exception information since we could not reproduce the error. Please try the attachment (aspose.pdf.kit.jar v2.0.0.2) and tell us whether it works in your application or not.

Thanks,

Hi!

Thank you very much, the patched version worked like a charm in my application!

We’ll go straight to testing it further in our environment, it seems to be just the library we need.

Thanks again for great help!
Egil Sørensen