Search code examples
javaxmlnosuchmethoderror

"Exception in thread "main" java.lang.NoSuchMethodError "


I was in execution of a java program in order to extract XML files.I received this Run Time Exception when i ran my java program. Please Suggest

During Compilation

This is the compile time error which i got

" GenerateInvoice.java:57: package com.ociweb.xml does not exist import com.ociweb.xml.Version; ^ GenerateInvoice.java:58: package com.ociweb.xml does not exist import com.ociweb.xml.WAX; ^ GenerateInvoice.java:69: package com.ociweb.xml does not exist import com.ociweb.xml.WAX; ^ GenerateInvoice.java:73: cannot resolve symbol symbol : class WAX location: class GenerateInvoice WAX waxDoc = null; ^ GenerateInvoice.java:453: cannot resolve symbol symbol : class WAX location: class GenerateInvoice waxDoc = new WAX("/u01/Output/report/gen_xml/work/" + DIR_NAME + "/" + file_name + "_invoice.xml", Version.V1_0); ^ GenerateInvoice.java:453: cannot resolve symbol symbol : variable Version location: class GenerateInvoice waxDoc = new WAX("/u01/Output/report/gen_xml/work/" + DIR_NAME + "/" + file_name + "_invoice.xml", Version.V1_0); "

Then i added a package "wax14_1.0.4.jar". After Running :

Exception in thread "main" java.lang.NoSuchMethodError: 
    java.util.regex.Pattern.quote(Ljava/lang/String;)Ljava/lang/String;
        at com.ociweb.xml.XMLUtil.<clinit>(XMLUtil.java:83)
        at com.ociweb.xml.ElementMetadata.buildQualifiedName(ElementMetadata.java:155)
        at com.ociweb.xml.ElementMetadata.<init>(ElementMetadata.java:136)
        at com.ociweb.xml.WAX.start(WAX.java:829)
        at com.ociweb.xml.WAX.start(WAX.java:816)
        at com.ociweb.xml.WAX.start(WAX.java:803)

Solution

  • According to the doc (http://docs.oracle.com/javase/6/docs/api/java/util/regex/Pattern.html), that method is available since 1.5. Check if you are running an environment < 1.5. If that's the case, you must use Retroweaver, as explained in the project main page (https://code.google.com/p/waxy/).