• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

XML Parser issue

 
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,
Actually I am getting the following exception while using org.apache.xerces.dom.DocumentImpl.adoptNode(),
this method is not able to understand by the application running on WSAD / WebSphere 4.0
The Exception is:
2bc8b7 ExceptionUtil X CNTR0020E: Non-application exception occurred while processing method respondToRq on bean BeanId(BP#BPEJB.jar#FdpsXMLRqMgr, null): java.lang.NoSuchMethodError: org.apache.xerces.dom.DocumentImpl: method adoptNode(Lorg/w3c/dom/Node V not found
java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
com.ibm.ejs.container.UncheckedException: ; nested exception is:
java.lang.NoSuchMethodError: org.apache.xerces.dom.DocumentImpl: method adoptNode(Lorg/w3c/dom/Node V not found
com.ibm.ejs.container.UncheckedException: ; nested exception is:
java.lang.NoSuchMethodError: org.apache.xerces.dom.DocumentImpl: method adoptNode(Lorg/w3c/dom/Node V not found
java.lang.NoSuchMethodError: org.apache.xerces.dom.DocumentImpl: method adoptNode(Lorg/w3c/dom/Node V not found
[Friday, November 22, 2002 5:35:33 PM EST]
If anyone have the solution, please let me know as soon as possible.
Thanks,
Shanmugam.
shanmugam.muthukumarasamy@prudential.com
shankumaran@yahoo.com
 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Shanmugam,
You have probably compiled your code using a different version of Xerces than the one installed in your application server.
Cheers
 
Shanmugam Muthukumarasamy
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Beno�t d'Oncieu

Thanks for your immediate reply. Actually this applcation is running fine in VAJ environment with the IBMParser.jar. This Jar file is having the org.apache.xerces.dom.DocumentImpl class.
But now I am trying to migrate this application to WSAD. In WSAD, runtime library, this is having different jar file (Xerces.jar). This Jar file is also having same package Structure. So what I did is I removed the Xerces.jar from the Runtime library and added IBMParser.jar and I tried. For that case also it is failing at adoptNode() method. And I tried to include the Xerces.jar which is coming along with WSAD in the runtime library and application library. Still I am getting the same problem. I don't know why it is ..? I am really confused and I don't know how to proceed with.
Please have a look on the the following code and if you have any suggestion please tell me.

org.apache.xerces.dom.DocumentImpl xmlDoc=(org.apache.xerces.dom.DocumentImpl)this.iO_OriginalXMLDoc;
xmlDoc.adoptNode((Node)vO_newElement);
//xmlDoc.appendChild((Node)vO_newElement);
//Node tmpNode = xmlDoc.importNode((Node)vO_newElement,true);
Node tmpNode=this.iO_CurrentNode.insertBefore(vO_newElement,vO_refElement);
if (vb_MoveToChild) {
this.iO_CurrentNode = tmpNode;
}

The Exception is:
ExceptionUtil X CNTR0020E: Non-application exception occurred while processing method respondToRq on bean BeanId(BP#BPEJB.jar#FdpsXMLRqMgr, null): java.lang.NoSuchMethodError: org.apache.xerces.dom.DocumentImpl: method adoptNode(Lorg/w3c/dom/Node V not found
java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
com.ibm.ejs.container.UncheckedException: ; nested exception is:
java.lang.NoSuchMethodError: org.apache.xerces.dom.DocumentImpl: method adoptNode(Lorg/w3c/dom/Node V not found
com.ibm.ejs.container.UncheckedException: ; nested exception is:
java.lang.NoSuchMethodError: org.apache.xerces.dom.DocumentImpl: method adoptNode(Lorg/w3c/dom/Node V not found
java.lang.NoSuchMethodError: org.apache.xerces.dom.DocumentImpl: method adoptNode(Lorg/w3c/dom/Node V not found
The place it is getting failed in the above code is:
xmlDoc.apoptNode(Node)
Thanks,
Shanmugam.
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You should be able to get away with it by using the importNode() method instead of the adoptNode() as importNode() is a public method of the org.w3c.dom.Document interface it does not use any implementation class. This should work with any Xercers version.
Try to avoid using internals (implementation classes) as often as you can, to avoid these kind of problems. Your code will be more portable accross implementation vendors and versions.
Using only standard APIs like DOM, SAX, JAXP and TraX (eventually JDOM), you should be able to do every kind if XML manipulation without having to resort to using internal API. Only do this in last resort or for performance reasons (and add relevant javadoc when you do this) or when you want to experiment.
Best regards
 
Shanmugam Muthukumarasamy
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Beno�t d'Oncieu,
Thank you very much for your reply. As per your suggestion, I got out of that Exception made by adoptNode() method. Now my application working fine with importNode() method. But still it is failing at insertBefore() method. Can you tell me what is the purpose of boolean parameter in the importNode() method. When we have to send "true" and when we have to send "false".
The code :
org.apache.xerces.dom.DocumentImpl xmlDoc=(org.apache.xerces.dom.DocumentImpl)this.iO_OriginalXMLDoc;
//xmlDoc.adoptNode((Node)vO_newElement);
//xmlDoc.appendChild((Node)vO_newElement);
/*Node tmpNode = */xmlDoc.importNode((Node)vO_newElement,true);
Node tmpNode=this.iO_CurrentNode.insertBefore(vO_newElement,vO_refElement);
if (vb_MoveToChild) {
this.iO_CurrentNode = tmpNode;
}
Exception:
org.w3c.dom.DOMException: DOM005 Wrong document
org.w3c.dom.DOMException: DOM005 Wrong document
do you have any idea..?
Once again thanks for your help.
regards,
Shanmugam.
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You would have found it by yourself by looking at the javadocs
Anyway, assuming that you are being a firewall that only let you access the javaranch web site, I'll give you some help
The importNode method takes two parameters. The first one is the node to import, the second one should be set to true when you want a deep copy (all descendant nodes as well). In extremely rare situations, you could want to only copy the node without any children, and that's when to use false.
This method returns a new node that has your document as owner. You can then integrate the node in your document.
So, for your code to work, you will have to use this return value (I have simplified your code as well):

Cheers
 
Shanmugam Muthukumarasamy
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Beno�t d'Oncieu,
Thank you very much for your help.
regards,
Shanmugam.
 
Where all the women are strong, all the men are good looking and all the tiny ads are above average:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic