hi,
I am new to the network programming,while i am connecting to remote server from a java program,my requirement is login to the JIRA software which is installed in server,and post my issue into JIRA.
Iam getting below errors.....
org.apache.xmlrpc.XmlRpcException: java.lang.Exception: RPC handler object "jira1" not found and no default handler registered
at org.apache.xmlrpc.client.XmlRpcStreamTransport.rea dResponse(XmlRpcStreamTransport.java:197)
at org.apache.xmlrpc.client.XmlRpcStreamTransport.sen dRequest(XmlRpcStreamTransport.java:156)
at org.apache.xmlrpc.client.XmlRpcHttpTransport.sendR equest(XmlRpcHttpTransport.java:143)
at org.apache.xmlrpc.client.XmlRpcSunHttpTransport.se ndRequest(XmlRpcSunHttpTransport.java:69)
at org.apache.xmlrpc.client.XmlRpcClientWorker.execut e(XmlRpcClientWorker.java:56)
at org.apache.xmlrpc.client.XmlRpcClient.execute(XmlR pcClient.java:167)
at org.apache.xmlrpc.client.XmlRpcClient.execute(XmlR pcClient.java:158)
at org.apache.xmlrpc.client.XmlRpcClient.execute(XmlR pcClient.java:147)
at com.prayog.JavaClient.main(JavaClient.java:181)
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Map;
import java.util.Vector;
import org.apache.xmlrpc.client.XmlRpcClient;
//import org.apache.xmlrpc.client.XmlRpcCommonsTransportFac tory;
import org.apache.xmlrpc.XmlRpcException;
import org.apache.xmlrpc.client.XmlRpcClientConfigImpl;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import java.security.cert.X509Certificate;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSession;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
public class JavaClient{
public static final String JIRA_URI = "http://host ip:8880";
public static final String RPC_PATH = "/rpc/xmlrpc";
public static final String USER_NAME = "username";
public static final String PASSWORD = "password";
@SuppressWarnings("unchecked")
public static void main(String[] args) throws NoSuchAlgorithmException,
KeyManagementException {
try {
// Create a trust manager that does not validate certificate chains
TrustManager[] trustAllCerts = new TrustManager[] {
new X509TrustManager() {
public X509Certificate[] getAcceptedIssuers() {
return null;
}
public void checkClientTrusted(X509Certificate[] certs,
String authType) {
// Trust always
}
public void checkServerTrusted(X509Certificate[] certs,
String authType) {
// Trust always
}
} };
// Install the all-trusting trust manager
SSLContext sc = SSLContext.getInstance("SSL");
// Create empty HostnameVerifier
HostnameVerifier hv = new HostnameVerifier() {
public boolean verify(String arg0, SSLSession arg1) {
return true;
}
};
sc.init(null, trustAllCerts, new java.security.SecureRandom());
HttpsURLConnection.setDefaultSSLSocketFactory(sc.g etSocketFactory());
HttpsURLConnection.setDefaultHostnameVerifier(hv);
//********************************
System.setProperty("https.proxyHost", "host");
System.setProperty("https.proxyPort", "port");
// Set the protocol for handling SSL based connecting
System.out.println(System.getProperties());
XmlRpcClient rpcClient = new XmlRpcClient();
XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();
config.setServerURL(new URL(JIRA_URI + RPC_PATH));
rpcClient.setConfig(config);
// Login and retrieve logon token
Vector loginParams = new Vector(2);
loginParams.add(USER_NAME);
loginParams.add(PASSWORD);
String loginToken = (String) rpcClient.execute("jira1.login",
loginParams);
System.out.println("Login sucess");
// Retrieve projects
Vector loginTokenVector = new Vector(1);
loginTokenVector.add(loginToken);
Object stuff = rpcClient.execute("jira1.getProjectsNoSchemes",
loginTokenVector);
Object[] projects = (Object[]) rpcClient.execute(
"jira1.getProjectsNoSchemes", loginTokenVector);
System.out.println("getProjects Sucess");
// Print projects
for (int i = 0; i < projects.length; i++) {
Map project = (Map) projects[i];
System.out.println("KEY: " + project.get("key") + "\tNAME: "
+ project.get("name") + "\tLEAD: "
+ project.get("lead"));
}
// Log out
Boolean bool = (Boolean) rpcClient.execute("jira1.logout",
loginTokenVector);
System.out.println("Logout successful: " + bool);
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (XmlRpcException e) {
e.printStackTrace();
}
}
}