Using Xpath in Dom4j

后端 未结 5 974
悲哀的现实
悲哀的现实 2021-02-12 12:22

I get the following exception when trying to access any nodes of a parsed xml document on dom4j:

Exception in thread \"main\" java.lang.NoClassDefFoundError: or         


        
5条回答
  •  暗喜
    暗喜 (楼主)
    2021-02-12 12:46

    A java.lang.NoClassDefFoundError is thrown by the JVM when a dependency that was available at the time a particular class was compiled cannot be found on the classpath when the class is loaded for use by the JVM.

    How are you invoking the parser code? Check and make sure that all the DOM4J dependencies in the lib folder of the DOM4J distribution (jaxen, jaxme-api etc) are on the classpath.

    If you are invoking the parser from the command line you can use the -classpath option:

    java -classpath C:\myjars\jar1.jar;C:\myjars\jar1.jar
    

    If you are invoking the parser from Ant for example use the tag:

      
          
        
     
    

    Your xpath expressions are not even being evaluated so you should stoptweaking those until you have sorted out your classpath issues.

提交回复
热议问题