By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,694 Members | 1,846 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,694 IT Pros & Developers. It's quick & easy.

Xpath Problem

P: 3
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
Share this Question
Share on Google+
5 Replies


Dököll
Expert 100+
P: 2,364
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

P: 3
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

10K+
P: 13,264
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

P: 3
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

Expert 10K+
P: 11,448
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

Post your reply

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