473,395 Members | 1,653 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Xpath Problem

Hi, I am trying to parse an xml using xpath. I dont have any problem when i try it as a standalone java application, but when I try the same code with in a servlet I am getting the below error. Can any one help me please. I need a solution ASAP.

SRVE0026E: [Servlet Error]-[javax/xml/xpath/XPathFactory]: java.lang.NoClassDefFoundError: javax/xml/xpath/XPathFactory
at com.ibm.cod.event.hitsReport.process(hitsReport.ja va(Compiled Code))
at com.ibm.cod.controller.servlet.GenerateHitExcel.pr ocess(GenerateHitExcel.java:82)
at com.ibm.cod.controller.servlet.GenerateHitExcel.do Post(GenerateHitExcel.java:32)
at com.ibm.cod.controller.servlet.GenerateHitExcel.do Get(GenerateHitExcel.java:27)
at javax.servlet.http.HttpServlet.service(HttpServlet .java:740)
at javax.servlet.http.HttpServlet.service(HttpServlet .java:853)
at com.ibm.ws.webcontainer.servlet.StrictServletInsta nce.doService(StrictServletInstance.java:110)
at com.ibm.ws.webcontainer.servlet.StrictLifecycleSer vlet._service(StrictLifecycleServlet.java:174)
at com.ibm.ws.webcontainer.servlet.IdleServletState.s ervice(StrictLifecycleServlet.java:313)
at com.ibm.ws.webcontainer.servlet.StrictLifecycleSer vlet.service(StrictLifecycleServlet.java:116)
at com.ibm.ws.webcontainer.servlet.ServletInstance.se rvice(ServletInstance.java:283)
at com.ibm.ws.webcontainer.servlet.ValidServletRefere nceState.dispatch(ValidServletReferenceState.java: 42)
at com.ibm.ws.webcontainer.servlet.ServletInstanceRef erence.dispatch(ServletInstanceReference.java:40)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispat cher.handleWebAppDispatch(WebAppRequestDispatcher. java:948)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispat cher.dispatch(WebAppRequestDispatcher.java:530)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispat cher.forward(WebAppRequestDispatcher.java:176)
at com.ibm.ws.webcontainer.srt.WebAppInvoker.doForwar d(WebAppInvoker.java:79)
at com.ibm.ws.webcontainer.srt.WebAppInvoker.handleIn vocationHook(WebAppInvoker.java:201)
at com.ibm.ws.webcontainer.cache.invocation.CachedInv ocation.handleInvocation(CachedInvocation.java:71)
at com.ibm.ws.webcontainer.cache.invocation.Cacheable InvocationContext.invoke(CacheableInvocationContex t.java:114)
at com.ibm.ws.webcontainer.srp.ServletRequestProcesso r.dispatchByURI(ServletRequestProcessor.java:186)
at com.ibm.ws.webcontainer.oselistener.OSEListenerDis patcher.service(OSEListener.java:334)
at com.ibm.ws.webcontainer.http.HttpConnection.handle Request(HttpConnection.java:56)
at com.ibm.ws.http.HttpConnection.readAndHandleReques t(HttpConnection.java:610)
at com.ibm.ws.http.HttpConnection.run(HttpConnection. java:431)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.j ava(Compiled Code))



Thanks in advance...
Jan 3 '08 #1
5 3552
Dököll
2,364 Expert 2GB
Hi, I am trying to parse an xml using xpath. I dont have any problem when i try it as a standalone java application...
Thanks in advance...
Hello, srinivasareddynr!

Are you able to go through the code in debug mode, if so, can you point out the line the occurs?

Sorry for your troubles by the way...

Dököll
Jan 5 '08 #2
Hi,

Thanks for the reply and below is the code I am using.....

DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance();
domFactory.setNamespaceAware(true); // never forget this!
DocumentBuilder builder = domFactory.newDocumentBuilder();
Document doc = builder.parse(AdvisorXmlPath);
System.out.println(doc.getElementsByTagName("rec") .getLength());
XPathFactory factory = XPathFactory.newInstance();
XPath xpath = factory.newXPath();
String expr = "English/rec[@id='" + rs1.getInt("hit_id") + "']";
Object result = xpath.evaluate(expr, doc, XPathConstants.NODE);
Node nodes = (Node) result;
hit_name = nodes.getAttributes().getNamedItem("name").getNode Value();

