Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

XMLRPC problem

42 views
Skip to first unread message

matth...@freenet.de

unread,
Feb 21, 2007, 9:32:58 AM2/21/07
to support-...@lists.mozilla.org

matth...@freenet.de

unread,
Feb 22, 2007, 8:42:58 AM2/22/07
to dev-apps...@lists.mozilla.org, support-...@lists.mozilla.org, matth...@freenet.de
can everyone see the mistake in this code

String login="matth...@freenet.de";
String password="mussel";

params.add(login);
params.add(password);
System.out.println(client.execute("User.login", params));

because eclipse show me this problem
Exception in thread "main" java.lang.ClassCastException: java.lang.String
cannot be cast to java.lang.Integer
at
org.apache.xmlrpc.parser.XmlRpcResponseParser.addResult(XmlRpcResponseParser.java:55)
at
org.apache.xmlrpc.parser.RecursiveTypeParserImpl.endValueTag(RecursiveTypeParserImpl.java:71)
at
org.apache.xmlrpc.parser.XmlRpcResponseParser.endElement(XmlRpcResponseParser.java:164)
at
com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(Unknown
Source)
at
com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEndElement(Unknown
Source)
at
com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(Unknown
Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown
Source)
at
com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(Unknown
Source)
at
com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown
Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown
Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown
Source)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown
Source)
at
com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown
Source)
at
org.apache.xmlrpc.client.XmlRpcStreamTransport.readResponse(XmlRpcStreamTransport.java:175)
at
org.apache.xmlrpc.client.XmlRpcStreamTransport.sendRequest(XmlRpcStreamTransport.java:145)
at
org.apache.xmlrpc.client.XmlRpcHttpTransport.sendRequest(XmlRpcHttpTransport.java:94)
at
org.apache.xmlrpc.client.XmlRpcSunHttpTransport.sendRequest(XmlRpcSunHttpTransport.java:39)
at
org.apache.xmlrpc.client.XmlRpcClientWorker.execute(XmlRpcClientWorker.java:53)
at org.apache.xmlrpc.client.XmlRpcClient.execute(XmlRpcClient.java:166)
at org.apache.xmlrpc.client.XmlRpcClient.execute(XmlRpcClient.java:157)
at org.apache.xmlrpc.client.XmlRpcClient.execute(XmlRpcClient.java:146)
at de.igosys.bugzilla.client.RPCClient.main(RPCClient.java:140)

"Jetzt Handykosten senken mit klarmobil - 14 Ct./Min.! Hier klicken"
http://www.klarmobil.de/index.html?pid=73025

Hugh Eaves

unread,
Mar 12, 2008, 12:41:26 PM3/12/08
to
Yes, using Java, you need to send the parameters to bugzilla as a "Map".

// Login to Bugzilla
Map paramMap = new HashMap();
paramMap.put("login", "matth...@freenet.de");
paramMap.put("password", "mussel");
result = client.execute("User.login",
new Object[] { paramMap });

If you haven't already, you'll also need to use an
XmlRpcCommonsTransportFactory initialized with a Jakarta HttpClient object
so that you can support cookies.

XmlRpcClient client = new XmlRpcClient();
HttpClient httpClient = new HttpClient();
XmlRpcCommonsTransportFactory factory = new
XmlRpcCommonsTransportFactory(
client);
factory.setHttpClient(httpClient);
client.setTransportFactory(factory);

XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();
config.setServerURL(new URL(
"https://your.bugzilla.server/xmlrpc.cgi"));
client.setConfig(config);


You still shouldn't have received the ClassCastException. I believe it's
happending because bugzilla sends an invalid XML response when there is an
error condition

Hugh


<matth...@freenet.de> wrote in message
news:mailman.1668.1172151787...@lists.mozilla.org...

cplusstudent

unread,
Mar 17, 2008, 8:37:34 AM3/17/08
to
On Mar 12, 12:41 pm, "Hugh Eaves" <hlea...@vcu.edu> wrote:
> Yes, using Java, you need to send the parameters to bugzilla as a "Map".
>
> // Login to Bugzilla
> Map paramMap = new HashMap();
> paramMap.put("login", "matthias...@freenet.de");

