File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes XML and Related Technologies and the fly likes Getting ClassCastException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Getting ClassCastException" Watch "Getting ClassCastException" New topic

Getting ClassCastException

Devarakonda Srikanth

Joined: Aug 27, 2007
Posts: 25
I am trying to replace a tag in existing jrxml file and i am successful in doing so by parsing the file through DOM. But when I am trying to write the same modified document which is in DOM object, I am getting the following exception:

java.lang.ClassCastException: org.apache.xerces.dom.DeferredElementImpl cannot be cast to com.sun.xml.tree.ElementNode
at com.Replace_Tag.replaceNode(
at com.Replace_Tag.processRequest(
at com.Replace_Tag.doGet(
at javax.servlet.http.HttpServlet.service(
at javax.servlet.http.HttpServlet.service(
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
at org.apache.catalina.core.ApplicationFilterChain.doFilter(
at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
at org.apache.catalina.core.ApplicationFilterChain.doFilter(
at org.apache.catalina.core.StandardWrapperValve.invoke(
at org.apache.catalina.core.StandardContextValve.invoke(
at org.apache.catalina.core.StandardHostValve.invoke(
at org.apache.catalina.valves.ErrorReportValve.invoke(
at org.apache.catalina.core.StandardEngineValve.invoke(
at org.apache.catalina.connector.CoyoteAdapter.service(
at org.apache.coyote.http11.Http11Processor.process(
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(

Here I am providing the code I am using:

can anybody help me in this regard??
It is sorta covered in the JavaRanch Style Guide.
subject: Getting ClassCastException
jQuery in Action, 3rd edition