Error while contacting C2DM server for Posting Message

82 views
Skip to first unread message

D KYON

unread,
Jan 17, 2011, 1:38:48 AM1/17/11
to android-c2dm
Hi all,
Am very new to C2DM as well HttpPost, While i try to post messages i
get the folowing error :


org.apache.http.conn.HttpHostConnectException: Connection to
https://android.apis.google.com refused

I use Httpclient-4.0.jar & Httpcore-4.0.1.jar

And the stack trace is :


org.apache.http.conn.HttpHostConnectException: Connection to
https://android.apis.google.com refused
at
org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:
127)
at
org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:
147)
at
org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:
101)
at
org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:
381)
at
org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:
641)
at
org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:
576)
at
com.techm.canvasm.util.HttpPostForC2DMServer.postMessage(HttpPostForC2DMServer.java:
63)
at
com.techm.canvasm.ws.CloudToDeviceMessagingWSSoapBindingImpl.registerMyApp(CloudToDeviceMessagingWSSoapBindingImpl.java:
79)
at
com.techm.canvasm.ws.CloudToDeviceMessagingWSSoapBindingSkeleton.registerMyApp(CloudToDeviceMessagingWSSoapBindingSkeleton.java:
79)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at
org.apache.axis.providers.java.RPCProvider.invokeMethod(RPCProvider.java:
397)
at
org.apache.axis.providers.java.RPCProvider.processMessage(RPCProvider.java:
186)
at
org.apache.axis.providers.java.JavaProvider.invoke(JavaProvider.java:
323)
at
org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:
32)
at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
at org.apache.axis.handlers.soap.SOAPService.invoke(SOAPService.java:
453)
at org.apache.axis.server.AxisServer.invoke(AxisServer.java:281)
at org.apache.axis.transport.http.AxisServlet.doPost(AxisServlet.java:
699)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
at
org.apache.axis.transport.http.AxisServletBase.service(AxisServletBase.java:
327)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:
252)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:
173)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:
213)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:
178)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:
126)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:
105)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:
107)
at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:
148)
at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:
868)
at org.apache.coyote.http11.Http11BaseProtocol
$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:
663)
at
org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:
527)
at
org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:
80)
at org.apache.tomcat.util.threads.ThreadPool
$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Unknown Source)
Caused by: java.net.ConnectException: Connection timed out: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(Unknown Source)
at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.connect(Unknown Source)
at
org.apache.http.conn.ssl.SSLSocketFactory.connectSocket(SSLSocketFactory.java:
333)
at
org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:
123)


And my code is is as given below :

