简体   繁体   中英

“main” java.lang.NoSuchMethodError:

Below is my code to integrate with bugzilla and i am getting exception

import java.util.Map;
import com.j2bugzilla.base.Bug;
import com.j2bugzilla.base.BugFactory;
import com.j2bugzilla.base.BugzillaConnector;
import com.j2bugzilla.base.BugzillaMethod;
import com.j2bugzilla.rpc.LogIn;
import com.j2bugzilla.rpc.ReportBug;


public class bugzillaTest {


public static void main(String args[]) throws Exception {


//try to connect to bugzilla

BugzillaConnector conn;
conn=new BugzillaConnector();
conn.connectTo("http://bugzilllaurl");


LogIn login=new LogIn("pramod.kg","123#er");
conn.executeMethod(login);

int id=login.getUserID();
System.out.println("current user id"+id);

BugFactory factory=new BugFactory();


              String component="Usability";
              String description="this is a test desc";
              String os="All";
              String platform="PC";
              String priority="High";
              String product="MMNR7";
              String summary="test summary";
              String version="1.0";
   Bug bugs= factory.newBug()
             .setComponent(component)
                     .setDescription(description)
             .setOperatingSystem(os)
             .setPlatform(platform)
              .setPriority(priority)
              .setProduct(product)
              .setSummary(summary)
              .setVersion(version)
              .createBug();

       ReportBug report=new ReportBug(bugs);



          try {

              conn.executeMethod(report);
              System.out.println("Bug is logged!");
        } catch (Exception e) {
            // TODO: handle exception

            System.out.println("eror"+e.getMessage());
        }
}
}

Exception is :

I have scucessfully logged in but when i run conn.executeMethod(report); i get below error.

Exception in thread "main" java.lang.NoSuchMethodError: org.apache.xmlrpc.parser.XmlRpcResponseParser.getErrorCause()Ljava/lang/Throwable; at org.apache.xmlrpc.client.XmlRpcStreamTransport.readResponse(XmlRpcStreamTransport.java:195) at org.apache.xmlrpc.client.XmlRpcStreamTransport.sendRequest(XmlRpcStreamTransport.java:156) at org.apache.xmlrpc.client.XmlRpcHttpTransport.sendRequest(XmlRpcHttpTransport.java:143) at org.apache.xmlrpc.client.XmlRpcSunHttpTransport.sendRequest(XmlRpcSunHttpTransport.java:69) at org.apache.xmlrpc.client.XmlRpcClientWorker.execute(XmlRpcClientWorker.java:56) at org.apache.xmlrpc.client.XmlRpcClient.execute(XmlRpcClient.java:167) at org.apache.xmlrpc.client.XmlRpcClient.execute(XmlRpcClient.java:137) at org.apache.xmlrpc.client.XmlRpcClient.execute(XmlRpcClient.java:126) at com.j2bugzilla.base.BugzillaConnector.executeMethod(BugzillaConnector.java:164) at bugzillaTest.main(bugzillaTest.java:92)

Add all the below jars and check

xmlrpc-client-3.1.3

xmlrpc-common-3.1.3

xmlrpc-server-3.1.3

l got fix this issue as below

public class bugzillaTest {


private static final String COMP = "Usability";
private static final String DES = "this is a test desc";
private static final String OS = "All";
private static final String PLAT = "PC";
private static final String PRIO = "High";
private static final String PRO = "MMNR7";
private static final String SUM = "test summary";
private static final String VER = "1.0";





public static void main(String args[]) throws Exception {

    // try to connect to bugzilla

    BugzillaConnector conn;
    BugFactory factory;
    Bug bugs;
    ReportBug report;

    conn = new BugzillaConnector();


    conn.connectTo("http://192.168.0.31/");

    LogIn login = new LogIn("username", "password");


    // create a bug

     factory = new BugFactory();
     bugs = factory
                .newBug().
     setOperatingSystem(OS)
        .setPlatform(PLAT)
        .setPriority(PRIO)
        .setProduct(PRO)
        .setComponent(COMP)
        .setSummary(SUM)
        .setVersion(VER)
        .setDescription(DES)
        .createBug();


     report=new ReportBug(bugs);




try{conn.executeMethod(login);
conn.executeMethod(report);

}
catch(Exception e){System.out.println(e.getMessage());}


}


}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM