com.sun.org.apache.xerces.internal.dom.DocumentImpl cannot be cast to org.codehaus.plexus.util.xml.X
- by Random
Afetr using the Model library (see this) for my Maven pom.xml during this weeks I jumped on this error while attempting to write a ConfiguratonContainer into the pom.xml.
The javadoc for Model says:
public void setConfiguration(Object configuration)
Set the configuration as DOM object.
Parameters:
configuration -
So I made some xml with Document (org.w3c.dom.Document) and the xml parser standar javax library. You know the code (it's through all the net) but I paste it here...
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder parser = factory.newDocumentBuilder();
Document doc =parser.newDocument();
And then you fill the code with Element declaration,a lot of appendChild and such.
And tried to make it work. Doesn't seem to do well.
First tried using
plugin.setConfiguration(doc);
But it didn't work.
Then I tried
Obejct obj = doc;
plugin.setConfiguration(obj);
But it didn't work.
Then I searched the net for answers, and guess...
It didn't work.
There are like 0 people using this library (maven.model) in all the net. So here am I again, asking the senseis for help.
Where is my error? I have downloaded the source code of the library trying to see where is the error, but it seems to be ok (as should).
I add the stackrace for reference
java.lang.ClassCastException: com.sun.org.apache.xerces.internal.dom.DocumentImpl cannot be cast to org.codehaus.plexus.util.xml.Xpp3Dom
at org.apache.maven.model.io.xpp3.MavenXpp3Writer.writePlugin(MavenXpp3Writer.java:1472)
at org.apache.maven.model.io.xpp3.MavenXpp3Writer.writeBuild(MavenXpp3Writer.java:326)
at org.apache.maven.model.io.xpp3.MavenXpp3Writer.writeModel(MavenXpp3Writer.java:1093)
at org.apache.maven.model.io.xpp3.MavenXpp3Writer.write(MavenXpp3Writer.java:102)
at com.mapfre.mutua.PDA.model.GeneratePOM.createPOM(GeneratePOM.java:28)
at com.mapfre.mutua.PDA.prueba.MavenPOM.generatePOMWAR(MavenPOM.java:681)
at com.mapfre.mutua.PDA.prueba.GenerarPOMMapfreAction.execute(GenerarPOMMapfreAction.java:36)
at org.apache.struts.chain.commands.servlet.ExecuteAction.execute(ExecuteAction.java:58)
at org.apache.struts.chain.commands.AbstractExecuteAction.execute(AbstractExecuteAction.java:67)
at org.apache.struts.chain.commands.ActionCommandBase.execute(ActionCommandBase.java:51)
at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:191)
at org.apache.commons.chain.generic.LookupCommand.execute(LookupCommand.java:305)
at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:191)
at org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:283)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:462)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:647)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:172)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:873)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
at java.lang.Thread.run(Unknown Source)