The method getTextContent() is undefined for the type Node
The method getTextContent() is undefined for the type Node
You can get this kind of error when your develop a system that use xml manipulation using library xml-apis. If you try to find a solution by a search in google you can find solutions like:
org.w3c.dom.Node.getTextContent() is only available as of Java 1.5
But, you are running and compile your project using Java 1.5. If yo
u are using Eclipse as IDE you can check this by right clicking on the project, Properties -> Java Compiler, and confirm that 1.5 or above are in the drop down lists. You also can see the projects facets to be sure.
Spotting the problem The method getTextContent() is undefined for the type Node in Eclipse
In the Eclipse “Problems” tab where you saw the error (one time for each coincidence in the workspace). If you don’t see that tab, go to Window -> Show View -> Problems.
The line with the problem may had the next apparence:
1 2 3 | Node node = ..... .... node.getTextContext()... |
Mouse over the capitalized word “Node” on the previous line, the yellow balloon assist should show “org.w3c.dom.Node”.
Now highlight the word Node. Right click, select Declarations -> Workspace.
In a moment a new “Search” tab should appear and report 2 declarations for org.w3c.dom.Node, in:
- classes.jar in jdk libs.
- xml-apis-1.0.b2.jar
It’s the second entry that’s causing the problem, it’s being pulled in from the contrib/extraction area, which Eclipse included but ant doesn’t.
The root cause of The method getTextContent() is undefined for the type Node
There are many jars packaged in the jdk libs and they sometimes contain the same library routines that xml-apis, but at different versions. When Eclipse created the project it tries to create a reasonable default classpath to build with, but the order matters, and in this case the list and order is different than what the ant build utility would have created.
The solution
The order of the classpath needs to be tweaked in Eclipse project; shove the xml-apis-1.0.b2.jar all the way to the bottom, past the built in JVM libraries. Probably if you use maven to deploy or package projects or ant you don´t have this problem.
¿How can i fix it in Eclipse?
Right click project, select Properties -> Java Build Path. The problem would stay with xml-apis-1.0.b2.jar and others related libraries such as xerces.
Go to Order and Export Tab, select the jdk library and click on buttom top to move it all the way up, so that have to be the first libraries to use.And it should not have a checkmark.Save the settings with the OK button and Eclipse should recompile everything, it might take it a second to wake up. But the Problems tab should now have no Errors, although still a ton of warnings. But those are a matter for another day!
——————————————————————————————-
References: http://www.enterprisesearchblog.com/2009/09/fix-for-gettextcontent-is-undefined-for-the-type-node-for-solr-project-in-eclipse-ide.htmlCategory: Others
Thanks , Buddy . Your solution was as smooth as butter 🙂
Hi indra
I am happy that could be useful for you my post.
Thx.
I believe this problem happens now and then once Java is updated! I had it a couple of times and I fixed it without knowing what I was doing. Now I know 🙂
Thanks a lot!
It works!
E.
You’re welcome, glad that was useful to you
Thanks a lot Man !
Very well expained and correctly solved my problem
Thanks a lot,Its very useful…
Hi Paco,
Thank you very much.
It helped me to compile my office app in minutes. 🙂 🙂
Great !!!
Thank you very much, Paco! It solved my problems! 🙂
I am glad to hear that
Thank you!!!
You are welcome !!
Thanx a lot. It worked great.
Thankyou very much good information. It resolved my problem in a minute
Thanks man. I was having this problem though I was using maven. I shoved down the maven dependecies behind JRE System Library. That fixed my problem.
Solved my problem. Thank you for your efforts and share this lesson.
Cheers
Simply wish to say your article is as surprising. The clearness in your post is just great and i can assume you’re an expert on this subject.
Well with your permission let me to grab your RSS feed to keep updated with forthcoming post.
Thanks a million and please continue the enjoyable work.