5

I have upgraded my J2EE web application from jdk6,tomcat6 to jdk7 and tomcat7 but while deploying teamcity is giving following error.

[xmltask] java.lang.NoClassDefFoundError: org/apache/xpath/XPathAPI

java.lang.NoClassDefFoundError: org/apache/xpath/XPathAPI
                at com.oopsconsultancy.xmltask.jdk14.XPathAnalyser14.analyse(XPathAnalyser14.java:29)
                at com.oopsconsultancy.xmltask.XmlReplace.apply(XmlReplace.java:72)
                at com.oopsconsultancy.xmltask.XmlReplacement.apply(XmlReplacement.java:61)
                at com.oopsconsultancy.xmltask.ant.XmlTask.processDoc(XmlTask.java:707)
                at com.oopsconsultancy.xmltask.ant.XmlTask.execute(XmlTask.java:676)
                at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
                at org.apache.tools.ant.Task.perform(Task.java:364)
                at org.apache.tools.ant.Target.execute(Target.java:341)
                at org.apache.tools.ant.Target.performTasks(Target.java:369)
                at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216)
                at org.apache.tools.ant.helper.SingleCheckExecutor.executeTargets(SingleCheckExecutor.java:37)
                at org.apache.tools.ant.Project.executeTargets(Project.java:1068)
                at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:382)
                at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
                at org.apache.tools.ant.Task.perform(Task.java:364)
                at org.apache.tools.ant.Target.execute(Target.java:341)
                at org.apache.tools.ant.Target.performTasks(Target.java:369)
                at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216)
                at org.apache.tools.ant.Project.executeTarget(Project.java:1185)
                at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:40)
                at org.apache.tools.ant.Project.executeTargets(Project.java:1068)
                at org.apache.tools.ant.Main.runBuild(Main.java:668)
                at org.apache.tools.ant.Main.startAnt(Main.java:187)
                at org.apache.tools.ant.launch.Launcher.run(Launcher.java:246)
                at org.apache.tools.ant.launch.Launcher.main(Launcher.java:67)
Caused by: java.lang.ClassNotFoundException: org.apache.xpath.XPathAPI
                at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
                at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
                at java.security.AccessController.doPrivileged(Native Method)
                at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
                at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
                at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
                ... 25 more
4
  • XPathAPI isn't in your classpath Commented May 1, 2014 at 10:17
  • sorry but what does xpathAPI is? plz tell me so that i can add it Commented May 1, 2014 at 10:44
  • @mark o'connor this is not duplicate(i already added xalan-2.7.1.jar but issue not resolved) Commented May 2, 2014 at 5:17
  • Clearly it's not in the classpath. Xalan contains this class, see: search.maven.org/… Commented May 2, 2014 at 10:13

8 Answers 8

4

The missing class is contained in xalan-2.7.0 (See Maven central). So I think the problem is how your classpath has been set.

Considering that this appears to be an error reported by the xmltask task, does this mean the error is being thrown by ANT?

Google found the following example which might be the answer to your problems:

Add the xalan jar to the classpath of your taskdef:

<taskdef name="xmltask" classname="com.oopsconsultancy.xmltask.ant.XmlTask">
  <classpath>
    <pathelement path="${common.lib.dir}/xmltask-1.15.1.jar" />
    <pathelement path="${common.lib.dir}/xalan-2.7.1.jar"/>
  </classpath>
</taskdef>
Sign up to request clarification or add additional context in comments.

1 Comment

I already have these entries in classpath, wondering what is wrong here
3

if using maven add this to your dependencies section:

<dependency>
    <groupId>xalan</groupId>
    <artifactId>xalan</artifactId>
    <version>2.7.0</version>
</dependency>

Comments

0

I am not sure but, i guess jar named xalan-2.4.0.jar is missing please download it and place inside.

http://www.java2s.com/Code/Jar/x/Downloadxalan240jar.htm

3 Comments

It already have xalan-2.7.0.jar
i think version matters
I agree but here I don't think so(with all due respect)
0

Add xpath to your classpath and try the deploy again. If you are not sure which xpath jar you need search in the tomcat libraries folder for xpathapi jar

Xpathapi is a jar used for evaluating xpaths (related to xml) in java. if you are not sure which version you need, google for it and fetch the latest xpath api jar .

1 Comment

I tried this option but it not helping me.
0

For now I just remove from my build.xml, and its working. I know its not a solution but we have to deliver.

Comments

0

In Build.xml, change the java version to 1.7 and classpath XMLTask from 1.15.1 to 1.16.1.. It works

Comments

0

You should remove import org.apache.xpath.operations.String;.

Comments

0

This is how I solved this, inlcuding Xalan and Serializer

  1. Download xalan-j2-2.7.0.jar & serializer-2.7.0.jar

  2. Update build.xml to include these jars in path

    <taskdef name="xmltask" classname="com.oopsconsultancy.xmltask.ant.XmlTask">
        <classpath>
            <pathelement location="../xmltask-v1.14.jar"/>
            <pathelement path="../xalan-j2-2.7.0.jar"/>
            <pathelement path="../serializer-2.7.0.jar"/>
        </classpath>
    </taskdef>
    

This should get it running.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.