Modify

Opened 11 years ago

Closed 11 years ago

#11108 closed defect (cantfix)

Problem with the api's library(int id, int when=0)

Reported by: anonymous Owned by: osimons
Priority: normal Component: XmlRpcPlugin
Severity: normal Keywords: method, ticket.changeLog, java
Cc: Olemis Lang Trac Release: 1.0

Description

I'm using the api xmlrpc for trac. I managed to see the list of tickets that were created. However, I can not use the method ticket.changeLog(int id, int When = 0). I have tried various ways to retrieve the values ​​of this method, but the following error is shown: "Ljava.lang.Object, can not be cast to java.util.Map". I've talked to some people about this issue and they told me that it's possibly a bug with the api's library. I would appreciate if someone would help me.

Best regards!

Attachments (1)

TracRpcApache.java (2.7 KB) - added by Olemis Lang 11 years ago.
Trac XML-RPC sample code (Java)

Download all attachments as: .zip

Change History (5)

comment:1 in reply to:  description Changed 11 years ago by Olemis Lang

Replying to anonymous:

[...]

However, I can not use the method ticket.changeLog(int id, int When = 0).

[...]

the following error is shown: "Ljava.lang.Object, can not be cast to java.util.Map".

It's obvious you should be using some Java client libraries to get this done . Please mention which one and provide sample Java code reproducing this failure so that I can take a look into this and determine whether this is a problem with your code or RPC client library (i.e. invalid ticket) or the RPC API (let's fix it) .

[...]

Thanks for your interest in the plugin . :)

comment:2 Changed 11 years ago by armin

Just got the same issue as the initial reporter of this issue.

Exception in thread "main" java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to java.util.Map
	at org.apache.xmlrpc.common.TypeConverterFactoryImpl$2.convert(TypeConverterFactoryImpl.java:164)
	at org.lustin.trac.xmlprc.TrackerDynamicProxy$1.invoke(TrackerDynamicProxy.java:128)
	at com.sun.proxy.$Proxy1.changeLog(Unknown Source)
	at Tests.TracXMLRpcTest.<init>(TracXMLRpcTest.java:64)

Just doing a basic query :

Ticket ticket = (Ticket) tdp.newInstance(Ticket.class);
System.out.println(ticket.changeLog(2,0));

All other methods like querying, creating and updating tickets work like a charm.

I'm using followng libraries :

Library Version
xmlrpc-client 3.1.3
xmlrpc-common 3.1.3
ws-commons-util 1.0.2
org.lustin.trac_xml 1.1.2

Any other information I should provide ?

comment:3 in reply to:  2 Changed 11 years ago by Olemis Lang

Replying to armin:

Just got the same issue as the initial reporter of this issue.

[...]

Any other information I should provide ?

Thanks for the information . I'll take a look into this .

comment:4 Changed 11 years ago by Olemis Lang

Keywords: bug removed
Resolution: cantfix
Status: newclosed
Trac Release: 1.0

This is what I get from the Python console


>>> from xmlrpclib import ServerProxy
>>> sp = ServerProxy("http://localhost:8082/trac_trunk/rpc")
>>> sp.ticket.get(1)
[1, <DateTime '20140128T03:12:34' at 181c098>, <DateTime '20140220T19:20:53' at 182ab90>, {'status': 'closed', 'changetime': <DateTime '20140220T19:20:53' at 182abd8>, 'description': 'd', 'reporter': 'anonymous', 'cc': '', 'type': 'defect', 'milestone': 'milestone2', '_ts': '1392924053536984', 'component': 'component1', 'summary': 's', 'priority': 'major', 'owner': 'somebody', 'version': '2.0', 'time': <DateTime '20140128T03:12:34' at 182ac20>, 'keywords': '', 'resolution': 'fixed'}]
>>> sp.ticket.changeLog(1, 0)
[[<DateTime '20140128T03:12:45' at 182ac68>, 'anonymous', 'comment', '1', '', 1], [<DateTime '20140128T03:12:45' at 182acf8>, 'anonymous', 'resolution', '', 'fixed', 1], [<DateTime '20140128T03:12:45' at 182ad88>, 'anonymous', 'status', 'new', 'closed', 1], [<DateTime '20140220T19:20:53' at 182add0>, 'murphy', 'comment', '2', '', 1], [<DateTime '20140220T19:20:53' at 182ae60>, 'murphy', 'milestone', '', 'milestone2', 1], [<DateTime '20140220T19:20:53' at 182aef0>, 'murphy', 'version', '', '2.0', 1]]

Then I wrote attached demo in Java only using Apache XML-RPC lib and it works as expected. These are the results I get.

+ Change
|    Jan 28, 2014 3:12:45 AM
|    by anonymous
|    permanent
|    field: comment
|    from: 1
|    to: 
+ Change
|    Jan 28, 2014 3:12:45 AM
|    by anonymous
|    permanent
|    field: resolution
|    from: 
|    to: fixed
+ Change
|    Jan 28, 2014 3:12:45 AM
|    by anonymous
|    permanent
|    field: status
|    from: new
|    to: closed
+ Change
|    Feb 20, 2014 7:20:53 PM
|    by murphy
|    permanent
|    field: comment
|    from: 2
|    to: 
+ Change
|    Feb 20, 2014 7:20:53 PM
|    by murphy
|    permanent
|    field: milestone
|    from: 
|    to: milestone2
+ Change
|    Feb 20, 2014 7:20:53 PM
|    by murphy
|    permanent
|    field: version
|    from: 
|    to: 2.0

Therefore there's nothing wrong with the server side API, afaict.

p.s. In sample code Trac RPC URL and ticket ID are retrieved from a global environment variable. This is my configuration:

$ dpkg -l libxmlrpc3* libws-commons-util-java | grep -v "^|"
Desired=Unknown/Install/Remove/Purge/Hold
+++-====================================================================-========================================-============-==============================================================================
ii  libws-commons-util-java                                              1.0.1-7                                  all          Common utilities from the Apache Web Services Project
ii  libxmlrpc3-client-java                                               3.1.3-5                                  all          XML-RPC implementation in Java (client side)
ii  libxmlrpc3-common-java                                               3.1.3-5                                  all          XML-RPC implementation in Java
ii  libxmlrpc3-java-doc                                                  3.1.3-5                                  all          XML-RPC implementation in Java (API documentation)


Changed 11 years ago by Olemis Lang

Attachment: TracRpcApache.java added

Trac XML-RPC sample code (Java)

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain osimons.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.