String data = "Test Message";
DefaultHttpClient client = new DefaultHttpClient();
HttpPost httppost = new HttpPost("https://android.apis.google.com/
c2dm/send");
List<NameValuePair> formparams = new ArrayList<NameValuePair>();
formparams.add(new BasicNameValuePair("registration_id",
registrationId));
formparams.add(new BasicNameValuePair("data.payload", data));
formparams.add(new BasicNameValuePair("collapse_key", "foo"));
if (null != registrationId)
{
formparams.add(new BasicNameValuePair("id", registrationId));
}
UrlEncodedFormEntity entity = null;
try
{
entity = new UrlEncodedFormEntity(formparams, "UTF-8");
}
catch (UnsupportedEncodingException e1)
{
// TODO Auto-generated catch block
e1.printStackTrace();
}
httppost.setEntity(entity);
Header header = new BasicHeader("Authorization: GoogleLogin
auth=",clientAuthToken);
Header header2 = new BasicHeader("Content-Type","application/x-www-
form-urlencoded");
httppost.addHeader(header);
httppost.addHeader(header2);
//httppost.getParams().setParameter("Content-
length:",""+data.length());
HttpContext localContext = new BasicHttpContext();
HttpResponse response = null;
try
{
System.out.println("RESPONSE : "+response);
response = client.execute(httppost, localContext);
System.out.println("RESPONSE : "+response);

//HttpEntity entity2 = response.getEntity();

System.out.println("----------------------------------------");
System.out.println(response.getStatusLine());
Header[] headers = response.getAllHeaders();
for (int i = 0; i < headers.length; i++) {
System.out.println(headers[i]);
}
System.out.println("----------------------------------------");

if (response.getEntity() != null) {
System.out.println(EntityUtils.toString(response.getEntity()));
}

}
catch (Exception e)
{
System.out.println(" EXCEPTION ------------------");
System.out.println("LocalizedMessage() :
"+e.getLocalizedMessage());
e.printStackTrace();
System.out.println("Message() : "+e.getMessage());

System.err.println(e);
}
finally
{

}

Can any one help me out ?

Thanks

D KYON

unread,
Jan 17, 2011, 5:06:04 AM1/17/11
to android-c2dm
I was missing proxy credentials in my code... i then added them :

HttpHost proxy = new HttpHost("myproxyurl, "http");
client.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY,
proxy);

it solved "org.apache.http.conn.HttpHostConnectException: Connection
tohttps://android.apis.google.comrefused" exception.

No i get following error :

HTTP/1.1 401 Unauthorized
Header :Content-Type: text/html; charset=UTF-8
Header :Date: Mon, 17 Jan 2011 10:01:49 GMT
Header :Expires: Mon, 17 Jan 2011 10:01:49 GMT
Header :Cache-Control: private, max-age=0
Header :X-Content-Type-Options: nosniff
Header :X-Frame-Options: SAMEORIGIN
Header :X-XSS-Protection: 1; mode=block
Header :Server: GSE
Header :Transfer-Encoding: chunked
----------------------------------------
<HTML>
<HEAD>
<TITLE>Unauthorized</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000">
<H1>Unauthorized</H1>
<H2>Error 401</H2>
</BODY>
</HTML>

any idea ??

rishi gaurav

unread,
Jan 17, 2011, 5:18:49 AM1/17/11
to androi...@googlegroups.com
Try Adding these permission in AndroidManifest.xml

<!-- Only this application can receive the messages and registration result -->
    <permission android:name="com.example.myapp.permission.C2D_MESSAGE" android:protectionLevel="signature" />
    <uses-permission android:name="com.example.myapp.permission.C2D_MESSAGE" />
   
    <!-- This app has permission to register and receive message -->
    <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
   
    <!-- Send the registration id to the server -->
    <uses-permission android:name="android.permission.INTERNET" />


Hope This Works!!!
--
Regards:

Rishi Gaurav

D KYON

unread,
Jan 17, 2011, 5:22:17 AM1/17/11
to android-c2dm
Thanks a lot Rishi. Will try and let you know

On Jan 17, 3:18 pm, rishi gaurav <rishi...@gmail.com> wrote:
> Try Adding these permission in AndroidManifest.xml
>
> <!-- Only this application can receive the messages and registration result
> -->
>     <permission android:name="com.example.myapp.permission.C2D_MESSAGE"
> android:protectionLevel="signature" />
>     <uses-permission android:name="com.example.myapp.permission.C2D_MESSAGE"
> />
>
>     <!-- This app has permission to register and receive message -->
>     <uses-permission
> android:name="com.google.android.c2dm.permission.RECEIVE" />
>
>     <!-- Send the registration id to the server -->
>     <uses-permission android:name="android.permission.INTERNET" />
>
> Hope This Works!!!
>
> ...
>
> read more »

D KYON

unread,
Jan 17, 2011, 6:39:47 AM1/17/11
to android-c2dm
Hi Rishi,

I did what u asked me to do, Still i face the same error HTTP/1.1 401
Unauthorized.
Is something wrong in my java code that does the Post for c2dm
server ?

Thank you
> ...
>
> read more »

debajit

unread,
Jan 17, 2011, 1:33:01 PM1/17/11
to androi...@googlegroups.com
hi D,

what account are you using to authenticate your requests to the C2DM
server? you need to use the role account (not a personal/user account
used on one of your target devices) specified when you signed up for
the C2DM service.

thx, debajit

D KYON

unread,
Jan 18, 2011, 4:18:40 AM1/18/11
to android-c2dm
Hi Debajit,

Am using the account which i specify when I sign up for the C2DM
service.
And I aslo tried getting the authToken from my app server

The code is as given below :
----------------------------------------------------------------------------
public static void performAuthentication(String regId)
{
System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
System.out.println("Performing Authentication ");


// Create a new HttpClient and Post Header
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("https://www.google.com/accounts/
ClientLogin");

HttpHost proxy = new HttpHost("myproxyurl", 80, "http");
httpclient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY,
proxy);

HttpParams params = httpclient.getParams();
params.setParameter("content-type", "application/x-www-form-
urlencoded");
try {

// Add your data
List<NameValuePair> nameValuePairs = new
ArrayList<NameValuePair>(2);
nameValuePairs.add(new
BasicNameValuePair("accountType","HOSTED_OR_GOOGLE"));
nameValuePairs.add(new BasicNameValuePair("Email",
"x...@gmail.com"));
nameValuePairs.add(new BasicNameValuePair("Passwd","abc"));
nameValuePairs.add(new BasicNameValuePair("service", "ac2dm"));
nameValuePairs.add(new BasicNameValuePair("source", "MyAapp"));
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));

System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
System.out.println("Execute HTTP Post Request");
System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");

HttpResponse response = httpclient.execute(httppost);
System.out.println(response.getEntity().toString());
BufferedReader in = new BufferedReader(new
InputStreamReader(response.getEntity().getContent()));
StringBuffer sb = new StringBuffer("");
String line = "";
//String NL = System.getProperty("line.separator");
while ((line = in.readLine()) != null)
{
sb.append(line);
}
in.close();
String result = sb.toString();
// System.out.println("Result=" + result);

String authToken=result.substring(result.indexOf("Auth=")+5);
// System.out.println("Token=" + authToken);

System.out.println("Result=="+result);
System.out.println("Token="+authToken);
System.out.println("SendingId="+regId);
System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");

sendMessage(regId, authToken);

} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
} catch (IOException e) {
// TODO Auto-generated catch block
}


}

Am getting the authToken from google i.e https://www.google.com/accounts/ClientLogin.
and passing the same to the below given method.

public static void sendMessage(String regId, String authToken)
{
System.out.println("Sending Message");
System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
// Create a new HttpClient and Post Header
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("https://android.apis.google.com/
c2dm/send");

HttpHost proxy = new HttpHost("myproxyurl", 80, "http");
httpclient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY,
proxy);

HttpParams params = httpclient.getParams();
params.setParameter("content-type", "application/x-www-form-
urlencoded");

httppost.addHeader("Authorization: GoogleLogin auth=", authToken);


try
{
// Add your data
List<NameValuePair> nameValuePairs = new
ArrayList<NameValuePair>(2);
//nameValuePairs.add(new BasicNameValuePair("Authorization:
GoogleLogin auth=", authToken));
nameValuePairs.add(new BasicNameValuePair("registration_id",
regId));
nameValuePairs.add(new BasicNameValuePair("collapse_key", "TEST"));

// nameValuePairs.add(new
BasicNameValuePair("data.<key>","FirstNote.<First>"));

httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));

// Execute HTTP Post Request
System.out.println("Executing sendMessage");
System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
HttpResponse response = httpclient.execute(httppost);

BufferedReader in = new BufferedReader(new
InputStreamReader(response.getEntity().getContent()));
StringBuffer sb = new StringBuffer("");
String line = "";
String NL = System.getProperty("line.separator");
while ((line = in.readLine()) != null)
{
sb.append(line + NL);
}
in.close();
String result = sb.toString();
System.out.println("Final Result=" + result);

} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
} catch (IOException e) {
// TODO Auto-generated catch block
}
//sendOther(authToken);

}