And when i try to run this code, it stopes at....

XPathFactory factory = XPathFactory.newInstance();
Can you please help me solve the problem... Thanks....




Hello, srinivasareddynr!

Are you able to go through the code in debug mode, if so, can you point out the line the occurs?

Sorry for your troubles by the way...

Dököll
Jan 7 '08 #3
r035198x
13,262 8TB
Hi,

Thanks for the reply and below is the code I am using.....

DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance();
domFactory.setNamespaceAware(true); // never forget this!
DocumentBuilder builder = domFactory.newDocumentBuilder();
Document doc = builder.parse(AdvisorXmlPath);
System.out.println(doc.getElementsByTagName("rec") .getLength());
XPathFactory factory = XPathFactory.newInstance();
XPath xpath = factory.newXPath();
String expr = "English/rec[@id='" + rs1.getInt("hit_id") + "']";
Object result = xpath.evaluate(expr, doc, XPathConstants.NODE);
Node nodes = (Node) result;
hit_name = nodes.getAttributes().getNamedItem("name").getNode Value();

And when i try to run this code, it stopes at....

XPathFactory factory = XPathFactory.newInstance();
Can you please help me solve the problem... Thanks....
NoClassDef is a missing class issue. Either you do not have the package that contains the javax/xml/xpath/XPathFactory class or it's not added to the project's classpath.
Jan 7 '08 #4
Thanks for the reply, but i have a different problem here.... when I try the same code in a standalone java application it is working but when I use the same code in a servlet is throws the above error.... Thanks....

NoClassDef is a missing class issue. Either you do not have the package that contains the javax/xml/xpath/XPathFactory class or it's not added to the project's classpath.
Jan 24 '08 #5
JosAH
11,448 Expert 8TB
Thanks for the reply, but i have a different problem here.... when I try the same code in a standalone java application it is working but when I use the same code in a servlet is throws the above error.... Thanks....
You don't have a different problem: if your stand alone application can run that
class it means that the jvm can find the class. The jvm that runs your servlet
can't find that class so you should fix that, i.e. stick the corresponding jar where
it belongs in the context of the jvm that runs your servlets. IOW, it's a class and/or
classpath problem just as the other poster pointed out.

kind regards,

Jos
Jan 24 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: gael.pegliasco | last post by:
Hi, How are you dear and nice helper :) ? I'm trying to test xpath with this simple program : import xml.dom.minidom from xml.xpath.Context import Context import xml.xpath
6
by: Ramon M. Felciano | last post by:
Helo all -- I'm trying to gain a deeper understand for what type of semi-declarative programming can be done through XML and XPath/XSLT. I'm looking at graph processing problems as a testbed for...
1
by: Murtaza Tinwala | last post by:
Hi mates, I have the following problem in XSLT. I have following variables: ref-file = <path of XML document> eg "xmlDoc.xml" repeatpath = <a repeat path expressed in Xpath like /root/person >...
4
by: Son KwonNam | last post by:
In XSLT, is this possible to get value from xml using XPath which is in XSLT variable? I mean XPath strings can be dynamic while XSL Transforming. If possible, How?? Because I'm not a...
3
by: Kathy Burke | last post by:
Hi again, I'm using the following xpath (works in visualizer) with a SelectSingleNode("xpath") statement. //Station/(WI])]/@order Problem is I get an error "expression passed to this method...
3
by: muscha | last post by:
Hi All, I have this weird problem. I have an xml document and tried to do an XPath query to it. If I use the SelectSingleNode method it throws an exception but it works with SelectNodes method....
2
by: ree32 | last post by:
When I import an xml document in Visual studio and Genereate as schema from it, and create a dataset from it, it adds this line into to the root element of my xml file -...
3
by: abcd_68 | last post by:
Hi there, I'm using, for the first time, the JDK1.5 Xpath API. I need to find elements in a Hibernate-generated .hbm.xml file. These files come with a <!DOCTYPE header mentioning a remote URL....
6
by: J.Marsch | last post by:
I must be completely losing my mind. I have some code that writes to config files. It works great with app.config files, but fails miserably with web.config files. For the life of me, I cannot...
5
by: jorgedelgadolopez | last post by:
Hi all, I am using the xpathnavigator evaluate function on .net (xpath 1 right?). Now I need to expand the code to do multiple contains, compare dates (such as 'before', 'between' and 'after'),...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.