Discussion:
java.lang.ClassCastException: org.apache.xml.dtm.ref.DTMManagerDefault cannot be cast to org.apache.xml.dtm.DTMManager
Matthew Broadhead
2018-07-17 00:06:58 UTC
Permalink
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().getContextClassLoader();
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.APPLICATION_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;
    // ...
}
Jean-Louis Monteiro
2018-07-17 10:46:54 UTC
Permalink
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 <
Post by Matthew Broadhead
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().getContextClassLoader();
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;
// ...
}
Matthew Broadhead
2018-07-17 11:03:22 UTC
Permalink
thanks Jean-Louis.  i tried excluding xalan maven artifact from the pom
but then FOP doesn't work.  i might try to create a reproducer using
tomee webapp archetype if possible
Post by Jean-Louis Monteiro
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 <
Post by Matthew Broadhead
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().getContextClassLoader();
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;
// ...
}
Matthew Broadhead
2018-07-17 17:35:54 UTC
Permalink
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>
Post by Jean-Louis Monteiro
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 <
Post by Matthew Broadhead
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().getContextClassLoader();
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;
// ...
}
Matthew Broadhead
2018-07-18 09:49:23 UTC
Permalink
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$$OwbNormalScopeProxy0.getXMLParse(uk/me/kissy/external/entityBeans/UtilityDao.java)
    at
uk.me.kissy.document.dao.DocumentElementDao.getBodyPDF(DocumentElementDao.java:395)
Post by Matthew Broadhead
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>
Post by Jean-Louis Monteiro
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 <
Post by Matthew Broadhead
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().getContextClassLoader();
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;
     // ...
}
Matthew Broadhead
2018-07-18 11:44:25 UTC
Permalink
ok i fixed that.  it was just a null attribute causing the problem. so
everything looks ok for now.  thanks for your help
Post by Matthew Broadhead
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
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$$OwbNormalScopeProxy0.getXMLParse(uk/me/kissy/external/entityBeans/UtilityDao.java)
    at
uk.me.kissy.document.dao.DocumentElementDao.getBodyPDF(DocumentElementDao.java:395)
Post by Matthew Broadhead
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>
Post by Jean-Louis Monteiro
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 <
Post by Matthew Broadhead
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().getContextClassLoader();
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;
     // ...
}
Jean-Louis Monteiro
2018-07-19 11:47:02 UTC
Permalink
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 <
ok i fixed that. it was just a null attribute causing the problem. so
everything looks ok for now. thanks for your help
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
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)
Post by Matthew Broadhead
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>
Post by Jean-Louis Monteiro
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 <
i have a couple of problems...
Post by Matthew Broadhead
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;
// ...
}
Matthew Broadhead
2018-07-21 09:52:36 UTC
Permalink
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.eclipse.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.eclipse.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.eclipse.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());
Post by Jean-Louis Monteiro
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 <
ok i fixed that. it was just a null attribute causing the problem. so
everything looks ok for now. thanks for your help
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
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)
Post by Matthew Broadhead
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>
Post by Jean-Louis Monteiro
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 <
i have a couple of problems...
Post by Matthew Broadhead
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;
// ...
}
Matthew Broadhead
2018-07-21 17:50:01 UTC
Permalink
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
Post by Matthew Broadhead
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.eclipse.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.eclipse.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.eclipse.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());
Post by Jean-Louis Monteiro
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 <
Post by Matthew Broadhead
ok i fixed that.  it was just a null attribute causing the problem. so
everything looks ok for now.  thanks for your help
Post by Matthew Broadhead
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
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)
Post by Matthew Broadhead
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>
Post by Jean-Louis Monteiro
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 <
i have a couple of problems...
Post by Matthew Broadhead
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)
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;
      // ...
}
Matthew Broadhead
2018-07-22 10:48:27 UTC
Permalink
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.
Post by Matthew Broadhead
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
Post by Matthew Broadhead
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.eclipse.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.eclipse.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.eclipse.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());
Post by Jean-Louis Monteiro
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 <
Post by Matthew Broadhead
ok i fixed that.  it was just a null attribute causing the problem. so
everything looks ok for now.  thanks for your help
Post by Matthew Broadhead
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
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)
Post by Matthew Broadhead
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>
Post by Jean-Louis Monteiro
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 <
i have a couple of problems...
Post by Matthew Broadhead
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)
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;
      // ...
}
Loading...