Still i get 401 Unauthorized exception.

One thing i wanted to know is is there any error in my HttpPost
implementation (in 3rd party app) or in registration process of my
android application.

Thank you

On Jan 17, 11:33 pm, debajit <deba...@android.com> wrote:
> hi D,
>
> what account are you using to authenticate your requests to the C2DM
> server?  you need to use the role account (not a personal/user account
> used on one of your target devices) specified when you signed up for
> the C2DM service.
>
> thx, debajit
>
> ...
>
> read more »

D KYON

unread,
Jan 19, 2011, 2:22:48 AM1/19/11
to android-c2dm
Hi all,

Thanks for your support and help.
I made it work.

Initially i tried settign the header as given below
httppost.addHeader("Authorization: GoogleLogin auth=", authToken)

later i changed it to
httppost.addHeader("Authorization", "GoogleLogin auth="+authToken);
it worked for me, now am able to send messages for my android.

Thank you
> Am getting the authToken from google i.ehttps://www.google.com/accounts/ClientLogin.
> ...
>
> read more »

roshan

unread,
Feb 10, 2011, 7:43:59 AM2/10/11
to android-c2dm
D KYON,

Could you plz tell me u used servlets...
I am getting 401 error..

roshan

unread,
Feb 10, 2011, 8:14:31 AM2/10/11
to android-c2dm