> paramMap.put("password", "mussel");
> result = client.execute("User.login",
> new Object[] { paramMap });
>
> If you haven't already, you'll also need to use an
> XmlRpcCommonsTransportFactory initialized with a Jakarta HttpClient object
> so that you can support cookies.
>
> XmlRpcClient client = new XmlRpcClient();
> HttpClient httpClient = new HttpClient();
> XmlRpcCommonsTransportFactory factory = new
> XmlRpcCommonsTransportFactory(
> client);
> factory.setHttpClient(httpClient);
> client.setTransportFactory(factory);
>
> XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();
> config.setServerURL(new URL(
> "https://your.bugzilla.server/xmlrpc.cgi"));
> client.setConfig(config);
>
> You still shouldn't have received the ClassCastException. I believe it's
> happending because bugzilla sends an invalid XML response when there is an
> error condition
>
> Hugh
>
> <matthias...@freenet.de> wrote in message

>
> news:mailman.1668.1172151787...@lists.mozilla.org...
> can everyone see the mistake in this code
>
> String login="matthias...@freenet.de";

Your reply helped me get what I needed to get done. I put together a
simple Groovy script to handle the task of reading in XML data and
looping through each node to create a bug in Bugzilla. Here is the
script:

import groovy.util.XmlSlurper
import groovy.net.xmlrpc.*

import java.util.Map
import java.util.HashMap
import java.net.ServerSocket

import org.apache.commons.httpclient.*
import org.apache.xmlrpc.client.*

