[prev in list] [next in list] [prev in thread] [next in thread]
List: openejb-user
Subject: Re: java.lang.ClassCastException: org.apache.xml.dtm.ref.DTMManagerDefault cannot be cast to
From: Matthew Broadhead <matthew.broadhead () nbmlaw ! co ! uk ! INVALID>
Date: 2018-07-22 10:48:27
Message-ID: 3b1c917d-e42a-e9ee-e9a9-2084651f444e () nbmlaw ! co ! uk
[Download RAW message or body]
ok it seems i can pass a ResourceBundle into the Transformer using
ResourceBundle resourceBundle = ResourceBundle.getBundle("test.messages");
Map<String, Object> parameters = new HashMap<String, Object>();
TransformerFactory transformerfactory = TransformerFactory.newInstance();
...
Templates templates = transformerfactory.newTemplates(ssXsl);
Transformer transformer = templates.newTransformer();
...
transformer.setParameter("resources", resourceBundle);
and declare it in xslt using
<xsl:param name="resources" />
this was broken back in 2016 but seems to work now. the reproducer
still demonstrates the overall problem.
On 21/07/18 19:50, Matthew Broadhead wrote:
> i have created a reproducer at
> https://github.com/chongma/xsltProblem
>
> there are 2 directories
> xslt704excluded
> xslt704included
>
> if you run from each
> mvn clean package tomee:run
>
> then navigate to
> http://localhost:8080/rest/open/test1
> http://localhost:8080/rest/open/test2
>
> you can see in the output when it fails like
> file:/home/matthew/git/xsltProblem/xslt704excluded/target/apache-tomee/webapps/ROOT/WEB-INF/classes/xslt/test2.xsl; \
> Line #7; Column #66; java.util.MissingResourceException: Can't find
> bundle for base name test.messages, locale en_GB
>
> it only fails when excluding xalan and xml-apis
>
> On 21/07/18 11:52, Matthew Broadhead wrote:
> > hmmm...actually i have realised what the problem is now.
> >
> > before excluding xalan and xml-apis in XSLT i can load a bundle from
> > the classpath without problem. for example
> > <xsl:variable name="resources"
> > select="java:util.ResourceBundle.getBundle('uk.me.kissy.document.messages')"
> > />
> > <xsl:value-of select="java:getString($resources,'documentBuilder2')" />
> >
> > after excluding them from the classpath i get these errors
> > file:/home/matthew/eclipse-workspaces/case-management/.metadata/.plugins/org.eclip \
> > se.wst.server.core/tmp0/wtpwebapps/document/WEB-INF/classes/documentXslt/documentBuilder.xsl; \
> > Line #6; Column #82; java.util.MissingResourceException: Can't find
> > bundle for base name uk.me.kissy.document.messages, locale en_GB
> > file:/home/matthew/eclipse-workspaces/case-management/.metadata/.plugins/org.eclip \
> > se.wst.server.core/tmp0/wtpwebapps/document/WEB-INF/classes/documentXslt/documentBuilder.xsl; \
> > Line #122; Column #61; Unknown error in XPath.
> > file:/home/matthew/eclipse-workspaces/case-management/.metadata/.plugins/org.eclip \
> > se.wst.server.core/tmp0/wtpwebapps/document/WEB-INF/classes/documentXslt/documentBuilder.xsl; \
> > Line #54; Column #54; java.lang.NullPointerException
> >
> > i have tried manually setting the classLoader without any success
> > TransformerFactory transformerfactory = TransformerFactory.newInstance(
> > "org.apache.xalan.processor.TransformerFactoryImpl",
> > this.getClass().getClassLoader());
> >
> > On 19/07/18 13:47, Jean-Louis Monteiro wrote:
> > > Great!
> > > Thanks for the follow up
> > >
> > > --
> > > Jean-Louis Monteiro
> > > http://twitter.com/jlouismonteiro
> > > http://www.tomitribe.com
> > >
> > > On Wed, Jul 18, 2018 at 1:44 PM, Matthew Broadhead <
> > > matthew.broadhead@nbmlaw.co.uk.invalid> wrote:
> > >
> > > > ok i fixed that. it was just a null attribute causing the problem. so
> > > > everything looks ok for now. thanks for your help
> > > >
> > > >
> > > > On 18/07/18 11:49, Matthew Broadhead wrote:
> > > >
> > > > > i have the problem now. this is the exception i get if i exclude
> > > > > xalan
> > > > > from fop. i have no idea what might cause this
> > > > >
> > > > > javax.xml.transform.TransformerException:
> > > > > java.lang.ArrayIndexOutOfBoundsException:
> > > > > 0 >= 0
> > > > > at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl
> > > > > .transform(TransformerImpl.java:737)
> > > > > at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl
> > > > > .transform(TransformerImpl.java:343)
> > > > > at uk.me.kissy.external.entityBeans.UtilityDao.getXMLParse(
> > > > > UtilityDao.java:191)
> > > > > at uk.me.kissy.external.entityBeans.UtilityDao$$OwbNormalScopeP
> > > > > roxy0.getXMLParse(uk/me/kissy/external/entityBeans/UtilityDao.java)
> > > > > at uk.me.kissy.document.dao.DocumentElementDao.getBodyPDF(Docum
> > > > > entElementDao.java:395)
> > > > >
> > > > > On 17/07/18 19:35, Matthew Broadhead wrote:
> > > > >
> > > > > > i have upgraded from fop 2.2 to 2.3 and excluded xalan and xml-apis
> > > > > > again. it seems to be working ok at the moment on my development
> > > > > > machine.
> > > > > > i will try again on production
> > > > > >
> > > > > > <dependency>
> > > > > > <groupId>org.apache.xmlgraphics</groupId>
> > > > > > <artifactId>fop</artifactId>
> > > > > > <version>${fop.version}</version>
> > > > > > <exclusions>
> > > > > > <exclusion>
> > > > > > <groupId>xalan</groupId>
> > > > > > <artifactId>xalan</artifactId>
> > > > > > </exclusion>
> > > > > > <exclusion>
> > > > > > <groupId>xml-apis</groupId>
> > > > > > <artifactId>xml-apis-ext</artifactId>
> > > > > > </exclusion>
> > > > > > <exclusion>
> > > > > > <groupId>xml-apis</groupId>
> > > > > > <artifactId>xml-apis</artifactId>
> > > > > > </exclusion>
> > > > > > </exclusions>
> > > > > > </dependency>
> > > > > > <dependency>
> > > > > > <groupId>org.docx4j</groupId>
> > > > > > <artifactId>docx4j</artifactId>
> > > > > > <version>${docx4j.version}</version>
> > > > > > <exclusions>
> > > > > > <exclusion>
> > > > > > <groupId>xalan</groupId>
> > > > > > <artifactId>xalan</artifactId>
> > > > > > </exclusion>
> > > > > > </exclusions>
> > > > > > </dependency>
> > > > > >
> > > > > > On 17/07/18 12:46, Jean-Louis Monteiro wrote:
> > > > > >
> > > > > > > This usually indicates you have the same class loaded into 2
> > > > > > > different
> > > > > > > classloaders which makes them different.
> > > > > > > In this scenario, I would check if you don't have duplicate
> > > > > > > xalan jars
> > > > > > > in
> > > > > > > tomee/lib and in the WEB-INF/lib of your application.
> > > > > > >
> > > > > > > Hope it helps
> > > > > > >
> > > > > > > --
> > > > > > > Jean-Louis Monteiro
> > > > > > > http://twitter.com/jlouismonteiro
> > > > > > > http://www.tomitribe.com
> > > > > > >
> > > > > > > On Tue, Jul 17, 2018 at 2:06 AM, Matthew Broadhead <
> > > > > > > matthew.broadhead@nbmlaw.co.uk.invalid> wrote:
> > > > > > >
> > > > > > > i have a couple of problems...
> > > > > > > > i have not been able to upgrade from TomEE 7.0.3 to 7.0.4 or
> > > > > > > > 7.0.5 due
> > > > > > > > to
> > > > > > > > the error (it works fine in 7.0.3)
> > > > > > > > java.lang.ClassCastException:
> > > > > > > > org.apache.xml.dtm.ref.DTMManagerDefault
> > > > > > > > cannot be cast to org.apache.xml.dtm.DTMManager
> > > > > > > >
> > > > > > > > which occurs when i run the following code for Apache FOP
> > > > > > > > ClassLoader classLoader = Thread.currentThread().getCont
> > > > > > > > extClassLoader();
> > > > > > > > URL filepath = classLoader.getResource(xslPath);
> > > > > > > > Reader xsl = new InputStreamReader(filepath.openStream());
> > > > > > > > TransformerFactory transformerfactory =
> > > > > > > > TransformerFactory.newInstance
> > > > > > > > ();
> > > > > > > > StreamSource ssXsl = new StreamSource(xsl);
> > > > > > > > Templates templates = transformerfactory.newTemplates(ssXsl);
> > > > > > > > Transformer transformer = templates.newTransformer();
> > > > > > > > StringReader reader = new StringReader(xml);
> > > > > > > > StringWriter writer = new StringWriter();
> > > > > > > > transformer.transform(new StreamSource(reader), new
> > > > > > > > StreamResult(writer));
> > > > > > > > out = writer.toString();
> > > > > > > > writer.close();
> > > > > > > > reader.close();
> > > > > > > >
> > > > > > > > My new problem is that I am using 7.0.5 in development and this
> > > > > > > > code
> > > > > > > > (using a CXF webClient) works perfectly.
> > > > > > > > Collection<? extends Integer> leadids =
> > > > > > > > webClient.accept(MediaType.APP
> > > > > > > > LICATION_JSON).getCollection(Integer.class);
> > > > > > > > List<Integer> leadids_ = new ArrayList<>(leadids);
> > > > > > > >
> > > > > > > > But when I deployed it to 7.0.3 it does not work. Is there any
> > > > > > > > way to
> > > > > > > > slurp some JSON formatted like this
> > > > > > > > [1,2,3,4]
> > > > > > > >
> > > > > > > > I tried creating a wrapper like below but it didn't match
> > > > > > > > public class listWrapper {
> > > > > > > > private List<Integer> list;
> > > > > > > > // ...
> > > > > > > > }
> > > > > > > >
> > > > > > > >
> >
>
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic