Re: How to configure TraxProcessor in 2.2?
gelo1234 <[email protected]> Tue, 10 Dec 2019 00:10:41 +0100
| Newsgroups | gmane.text.xml.cocoon.user |
|---|---|
| Message-ID | <CAPJaKUpAWownYyxWrWeLhNNZn3UVLyybM2r_4hNNOL3BwWVxmw@mail.gmail.com> |
--000000000000ca3bea05994d8131 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Mark, Why do you need a Custom XSLT Processor other than Saxon actually?? Saxon should do the right thing. Why wrapping it inside any "upper-level" Transformer? It's getting kinda weird. You can always add a new Java class to standard Cocoon Processors/Transformers. https://mrhaki.blogspot.com/2008/09/use-saxon-in-cocoon-22.html Greetings, Greg pon., 9 gru 2019 o 23:02 Mark H. Wood <[email protected]> napisa=C5=82(a): > On Thu, Dec 05, 2019 at 04:13:08PM +0100, Javier Puerto wrote: > > I recommend you to use the Spring configuration. I never had this > > requirement before but by the error message and the configuration > fragment > > that you have sent the NPE is caused because you are not passing an > > instance of "org.dspace.saxon.ConfigurableTransformerFactory", you are > > passing a String instead. > > > > <property name=3D'transformerFactory' > > value=3D'org.dspace.saxon.ConfigurableTransformerFactor= y'/> > > > > IIRC you should change it to: > > <property name=3D'transformerFactory'> > > <bean class=3D"org.dspace.saxon.ConfigurableTransformerFactory"/> > > </property> > > > > The attribute "value" is for literal values. You can also define the be= an > > with an ID and then use the attribute "ref" with the ID of the bean. > > I hope that helps. > > It would have made more sense for this to take a bean reference, but > the Javadoc for TraxProcessor says that setTransformerFactory() takes > a String argument. That seems to be correct: when I change it to a > reference, I get: > > 09-Dec-2019 15:12:39.128 SEVERE [localhost-startStop-24] > org.apache.catalina.cor > e.StandardContext.listenerStart Exception sending context initialized > event to l > istener instance of class > [org.springframework.web.context.ContextLoaderListener > ] > org.springframework.beans.factory.BeanCreationException: Error > creating > bean with name 'org.apache.excalibur.xml.xslt.XSLTProcessor/saxon' define= d > in Se > rvletContext resource [/WEB-INF/spring/applicationContext.xml]: > Initialization o > f bean failed; nested exception is > org.springframework.beans.ConversionNotSuppor > tedException: Failed to convert property value of type > 'org.dspace.saxon.Configu > rableTransformerFactory' to required type 'java.lang.String' for property > 'trans > formerFactory'; nested exception is java.lang.IllegalStateException: > Cannot conv > ert value of type [org.dspace.saxon.ConfigurableTransformerFactory] to > required > type [java.lang.String] for property 'transformerFactory': no matching > editors o > r conversion strategy found > > When I change it back to the literal name of the class, the > webapp. starts normally. But it still errors out when it tries to run > the XSLT transformer. > > It begins to look as though one can't really wire up TraxProcessor > using Spring. (By this I mean: using Spring's normal <bean> > <property> etc.) I'm guessing that it blows up because nothing has > called #parameterize(Parameters), because #parameterize() knows how > the properties must be set up and makes sure they are all sensible, > and thus something was left unset. > > I tried adding > > log4j.logger.org.apache.excalibur =3D DEBUG > log4j.logger.org.apache.avalon =3D DEBUG > > to our logging config. but it made no useful difference in the > output. I cannot see what paths are actually being consulted for > Cocoon component configuration, but it seems that none of the places > I've put my .xconf is one of them. > > > El mi=C3=A9., 4 dic. 2019 a las 22:46, Mark H. Wood (<[email protected]>) > escribi=C3=B3: > > > > > I'm using Cocoon 2.2. I need to pass a custom XSLT transformer > > > factory (that wraps Saxon's to configure it) to TraxProcessor, and th= e > > > advice I've found in several places around the Web doesn't seem to be > > > working: my factory class never gets instantiated. > > > > > > I've got a file META-INF/cocoon/avalon/cocoon-core-saxon-xslt.xconf: > > > > > > <?xml version=3D"1.0" encoding=3D"UTF-8"?> > > > <components> > > > <component role=3D"org.apache.excalibur.xml.xslt.XSLTProcessor/saxo= n" > > > class=3D"org.apache.cocoon.components.xslt.TraxProcessor"> > > > <parameter name=3D"use-store" value=3D"true"/> > > > <parameter name=3D"transformer-factory" > > > > value=3D"org.dspace.saxon.ConfigurableTransformerFactory"/> > > > </component> > > > </components> > > > > > > I also tried copying it to WEB-INF/cocoon and it didnt' seem to work > > > there either. > > > > > > I do have <configurator:settings/> and <avalon:bridge/> in the Spring > > > config. > > > > > > Is there some way to debug component configuration and see if the fil= e > > > is even being looked for (and where *is* configuration looking)? The > > > Cocoon site directs me to Excalibur, which directs me to Avalon, whic= h > > > says that Avalon is wound up and directs me back to Excalibur.... > > > > > > > > > > > > I've also tried to configure the thing using Spring: > > > > > > <bean name=3D'org.apache.excalibur.xml.xslt.XSLTProcessor/saxon' > > > class=3D'org.apache.cocoon.components.xslt.TraxProcessor' > > > init-method=3D'initialize' > > > destroy-method=3D'dispose'> > > > <!--property name=3D'use-store' value=3D'true'/--> > > > <property name=3D'transformerFactory' > > > > value=3D'org.dspace.saxon.ConfigurableTransformerFactory'/> > > > </bean> > > > > > > but so far I'm missing something: TraxProcessor.sourceToSAX throws a= n > > > NPE. I'm probably not setting the parameters correctly -- there isn'= t > > > a setter for use-store at all, for example. > > > > > > I've found any number of pages that tell me Avalon configuration is > > > being replaced by Spring, but nothing practical on how to convert > > > Avalon configuration (such as the first sample above) to Spring, or > > > even how to write fresh Spring configuration for Cocoon components. > > > It would be nice to know how to do this even if I wind up using the > > > Avalon approach with the present task. > > > > > > -- > > > Mark H. Wood > > > Lead Technology Analyst > > > > > > University Library > > > Indiana University - Purdue University Indianapolis > > > 755 W. Michigan Street > > > Indianapolis, IN 46202 > > > 317-274-0749 > > > www.ulib.iupui.edu > > > > > -- > Mark H. Wood > Lead Technology Analyst > > University Library > Indiana University - Purdue University Indianapolis > 755 W. Michigan Street > Indianapolis, IN 46202 > 317-274-0749 > www.ulib.iupui.edu > --000000000000ca3bea05994d8131 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable <div dir=3D"ltr"><div class=3D"gmail_default" style=3D"font-size:small">Mar= k,</div><div class=3D"gmail_default" style=3D"font-size:small"><br></div><d= iv class=3D"gmail_default" style=3D"font-size:small">Why do you need a Cust= om XSLT Processor other than Saxon actually?? Saxon should do the right thi= ng. Why wrapping it inside any "upper-level" Transformer? It'= s getting kinda weird. You can always add a new Java class to standard Coco= on Processors/Transformers. <br></div><div class=3D"gmail_default" style=3D= "font-size:small"><br></div><div class=3D"gmail_default" style=3D"font-size= :small"><a href=3D"https://mrhaki.blogspot.com/2008/09/use-saxon-in-cocoon-= 22.html">https://mrhaki.blogspot.com/2008/09/use-saxon-in-cocoon-22.html</a= ></div><div class=3D"gmail_default" style=3D"font-size:small"><br></div><di= v class=3D"gmail_default" style=3D"font-size:small">Greetings,</div><div cl= ass=3D"gmail_default" style=3D"font-size:small">Greg<br> </div><div class= =3D"gmail_default" style=3D"font-size:small"><br></div></div><br><div class= =3D"gmail_quote"><div dir=3D"ltr" class=3D"gmail_attr">pon., 9 gru 2019 o 2= 3:02=C2=A0Mark H. Wood <<a href=3D"mailto:[email protected]">[email protected]= du</a>> napisa=C5=82(a):<br></div><blockquote class=3D"gmail_quote" styl= e=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);paddin= g-left:1ex">On Thu, Dec 05, 2019 at 04:13:08PM +0100, Javier Puerto wrote:<= br> > I recommend you to use the Spring configuration. I never had this<br> > requirement before but by the error message and the configuration frag= ment<br> > that you have sent the NPE is caused because you are not passing an<br= > > instance of "org.dspace.saxon.ConfigurableTransformerFactory"= ;, you are<br> > passing a String instead.<br> > <br> > <property name=3D'transformerFactory'<br> >=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0value=3D&= #39;org.dspace.saxon.ConfigurableTransformerFactory'/><br> > <br> > IIRC you should change it to:<br> > <property name=3D'transformerFactory'><br> >=C2=A0 =C2=A0<bean class=3D"org.dspace.saxon.ConfigurableTransf= ormerFactory"/><br> > </property><br> > <br> > The attribute "value" is for literal values. You can also de= fine the bean<br> > with an ID and then use the attribute "ref" with the ID of t= he bean.<br> > I hope that helps.<br> <br> It would have made more sense for this to take a bean reference, but<br> the Javadoc for TraxProcessor says that setTransformerFactory() takes<br> a String argument.=C2=A0 That seems to be correct:=C2=A0 when I change it t= o a<br> reference, I get:<br> <br> 09-Dec-2019 15:12:39.128 SEVERE [localhost-startStop-24] org.apache.catalin= a.cor<br> e.StandardContext.listenerStart Exception sending context initialized event= to l<br> istener instance of class [org.springframework.web.context.ContextLoaderLis= tener<br> ]<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 org.springframework.beans.factory.BeanCreationE= xception: Error creating <br> bean with name 'org.apache.excalibur.xml.xslt.XSLTProcessor/saxon' = defined in Se<br> rvletContext resource [/WEB-INF/spring/applicationContext.xml]: Initializat= ion o<br> f bean failed; nested exception is org.springframework.beans.ConversionNotS= uppor<br> tedException: Failed to convert property value of type 'org.dspace.saxo= n.Configu<br> rableTransformerFactory' to required type 'java.lang.String' fo= r property 'trans<br> formerFactory'; nested exception is java.lang.IllegalStateException: Ca= nnot conv<br> ert value of type [org.dspace.saxon.ConfigurableTransformerFactory] to requ= ired <br> type [java.lang.String] for property 'transformerFactory': no match= ing editors o<br> r conversion strategy found<br> <br> When I change it back to the literal name of the class, the<br> webapp. starts normally.=C2=A0 But it still errors out when it tries to run= <br> the XSLT transformer.<br> <br> It begins to look as though one can't really wire up TraxProcessor<br> using Spring.=C2=A0 (By this I mean:=C2=A0 using Spring's normal <be= an><br> <property> etc.)=C2=A0 I'm guessing that it blows up because noth= ing has<br> called #parameterize(Parameters), because #parameterize() knows how<br> the properties must be set up and makes sure they are all sensible,<br> and thus something was left unset.<br> <br> I tried adding<br> <br> =C2=A0 log4j.logger.org.apache.excalibur =3D DEBUG<br> =C2=A0 log4j.logger.org.apache.avalon =3D DEBUG<br> <br> to our logging config. but it made no useful difference in the<br> output.=C2=A0 I cannot see what paths are actually being consulted for<br> Cocoon component configuration, but it seems that none of the places<br> I've put my .xconf is one of them.<br> <br> > El mi=C3=A9., 4 dic. 2019 a las 22:46, Mark H. Wood (<<a href=3D"ma= ilto:[email protected]" target=3D"_blank">[email protected]</a>>) escribi=C3= =B3:<br> > <br> > > I'm using Cocoon 2.2.=C2=A0 I need to pass a custom XSLT tran= sformer<br> > > factory (that wraps Saxon's to configure it) to TraxProcessor= , and the<br> > > advice I've found in several places around the Web doesn'= t seem to be<br> > > working:=C2=A0 my factory class never gets instantiated.<br> > ><br> > > I've got a file META-INF/cocoon/avalon/cocoon-core-saxon-xslt= .xconf:<br> > ><br> > > <?xml version=3D"1.0" encoding=3D"UTF-8"?&= gt;<br> > > <components><br> > >=C2=A0 =C2=A0<component role=3D"org.apache.excalibur.xml.x= slt.XSLTProcessor/saxon"<br> > >=C2=A0 =C2=A0 =C2=A0class=3D"org.apache.cocoon.components.xsl= t.TraxProcessor"><br> > >=C2=A0 =C2=A0 =C2=A0<parameter name=3D"use-store" val= ue=3D"true"/><br> > >=C2=A0 =C2=A0 =C2=A0<parameter name=3D"transformer-factory= "<br> > >=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 value=3D&q= uot;org.dspace.saxon.ConfigurableTransformerFactory"/><br> > >=C2=A0 =C2=A0</component><br> > > </components><br> > ><br> > > I also tried copying it to WEB-INF/cocoon and it didnt' seem = to work<br> > > there either.<br> > ><br> > > I do have <configurator:settings/> and <avalon:bridge/&g= t; in the Spring<br> > > config.<br> > ><br> > > Is there some way to debug component configuration and see if the= file<br> > > is even being looked for (and where *is* configuration looking)?= =C2=A0 The<br> > > Cocoon site directs me to Excalibur, which directs me to Avalon, = which<br> > > says that Avalon is wound up and directs me back to Excalibur....= <br> > ><br> > ><br> > ><br> > > I've also tried to configure the thing using Spring:<br> > ><br> > >=C2=A0 =C2=A0 =C2=A0<bean name=3D'org.apache.excalibur.xml.= xslt.XSLTProcessor/saxon'<br> > >=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0class=3D'org.apache.c= ocoon.components.xslt.TraxProcessor'<br> > >=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0init-method=3D'initia= lize'<br> > >=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0destroy-method=3D'dis= pose'><br> > >=C2=A0 =C2=A0 =C2=A0 =C2=A0<!--property name=3D'use-store&#= 39; value=3D'true'/--><br> > >=C2=A0 =C2=A0 =C2=A0 =C2=A0<property name=3D'transformerFac= tory'<br> > >=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0valu= e=3D'org.dspace.saxon.ConfigurableTransformerFactory'/><br> > >=C2=A0 =C2=A0 =C2=A0</bean><br> > ><br> > > but so far I'm missing something:=C2=A0 TraxProcessor.sourceT= oSAX throws an<br> > > NPE.=C2=A0 I'm probably not setting the parameters correctly = -- there isn't<br> > > a setter for use-store at all, for example.<br> > ><br> > > I've found any number of pages that tell me Avalon configurat= ion is<br> > > being replaced by Spring, but nothing practical on how to convert= <br> > > Avalon configuration (such as the first sample above) to Spring, = or<br> > > even how to write fresh Spring configuration for Cocoon component= s.<br> > > It would be nice to know how to do this even if I wind up using t= he<br> > > Avalon approach with the present task.<br> > ><br> > > --<br> > > Mark H. Wood<br> > > Lead Technology Analyst<br> > ><br> > > University Library<br> > > Indiana University - Purdue University Indianapolis<br> > > 755 W. Michigan Street<br> > > Indianapolis, IN 46202<br> > > 317-274-0749<br> > > <a href=3D"http://www.ulib.iupui.edu" rel=3D"noreferrer" target= =3D"_blank">www.ulib.iupui.edu</a><br> > ><br> <br> -- <br> Mark H. Wood<br> Lead Technology Analyst<br> <br> University Library<br> Indiana University - Purdue University Indianapolis<br> 755 W. Michigan Street<br> Indianapolis, IN 46202<br> 317-274-0749<br> <a href=3D"http://www.ulib.iupui.edu" rel=3D"noreferrer" target=3D"_blank">= www.ulib.iupui.edu</a><br> </blockquote></div> --000000000000ca3bea05994d8131--