Google API in Java vs. Struts
<p>If I use the below method to get the token of Google account using a normal Java project, it works absolutely fine, but if I use that same code in my Struts project, it gives me a <code>ClassNotFoundException</code>. Could someone please tell me why it is throwing the exception? I am lost.   </p>

<pre><code>public String Login(String username,String password){
    String token = null;
     HttpClient client = new DefaultHttpClient();
     String postURL = "https://www.google.com/accounts/ClientLogin";
     HttpPost post = new HttpPost(postURL);
     List&lt;NameValuePair&gt; nvps = new ArrayList&lt;NameValuePair&gt;();
     nvps.add(new BasicNameValuePair("accountType", "HOSTED_OR_GOOGLE"));
     nvps.add(new BasicNameValuePair("Email", username));
     nvps.add(new BasicNameValuePair("Passwd", password));
     nvps.add(new BasicNameValuePair("service", "cp"));// Name of Google service 
     nvps.add(new BasicNameValuePair("source", "feras-MeAndTheGreenRobot-1.0"));
     UrlEncodedFormEntity ent;
     try {
             ent = new UrlEncodedFormEntity(nvps, HTTP.UTF_8);
             post.setEntity(ent);
             HttpResponse responsePOST = client.execute(post);
             HttpEntity resEntity = responsePOST.getEntity();
             if (resEntity != null) {
                      String authToken=  EntityUtils.toString(resEntity);
                     System.out.println("RESPONSE is "+ authToken );
 token = authToken.substring(authToken.indexOf("Auth=") + 5, authToken.length()).trim();
                     System.out.println("Auth is "+  authToken.substring(authToken.indexOf("Auth=") + 5, authToken.length()).trim());
             }
     } catch (UnsupportedEncodingException e) {
             e.printStackTrace();
     } catch (ClientProtocolException e) {
             e.printStackTrace();
     } catch (IOException e) {
             e.printStackTrace();
     }
    return token;
}
</code></pre>

<p>Exception</p>

<pre><code>java.lang.ClassNotFoundException: org.apache.http.client.ClientProtocolException
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1701)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1546)
at com.struts.action.LoginAction.submit(LoginAction.java:85)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:404)
at com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:267)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:229)
at com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:221)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:86)
at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
at com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:150)
at org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:48)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:86)
at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
at com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:123)
at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:184)
</code></pre>