HI D KYON,

String token = userToken[3];
String regId =
"APA91bEkAt4uxQPzpfFSgsNaBj_ijRGp5h5smU7D8FHci0nVnArfZnyWMVQFqM7H9D-
XI1plM_o4B0a7BN23UlsxMwWBwrWUkWxSfXAkoPWYUw3F-5nltdo";
String suc = "yes got it";
URL url1 = new URL("http://android.apis.google.com/c2dm/send");
HttpURLConnection conn = (HttpURLConnection)url1.openConnection();
disableCertificateValidation();

conn.setDoOutput(true);
conn.setUseCaches(false);
conn.setRequestMethod("POST");
conn.usingProxy();
conn.setRequestProperty("Content-Type", "application/x-www-form-
urlencoded;charset=UTF-8");
conn.setRequestProperty("Content-
Length",Integer.toString(suc.length()));
conn.setRequestProperty("registration_id",regId);
conn.setRequestProperty("collapse_key","9774d56d682e549c");
conn.setRequestProperty("data.payload",suc);
conn.setRequestProperty( "Authorization: ","GoogleLogin auth=" +
token.trim());
OutputStreamWriter out = new
OutputStreamWriter(conn.getOutputStream());
out.write(suc);
out.close();
int responseCode = conn.getResponseCode();

This is the code i am using to send the msgs to the c2dm server, and i
am using servlets in tomcat server, plz suggest me if i am wrong.

Could u plz share the code.
> ...
>
> read more »

D KYON

unread,
Feb 10, 2011, 8:36:04 AM2/10/11
to android-c2dm
Hi Roshan,

I Dint use any servlet my requirement was different... from a
webservice i just make call to a static method


Code : -

Below given code is to get the Auth_token for ur 3rd party app server

public static void performAuthentication(String regId)
{
regId = "ur_app_registration_id";
// Create a new HttpClient and Post Header
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("https://www.google.com/accounts/
ClientLogin");

// this is for proxy settings
HttpHost proxy = new HttpHost("ur_proxy_server_url", 80, "http");
httpclient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY,
proxy);

HttpParams params = httpclient.getParams();
params.setParameter("content-type", "application/x-www-form-
urlencoded");
try {

// Add your data
List<NameValuePair> nameValuePairs = new
ArrayList<NameValuePair>(2);
nameValuePairs.add(new
BasicNameValuePair("accountType","HOSTED_OR_GOOGLE"));
nameValuePairs.add(new BasicNameValuePair("Email",
"ur_registered_email_id"));
nameValuePairs.add(new BasicNameValuePair("Passwd","*******"));
nameValuePairs.add(new BasicNameValuePair("service", "ac2dm"));
nameValuePairs.add(new BasicNameValuePair("source", "sourcename"));
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));

logger.info(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
logger.info("Execute HTTP Post Request");
logger.info(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
// Execute HTTP Post Requestu
HttpResponse response = httpclient.execute(httppost);
logger.info(response.getEntity().toString());
BufferedReader in = new BufferedReader(new
InputStreamReader(response.getEntity().getContent()));
StringBuffer sb = new StringBuffer("");
String line = "";

while ((line = in.readLine()) != null)
{
sb.append(line);
}
in.close();
String result = sb.toString();
// logger.info("Result=" + result);

String authToken=result.substring(result.indexOf("Auth=")+5);
// logger.info("Token=" + authToken);

logger.info("Result=="+result);
logger.info("Token="+authToken);
logger.info("SendingId="+regId);
logger.info(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");

RegistrationDao registrationDao = new RegistrationDao();
registrationDao.updateClientAuthToken(authToken.trim());

//sendMessage(regId, authToken.trim());

} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
} catch (IOException e) {
// TODO Auto-generated catch block
}

}


Following code is to send the message to C2DM server :

public static void sendMessage(String regId, String authToken, String
data)
{
logger.info("******************************");
logger.info("In sendMessage()");
logger.info("******************************");

logger.info("Sending Message");
logger.info(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
// Create a new HttpClient and Post Header
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("https://android.apis.google.com/
c2dm/send");

httppost.addHeader("Authorization", "GoogleLogin auth="+authToken);
httppost.addHeader("Content-Type","application/x-www-form-
urlencoded");

try
{
// Add your data
List<NameValuePair> nameValuePairs = new
ArrayList<NameValuePair>(2);
nameValuePairs.add( new BasicNameValuePair( "accountName",
"registered_email_id" ) );
nameValuePairs.add(new BasicNameValuePair("registration_id",
regId));
nameValuePairs.add(new BasicNameValuePair("collapse_key", "TEST"));
nameValuePairs.add(new BasicNameValuePair("data.payload",data));
//nameValuePairs.add(new BasicNameValuePair("service", "ac2dm"));
httppost.setEntity(new
UrlEncodedFormEntity(nameValuePairs,"UTF-8"));

// Execute HTTP Post Request
logger.info("Executing sendMessage");
logger.info(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
HttpResponse response = httpclient.execute(httppost);

logger.info("----------------------------------------");
logger.info(response.getStatusLine());
Header[] resHeader = response.getAllHeaders();
for (int i = 0; i < resHeader.length; i++)
{
logger.info("Header ["+i+"]:"+resHeader[i]);
logger.info(resHeader[i].getName());
logger.info(resHeader[i].getValue());
if(resHeader[i].toString().startsWith("Update-Client-Auth: "))
{
logger.info("*************************************");
logger.info(resHeader[i].toString());
RegistrationDao registrationDao = new RegistrationDao();

registrationDao.updateClientAuthToken(resHeader[i].toString().substring(resHeader[i].toString().indexOf("Update-
Client-Auth: ")+20));
}
}
logger.info("----------------------------------------");

if (response.getEntity() != null)
{
logger.info(EntityUtils.toString(response.getEntity()));
}

} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
} catch (IOException e) {
// TODO Auto-generated catch block
}

}


> ...
>
> read more »

roshan vidapanakal

unread,
Feb 10, 2011, 8:48:02 AM2/10/11
to androi...@googlegroups.com
I am getting problem while sending the registration id from android to tomcat server.
What is u r third party application server? How did u manage the things. could you plz tell me.
--
Regards,
Roshan

D KYON

unread,
Feb 11, 2011, 12:20:31 AM2/11/11
to androi...@googlegroups.com
Hi Roshan,

Android will call my webservices for registering the application with the server by passing the registrationId .. later it calls another webservices method to notify android.. the webservices method inturn call the c2dm for sending the notification message to android
--
Regards

Karthikeyan S
+91 9379182477

roshan vidapanakal

unread,
Feb 11, 2011, 12:32:47 AM2/11/11
to androi...@googlegroups.com

thanks for your reply. I am doing this in servlets using apache tomcat. But when i am using httpclient and running the program in tomcat its showing me "java.lang.
NoClassDefFoundError: org/apache/http/client/ClientProtocolException "

can i run this in tomcat, or do i need to set up xampp.
--
Regards,
Roshan

D KYON

unread,
Feb 11, 2011, 1:06:40 AM2/11/11
to android-c2dm
Hi Roshan,

Add Httpclient-4.0.jar / Httpcore-4.0.1.jar into ur tomcat lib... and
add the jars to the build path


On Feb 11, 10:32 am, roshan vidapanakal <roshanrani2...@gmail.com>
wrote:
> thanks for your reply. I am doing this in servlets using apache tomcat. But
> when i am using httpclient and running the program in tomcat its showing me
> "java.lang.
> NoClassDefFoundError: org/apache/http/client/ClientProtocolException "
>
> can i run this in tomcat, or do i need to set up xampp.
>
>
>
>
>
>
>
> On Fri, Feb 11, 2011 at 10:50 AM, D KYON <karthikeyan...@gmail.com> wrote:
> > Hi Roshan,
>
> > Android will call my webservices for registering the application with the
> > server by passing the registrationId .. later it calls another webservices
> > method to notify android.. the webservices method inturn call the c2dm for
> > sending the notification message to android
>
> > On Thu, Feb 10, 2011 at 7:18 PM, roshan vidapanakal <
> > roshanrani2...@gmail.com> wrote:
>
> >> I am getting problem while sending the registration id from android to
> >> tomcat server.
> >> What is u r third party application server? How did u manage the things.
> >> could you plz tell me.
>
> >>> registrationDao.updateClientAuthToken(resHeader[i].toString().substring(res Header[i].toString().indexOf("Update-
> ...
>
> read more »

roshan vidapanakal

unread,
Feb 11, 2011, 3:07:07 AM2/11/11
to androi...@googlegroups.com
Though I added the jars to the lib and to the build path it is showing the following exception "java.lang.NoClassDefFoundError: org/apache/http/params/SyncBasicHttpParams"
--
Regards,
Roshan

roshan vidapanakal

unread,
Feb 11, 2011, 4:25:09 AM2/11/11
to androi...@googlegroups.com
Hi D KYON,

I am able to send the msgs from the server and receive on the emulator.
Thanks for your help....
--
Regards,
Roshan

roshan vidapanakal

unread,
Feb 15, 2011, 2:18:19 AM2/15/11
to androi...@googlegroups.com
Hi D KYON,
What is the role account and the contact email while signing up for
c2dm

i am the application developer, i will get auth token for my email
account on the server side

if the other people wants to use my app (which as c2dm service) they
need to register and send the registration id to the server, then with
my auth token i'll send messages to that user.

is it correct.

does the user who wants to use my service needs to again sign up for
c2dm or only register.

if any one resolved this problem plz address here. i am in urgent need
of this.

--
Regards,
Roshan

anil kukreti

unread,
Feb 15, 2011, 3:39:57 AM2/15/11
to androi...@googlegroups.com
The android user just has to register with the already verified c2dm account.
--
Thanks for Cooperating!
 Anil Kukreti

We are not here for making a history.
We are here for making a future. !
09717125554
09312646623
Linked In : http://in.linkedin.com/in/anilkukreti
Blog : http://androidosbeginning.blogspot.com/
Skype Id : anil.kleward
Reply all
Reply to author
Forward
0 new messages