Modify

Opened 7 years ago

Closed 7 years ago

#13411 closed defect (worksforme)

Problem creating tickets with xml-rpc: 'weakly-referenced object no longer exists' while executing 'ticket.create()'

Reported by: anonymous Owned by: osimons
Priority: normal Component: XmlRpcPlugin
Severity: normal Keywords:
Cc: Trac Release: 0.11

Description (last modified by Jun Omae)

I've been trying to fix this for a couple of days and I do not know why it may be happening.

Eclipse throws this error

org.apache.xmlrpc.XmlRpcException: 'weakly-referenced object no longer exists' while executing 'ticket.create()'
	at org.apache.xmlrpc.client.XmlRpcStreamTransport.readResponse(Unknown Source)
	at org.apache.xmlrpc.client.XmlRpcStreamTransport.sendRequest(Unknown Source)
	at org.apache.xmlrpc.client.XmlRpcHttpTransport.sendRequest(Unknown Source)
	at org.apache.xmlrpc.client.XmlRpcSunHttpTransport.sendRequest(Unknown Source)
	at org.apache.xmlrpc.client.XmlRpcClientWorker.execute(Unknown Source)
	at org.apache.xmlrpc.client.XmlRpcClient.execute(Unknown Source)
	at org.apache.xmlrpc.client.XmlRpcClient.execute(Unknown Source)
	at org.apache.xmlrpc.client.XmlRpcClient.execute(Unknown Source)
	at controller.ManagerImportTickets.call(ManagerImportTickets.java:38)
	at controller.ManagerImportTickets.createTicket(ManagerImportTickets.java:49)
	at controller.ManagerImportTickets.main(ManagerImportTickets.java:77)
JavaClient: org.apache.xmlrpc.XmlRpcException: 'weakly-referenced object no longer exists' while executing 'ticket.create()'

My code:

import java.io.IOException;
import java.net.URL;
import java.util.Hashtable;
import java.util.Map;

import org.apache.xmlrpc.XmlRpcException;
import org.apache.xmlrpc.client.XmlRpcClient;
import org.apache.xmlrpc.client.XmlRpcClientConfigImpl;
import Model.Ticket;

public class ManagerImportTickets 
{
    private static XmlRpcClient client;
    private final static String PASSWORD = "xxxx";
    private final static String USER = "xxxx";
    private final static String URL = "http://xxxx/trac/project/login/rpc";
    
    private static void createConnection() throws Exception 
    {
        XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();
           
        config.setServerURL(new URL(URL));
        config.setBasicUserName(USER);
        config.setBasicPassword(PASSWORD);
        
        client = new XmlRpcClient();
        client.setConfig(config);
    }
    
    private static Object call(String method, Object... parameters) throws XmlRpcException, IOException 
    {
        Object result = client.execute(method, parameters);
        if (result instanceof XmlRpcException) 
        {
            throw (XmlRpcException) result;
        }
        return result;
    }
    
    private static int createTicket(String summary, String description, Map<String, Object> attributes)
            throws XmlRpcException, IOException 
    {
        int id = (Integer) call("ticket.create", summary, description, attributes);
        return id;
    }
    
    public static void main (String [] args) 
    { 
        Map<String, Object> attributes = new Hashtable<String, Object>();
        Ticket aTicket = new Ticket("type", "summary",  "id_html", "status", "document", "scope", "description", "component", "part_number", "milestone");
        Object aResult;
        
        try 
        {
            createConnection();
            
            attributes.put("type", "task");
            attributes.put("status", "closed");
            
            aResult  = (Integer) createTicket(aTicket.getSummary(), aTicket.getDescription(), attributes);
            System.out.println("Id del ticket creado: " + aResult);         
        } 
        catch (Exception exception) 
        { 
            exception.printStackTrace();
            System.err.println("JavaClient: " + exception); 
        } 
    }
}

Attachments (0)

Change History (5)

comment:1 Changed 7 years ago by Jun Omae

Component: SELECT A HACKXmlRpcPlugin
Description: modified (diff)
Keywords: XMLRPC removed
Owner: set to osimons

Are you really using Trac 0.11? We recommend to upgrade to Trac 1.0.x, at least.

Please post trac.log when the error is raised after enabling TracLogging with DEBUG level.

comment:2 in reply to:  1 ; Changed 7 years ago by anonymous

Replying to Jun Omae:

Are you really using Trac 0.11? We recommend to upgrade to Trac 1.0.x, at least.

Please post trac.log when the error is raised after enabling TracLogging with DEBUG level.

the version 0.11.4 exactly. It is not feasible in the short term to change the version :( I will try to put the log that Trac offers.

Last edited 7 years ago by Ryan J Ollos (previous) (diff)

comment:3 in reply to:  2 ; Changed 7 years ago by Ryan J Ollos

Replying to anonymous:

It is not feasible in the short term to change the version :(

It's also not feasible for us to provide support for 0.11.7. The last 0.11.x release was in 2010.

comment:4 in reply to:  3 Changed 7 years ago by anonymous

Replying to Ryan J Ollos:

Replying to anonymous:

It is not feasible in the short term to change the version :(

It's also not feasible for us to provide support for 0.11.7. The last 0.11.x release was in 2010.

Now it works. I put all the fields of the ticket and .. magic. I don't understand anything, but it works.

comment:5 Changed 7 years ago by Ryan J Ollos

Resolution: worksforme
Status: newclosed

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.