简体   繁体   English

使用Java在Bugzilla中创建bug时出错

[英]Error while creating bug in Bugzilla using Java

while trying to create a new bug in bugzilla, i am getting an error "You must log in before using this part of Bugzilla" 在尝试在bugzilla中创建一个新的bug时,我收到一条错误“你必须在使用Bugzilla的这一部分之前登录”

Code looks like 代码看起来像

`HttpClient httpClient = new HttpClient();
    XmlRpcClient rpcClient = new XmlRpcClient();
    XmlRpcCommonsTransportFactory factory = new XmlRpcCommonsTransportFactory(rpcClient);
    XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();

    factory.setHttpClient(httpClient);
    rpcClient.setTransportFactory(factory);
    config.setServerURL(new URL("http://192.168.0.203/xmlrpc.cgi"));
    rpcClient.setConfig(config);

    // map of the login data
    Map<String, String> loginMap = new HashMap<String, String>();
    loginMap.put("login", "bugzilla.admin@abcd.com");
    loginMap.put("password", "bugzilla@admin");
    loginMap.put("rememberlogin", "Bugzilla_remember");

    // login to bugzilla
    Object loginResult = rpcClient.execute("User.login", new Object[]{loginMap});
    System.err.println ("loginResult=" + loginResult);

    // map of the bug data
    Map<String, String> bugMap = new HashMap<String, String>();

    bugMap.put("product", "Demo");
    bugMap.put("component", "Demo_project");
    bugMap.put("summary", "Bug created for test");
    bugMap.put("description", "This is text ");
    bugMap.put("version", "unspecified");
    bugMap.put("op_sys", "Windows");
    bugMap.put("platform", "PC");
    bugMap.put("priority", "P2");
    bugMap.put("severity", "Normal");
    bugMap.put("status", "NEW");

    // create bug
    Object createResult = rpcClient.execute("Bug.create", new Object[]{bugMap});
    System.err.println("createResult = " + createResult);
 `

At first i am able to login and the response I get is-: loginResult={id=1, token=1-AJ4uG13zlJ} but when creating a new bug error occurs 起初我能够登录并且我得到的响应是::loginResult = {id = 1,token = 1-AJ4uG13zlJ}但是在创建新错误时会发生错误

`Exception in thread "main" org.apache.xmlrpc.XmlRpcException: You must log in before using this part of Bugzilla.
at org.apache.xmlrpc.client.XmlRpcStreamTransport.readResponse(XmlRpcStreamTransport.java:197)
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.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.abcd.BugCreator2.main(BugCreator2.java:52)`

Why do I get this error of login again, when I am already logged in. 当我已经登录时,为什么会再次出现此登录错误。

Edit-: 编辑-:

The above code works fine when tried on https://bugzilla.mozilla.org It seems there is some problem while configuration of Bugzilla on local server. https://bugzilla.mozilla.org上尝试上面的代码工作正常。在本地服务器上配置Bugzilla时似乎存在一些问题。

first of all thanks to you i was searching code just like yours... 首先感谢你,我正在寻找与你一样的代码......

and if you still get that error you should know that you also need to send login and password parameters for create method. 如果仍然出现该错误,您应该知道还需要为create方法发送登录名和密码参数。

just try like this .. 试试这样..

add this 加上这个

bugMap.put("login", "bugzilla.admin@abcd.com");
bugMap.put("password", "bugzilla@admin");

before this 在这之前

bugMap.put("product", "Demo");
bugMap.put("component", "Demo_project");
bugMap.put("summary", "Bug created for test");
bugMap.put("description", "This is text ");
bugMap.put("version", "unspecified");
bugMap.put("op_sys", "Windows");
bugMap.put("platform", "PC");
bugMap.put("priority", "P2");
bugMap.put("severity", "Normal");
bugMap.put("status", "NEW");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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