ClassCastException when trying to generate CND in Site WAR

3 views
Skip to first unread message

Marnix

unread,
Oct 24, 2017, 4:03:59 AM10/24/17
to Hippo Community
Hi,

Using the latest Hippo version, I'm trying to write some code in my site war (as part of a jaxrs endpoint) that is able to export the CND for a particular namespace. Looking at the CMS backend code, in particular the CND export button in the repository browser, I found there is a class called `org.hippoecm.repository.util.JcrCompactNodeTypeDefWriter` that sort of does what I need it to.

When I invoke the code however, I get the following exception.

[INFO] [talledLocalContainer] Caused by: java.lang.ClassCastException: org.apache.jackrabbit.core.nodetype.NodeTypeImpl cannot be cast to org.apache.jackrabbit.spi.commons.nodetype.AbstractNodeType
[INFO] [talledLocalContainer] at org.hippoecm.repository.util.JcrCompactNodeTypeDefWriter.visit(JcrCompactNodeTypeDefWriter.java:88) ~[hippo-repository-utilities-5.0.0.jar:5.0.0]
[INFO] [talledLocalContainer] at org.hippoecm.repository.util.JcrCompactNodeTypeDefWriter.getNodeTypes(JcrCompactNodeTypeDefWriter.java:65) ~[hippo-repository-utilities-5.0.0.jar:5.0.0]
[INFO] [talledLocalContainer] at org.hippoecm.repository.util.JcrCompactNodeTypeDefWriter.compactNodeTypeDef(JcrCompactNodeTypeDefWriter.java:51) ~[hippo-repository-utilities-5.0.0.jar:5.0.0]
[INFO] [talledLocalContainer] at nz.xinsolutions.packages.PartialCndExporter.toFullCnd(PartialCndExporter.java:69) ~[classes/:1.1-SNAPSHOT]
[INFO] [talledLocalContainer] at nz.xinsolutions.packages.PartialCndExporter.lambda$getFullExports$2(PartialCndExporter.java:58) ~[classes/:1.1-SNAPSHOT]


Looking at the hierarchy for these objects it seems like this should be no problem. 

Temporarily copying across and modifying the code to use NodeTypeImpl directly, I still get the error message, but saying that NodeTypeImpl can't be cast to NodeTypeImpl. To my mind, this then means it is somehow related to the ClassLoaders. 

Before I go down a potentially unnecessary rabbit-hole, is there something obvious I am missing here? Or do I somehow need to make sure these objects are in the shared library classpath?

Looking forward to your responses!

Cheers,

Marnix
Reply all
Reply to author
Forward
0 new messages