public class BugzillaCreateFromXML {

public static void main(String[] args) {

// get the xml data of our issues in the .xml file
def xmlData = new XmlSlurper().parse(new File("C:/
issues.xml"))

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

factory.setHttpClient(httpClient)
rpcClient.setTransportFactory(factory)
config.setServerURL(new URL("http://bugzilla-addres/
xmlrpc.cgi"))
rpcClient.setConfig(config)

// map of the login data
Map loginMap = new HashMap()
loginMap.put("login", "admin")
loginMap.put("password", "admin")
loginMap.put("rememberlogin", "Bugzilla_remember")

// login to bugzilla
def loginResult = rpcClient.execute("User.login", loginMap)
println loginResult

// map of the bug data
Map bugMap = new HashMap()

// iterate through each issue
xmlData.issue.each {

bugMap.put("product", it.product.text())
bugMap.put("component", it.component.text())
bugMap.put("summary", it.summary.text())
bugMap.put("version", it.version.text())
bugMap.put("description", it.description.text())
bugMap.put("op_sys", it.opsys.text())
bugMap.put("platform", it.platform.text())
bugMap.put("priority", it.priority.text())
bugMap.put("severity", it.severity.text())
bugMap.put("status", it.status.text())

// create bug
def createResult = rpcClient.execute("Bug.create", bugMap)
println createResult

// clear bugMap so we can re-populate it with the next
issue
bugMap.clear()
}
}
}

I posted a blog at thejavajar.com with some more detail. Thanks.

ara...@gmail.com

unread,
May 8, 2008, 10:03:44 PM5/8/08
to
Hi,

I am trying to create a webservice client for logging bugs
automatically from a 3rd party application into bugzilla.

I am able to log into the system using the webservice, but when i try
to create a bug it says the following error message..

rg.apache.xmlrpc.XmlRpcException: Login Required
at
org.apache.xmlrpc.client.XmlRpcStreamTransport.readResponse(XmlRpcStreamTransport.java:
186)


at
org.apache.xmlrpc.client.XmlRpcStreamTransport.sendRequest(XmlRpcStreamTransport.java:
145)
at
org.apache.xmlrpc.client.XmlRpcHttpTransport.sendRequest(XmlRpcHttpTransport.java:
94)
at
org.apache.xmlrpc.client.XmlRpcSunHttpTransport.sendRequest(XmlRpcSunHttpTransport.java:

44)


at
org.apache.xmlrpc.client.XmlRpcClientWorker.execute(XmlRpcClientWorker.java:
53)
at org.apache.xmlrpc.client.XmlRpcClient.execute(XmlRpcClient.java:
166)
at org.apache.xmlrpc.client.XmlRpcClient.execute(XmlRpcClient.java:

136)
at org.apache.xmlrpc.client.XmlRpcClient.execute(XmlRpcClient.java:
125)
at
com.company.tgt.webservice.AppXMLRPCClient.testXMLRPCClient(AppXMLRPCClient.java:
59)
at
com.company.tgt.webservice.AppXMLRPCClient.main(AppXMLRPCClient.java:
28)

and below is the program sample..

private void testXMLRPCClient()
{
try
{

XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();

config.setServerURL(new URL("http://mycomputer.net:9999/bugzilla/
xmlrpc.cgi"));


XmlRpcClient client = new XmlRpcClient();

client.setConfig(config);


Map loginMap = new HashMap();

loginMap.put("login", "login");
loginMap.put("password", "Pa$$word");
loginMap.put("rememberlogin","Bugzilla_remember");
System.out.println(client.execute("Bugzilla.version", new Object[]
{loginMap}));
System.out.println(client.execute("Bugzilla.timezone", new Object[]
{loginMap}));
System.out.println(client.execute("User.login", new Object[]
{loginMap}));
Map issueMap = new HashMap();
issueMap.put("product", "Test");
issueMap.put("component", "Test");
issueMap.put("summary", "Testing Bugzilla Data Entry through XML-
RPC");
issueMap.put("version", "unspecified");
issueMap.put("description", "Test Description");
issueMap.put("op_sys", "Windows");
issueMap.put("platform", "PC");
issueMap.put("priority", "P4");
issueMap.put("severity", "normal");
Object obj = client.execute("Bug.create", new Object[]{issueMap});

}catch (MalformedURLException e)
{
e.printStackTrace();
}catch (XmlRpcException e)
{
e.printStackTrace();
}
}

Thanks in advance...

Arasan.

> > org.apache.xmlrpc.parser.XmlRpcResponseParser.addResult(XmlRpcResponseParse­r.java:55)
> > at
> > org.apache.xmlrpc.parser.RecursiveTypeParserImpl.endValueTag(RecursiveTypeP­arserImpl.java:71)
> > at
> > org.apache.xmlrpc.parser.XmlRpcResponseParser.endElement(XmlRpcResponsePars­er.java:164)
> > at
> > com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(Unk­nown
> > Source)
> > at
> > com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scan­EndElement(Unknown
> > Source)
> > at
> > com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$Frag­mentContentDriver.next(Unknown


> > Source)
> > at
> > com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown
> > Source)
> > at

> > com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(Unkno­wn
> > Source)
> > at
> > com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scan­Document(Unknown


> > Source)
> > at
> > com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown
> > Source)
> > at
> > com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown
> > Source)
> > at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown
> > Source)
> > at
> > com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown
> > Source)
> > at

> > com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(U­nknown
> > Source)
> > at
> > org.apache.xmlrpc.client.XmlRpcStreamTransport.readResponse(XmlRpcStreamTra­nsport.java:175)
> > at
> > org.apache.xmlrpc.client.XmlRpcStreamTransport.sendRequest(XmlRpcStreamTran­sport.java:145)
> > at
> > org.apache.xmlrpc.client.XmlRpcHttpTransport.sendRequest(XmlRpcHttpTranspor­t.java:94)
> > at
> > org.apache.xmlrpc.client.XmlRpcSunHttpTransport.sendRequest(XmlRpcSunHttpTr­ansport.java:39)

Max Kanat-Alexander

unread,
May 9, 2008, 2:25:16 AM5/9/08
to support-...@lists.mozilla.org
On Thu, 8 May 2008 19:03:44 -0700 (PDT) ara...@gmail.com wrote:
> I am able to log into the system using the webservice, but when i try
> to create a bug it says the following error message..
>
> rg.apache.xmlrpc.XmlRpcException: Login Required

Your WebService needs to send the Cookies it got in responsewith
the login method. I'm pretty sure somebody's already written code in
Java that helps with this.

-Max
--
http://www.everythingsolved.com/
Competent, Friendly Bugzilla and Perl Services. Everything Else, too.

0 new messages