You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-dev@xmlgraphics.apache.org by Andreas Schröder <as...@web.de> on 2008/05/05 10:55:58 UTC
think I found a bug
Hello,
I already posted in the user group, but they only wonder about my error and can't help. So I think that it is a bug.
I use Apache FOP 0.95beta but the same error also occured in 0.94 stable version: When trying to make a new instance of the fop factory with "FopFactory fopFactory = FopFactory.newInstance();" I get an exception with the following stack trace:
java.lang.ClassCastException: org.apache.fop.render.afp.extensions.AFPExtensionHandlerFactory
cannot be cast to org.apache.fop.util.ContentHandlerFactory
at org.apache.fop.util.ContentHandlerFactoryRegistry.discover(ContentHandlerFactoryRegistry.java:105)
at org.apache.fop.util.ContentHandlerFactoryRegistry.<init>(ContentHandlerFactoryRegistry.java:47)
at org.apache.fop.apps.FopFactory.<init>(FopFactory.java:76)
at org.apache.fop.apps.FopFactory.newInstance(FopFactory.java:166)
at de.hc.pdf_from_word.PdfCreator.convertXML2PDF(PdfCreator.java:44)
at de.hc.pdf_from_word.CorrespondenceCase.createCorrespondence(CorrespondenceCase.java:81)
at de.hc.pdf_from_word.CorrespondenceCase.makeCorrespondence(CorrespondenceCase.java:64)
at de.hc.pdf_from_word.CorrespondenceCase.initiate(CorrespondenceCase.java:113)
at org.apache.jsp.Anmeld_L3_2211_jsp._jspService(Anmeld_L3_2211_jsp.java:524)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:137)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:210)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2422)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:171)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:163)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:199)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:828)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:700)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:584)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
at java.lang.Thread.run(Thread.java:619)
In the user group they told me they assume that I use different versions of fop at thte same time but in my classpath and container I only use one fop.jar at the time.
Please excuse me, if this doesn't fit in this group. I would be happy about a hint.
Andreas Schröder
_________________________________________________________________________
In 5 Schritten zur eigenen Homepage. Jetzt Domain sichern und gestalten!
Nur 3,99 EUR/Monat! http://www.maildomain.web.de/?mc=021114
Re: think I found a bug
Posted by Andreas Delmelle <an...@telenet.be>.
On May 5, 2008, at 16:55, Andreas Delmelle wrote:
> On May 5, 2008, at 10:55, Andreas Schröder wrote:
>
>> I already posted in the user group, but they only wonder about my
>> error and can't help. So I think that it is a bug.
>>
>> I use Apache FOP 0.95beta but the same error also occured in 0.94
>> stable version: When trying to make a new instance of the fop
>> factory with "FopFactory fopFactory = FopFactory.newInstance();" I
>> get an exception with the following stack trace:
>>
>>
>> java.lang.ClassCastException:
>> org.apache.fop.render.afp.extensions.AFPExtensionHandlerFactory
>> cannot be cast to org.apache.fop.util.ContentHandlerFactory
<snip />
FWIW, and for all interested parties: Andreas confirmed to me off-
list that using only one FopFactory seems to work. So far, he hasn't
taken that back, so I'm assuming no news is good news. ;-)
This shows that using only one factory is not merely a matter of
'best practice', it avoids ugly exceptions like the one above.
Of course, Big thanks to Jörg for supplying us with the vital piece
of info!
Cheers
Andreas
Re: think I found a bug
Posted by Andreas Delmelle <an...@telenet.be>.
On May 5, 2008, at 10:55, Andreas Schröder wrote:
Hi
> I already posted in the user group, but they only wonder about my
> error and can't help. So I think that it is a bug.
>
> I use Apache FOP 0.95beta but the same error also occured in 0.94
> stable version: When trying to make a new instance of the fop
> factory with "FopFactory fopFactory = FopFactory.newInstance();" I
> get an exception with the following stack trace:
>
>
> java.lang.ClassCastException:
> org.apache.fop.render.afp.extensions.AFPExtensionHandlerFactory
> cannot be cast to org.apache.fop.util.ContentHandlerFactory
I dug up the earlier thread on fop-users@, and I suspect that Jörg's
reply is the one that holds the key.
<quote>
In a web application, this may also be happen if the
AFPExtensionHandlerFactory has been loaded in a different
security context , which means it is an implementation of
the ContentHandlerFactory of the other context.
</quote>
From the stack trace, we can deduce that you create a new fopFactory
instance for each run ('newInstance()' always means 'new FopFactory
();').
The original ContentHandlerFactory class has probably already been
loaded when the servlet container first initialized, by the default
ClassLoader (or by the ClassLoader used in the first run).
No idea how this can be verified, though. To ascertain whether this
is the case, my personal first shot would be to try to set up a
central fopFactory instance, which would also be loaded only once,
when the webapp is first initialized. The big difference would be
that you'd use that very same FopFactory for all the requests, which
should eliminate the issue...
HTH!
Andreas