Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7611987
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T01:48:03+00:00 2026-05-31T01:48:03+00:00

I am new to Google App Engine (Java) and PayPal process. I am using

  • 0

I am new to Google App Engine (Java) and PayPal process. I am using tutorial provided http://googleappengine.blogspot.com/2010/06/paypal-introduces-paypal-x-platform.html and NOT sure why I am getting following exception:

Uncaught exception from servlet
java.lang.NoClassDefFoundError: com/paypal/adaptive/exceptions/AuthorizationRequiredException

Here is my Servlet Class file which suppose to do preapproval and provide preapproval key and authorization url ..

import java.io.IOException;
import java.util.logging.Logger;

import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.paypal.adaptive.api.requests.fnapi.ParallelPay;
import com.paypal.adaptive.api.responses.PayResponse;
import com.paypal.adaptive.core.APICredential;
import com.paypal.adaptive.core.AckCode;
import com.paypal.adaptive.core.CurrencyCodes;
import com.paypal.adaptive.core.PaymentType;
import com.paypal.adaptive.core.Receiver;
import com.paypal.adaptive.core.ServiceEnvironment;
import com.paypal.adaptive.exceptions.AuthorizationRequiredException;
import com.paypal.adaptive.exceptions.InvalidAPICredentialsException;
import com.paypal.adaptive.exceptions.InvalidResponseDataException;
import com.paypal.adaptive.exceptions.MissingAPICredentialsException;
import com.paypal.adaptive.exceptions.MissingParameterException;
import com.paypal.adaptive.exceptions.NotEnoughReceivers;
import com.paypal.adaptive.exceptions.PayPalErrorException;
import com.paypal.adaptive.exceptions.PaymentExecException;
import com.paypal.adaptive.exceptions.PaymentInCompleteException;
import com.paypal.adaptive.exceptions.ReceiversCountMismatchException;
import com.paypal.adaptive.exceptions.RequestAlreadyMadeException;
import com.paypal.adaptive.exceptions.RequestFailureException;


@SuppressWarnings("serial")
public class CWEMartServlet extends HttpServlet {
        private static final Logger log = Logger.getLogger(CWEMartServlet.class.getName());


        private static APICredential credentialObj;

        @Override
        public void init(ServletConfig config) throws ServletException {
                // TODO Auto-generated method stub
                super.init(config);

                // Get the value of APIUsername
                String APIUsername = getServletConfig().getInitParameter("PPAPIUsername"); 
                String APIPassword = getServletConfig().getInitParameter("PPAPIPassword"); 
                String APISignature = getServletConfig().getInitParameter("PPAPISignature"); 
                String AppID = getServletConfig().getInitParameter("PPAppID"); 
                String AccountEmail = getServletConfig().getInitParameter("PPAccountEmail");

                if(APIUsername == null || APIUsername.length() <= 0
                                || APIPassword == null || APIPassword.length() <=0 
                                || APISignature == null || APISignature.length() <= 0
                                || AppID == null || AppID.length() <=0 ) {
                        // requires API Credentials not set - throw exception
                        throw new ServletException("APICredential(s) missing");
                }

                credentialObj = new APICredential();
                credentialObj.setAPIUsername(APIUsername);
                credentialObj.setAPIPassword(APIPassword);
                credentialObj.setSignature(APISignature);
                credentialObj.setAppId(AppID);
                credentialObj.setAccountEmail(AccountEmail);
                log.info("Servlet initialized successfully");
        }

        public void doGet(HttpServletRequest req, HttpServletResponse resp)
        throws IOException {
                try {
                        String id = req.getParameter("id");
                        String title = req.getParameter("title");
                        String order = req.getParameter("order");
                        String returnParam = req.getParameter("return"); 
                        String cancel = req.getParameter("cancel");

                        if(cancel != null && cancel.equals("1")) {
                                // user canceled the payment
                                getServletConfig().getServletContext().getRequestDispatcher("/paymentcancel.jsp").forward(req, resp);

                        } else if(returnParam != null && returnParam.equals("1")){
                                getServletConfig().getServletContext().getRequestDispatcher("/paymentsuccess.jsp").forward(req, resp);

                        } else if(order != null && order.length() > 0){
                                // process order

                                try {


                                        StringBuilder url = new StringBuilder();
                                        url.append(req.getRequestURL());
                                        String returnURL = url.toString() + "?return=1&payKey=${payKey}&id="+ id + "&title=" + title;
                                        String cancelURL = url.toString() + "?cancel=1&id="+ id + "&title=" + title;
                                        //String ipnURL = url.toString() + "?action=ipn";

                                        ParallelPay parallelPay = new ParallelPay(2);
                                        parallelPay.setCancelUrl(cancelURL);
                                        parallelPay.setReturnUrl(returnURL);
                                        parallelPay.setCredentialObj(credentialObj);
                                        parallelPay.setUserIp(req.getRemoteAddr());
                                        parallelPay.setApplicationName("Sample app on GAE");
                                        parallelPay.setCurrencyCode(CurrencyCodes.USD);
                                        parallelPay.setEnv(ServiceEnvironment.SANDBOX);
                                        //parallelPay.setIpnURL(ipnURL);
                                        parallelPay.setLanguage("en_US");
                                        parallelPay.setMemo(title);

                                        // set the receivers
                                        Receiver primaryReceiver = new Receiver();
                                        primaryReceiver.setAmount(5.0);
                                        primaryReceiver.setEmail("jagdis_1325390370_biz@yahoo.com");
                                        primaryReceiver.setPaymentType(PaymentType.GOODS);
                                        parallelPay.addToReceivers(primaryReceiver);

                                        // set the second receivers
                                        Receiver rec1 = new Receiver();
                                        rec1.setAmount(3.0);
                                        rec1.setEmail("jagdis_1331173124_biz@yahoo.com");
                                        rec1.setPaymentType(PaymentType.GOODS);
                                        parallelPay.addToReceivers(rec1);

                                        PayResponse payResponse = parallelPay.makeRequest();
                                        log.info("Payment success - payKey:" + payResponse.getPayKey());

                                } catch (IOException e) {
                                        resp.getWriter().println("Payment Failed w/ IOException");
                                } catch (MissingAPICredentialsException e) {
                                        // No API Credential Object provided - log error
                                        e.printStackTrace();
                                        resp.getWriter().println("No APICredential object provided");
                                } catch (InvalidAPICredentialsException e) {
                                        // invalid API Credentials provided - application error - log error
                                        e.printStackTrace();
                                        resp.getWriter().println("Invalid API Credentials " + e.getMissingCredentials());
                                } catch (MissingParameterException e) {
                                        // missing parameter - log  error
                                        e.printStackTrace();
                                        resp.getWriter().println("Missing Parameter error: " + e.getParameterName());
                                } catch(ReceiversCountMismatchException e){
                                        // missing receiver - log  error
                                        e.printStackTrace();
                                        resp.getWriter().println("Receiver count did not match - expected: " 
                                                        + e.getExpectedNumberOfReceivers() 
                                                        + " - actual:" + e.getActualNumberOfReceivers());                       
                                } catch (RequestFailureException e) {
                                        // HTTP Error - some connection issues ?
                                        e.printStackTrace();
                                        resp.getWriter().println("Request HTTP Error: " + e.getHTTP_RESPONSE_CODE());
                                } catch (InvalidResponseDataException e) {
                                        // PayPal service error 
                                        // log error
                                        e.printStackTrace();
                                        resp.getWriter().println("Invalid Response Data from PayPal: \"" + e.getResponseData() + "\"");
                                } catch (PayPalErrorException e) {
                                        // Request failed due to a Service/Application error
                                        e.printStackTrace();
                                        if(e.getResponseEnvelope().getAck() == AckCode.Failure){
                                                // log the error
                                                resp.getWriter().println("Received Failure from PayPal (ack)");
                                                resp.getWriter().println("ErrorData provided:");
                                                resp.getWriter().println(e.getPayErrorList().toString());
                                                if(e.getPaymentExecStatus() != null){
                                                        resp.getWriter().println("PaymentExecStatus: " + e.getPaymentExecStatus());
                                                }
                                        } else if(e.getResponseEnvelope().getAck() == AckCode.FailureWithWarning){
                                                // there is a warning - log it!
                                                resp.getWriter().println("Received Failure with Warning from PayPal (ack)");
                                                resp.getWriter().println("ErrorData provided:");
                                                resp.getWriter().println(e.getPayErrorList().toString());
                                        }
                                } catch (RequestAlreadyMadeException e) {
                                        // shouldn't occur - log the error
                                        e.printStackTrace();
                                        resp.getWriter().println("Request to send a request that has already been sent!");
                                } catch (PaymentExecException e) {

                                        resp.getWriter().println("Failed Payment Request w/ PaymentExecStatus: " + e.getPaymentExecStatus().toString());
                                        resp.getWriter().println("ErrorData provided:");

                                        resp.getWriter().println(e.getPayErrorList().toString());
                                }catch (PaymentInCompleteException e){
                                        resp.getWriter().println("Incomplete Payment w/ PaymentExecStatus: " + e.getPaymentExecStatus().toString());
                                        resp.getWriter().println("ErrorData provided:");

                                        resp.getWriter().println(e.getPayErrorList().toString());                       
                                } catch (NumberFormatException e) {
                                        // invalid number passed
                                        e.printStackTrace();
                                        resp.getWriter().println("Invalid number of receivers sent");

                                } catch (NotEnoughReceivers e) {
                                        // not enough receivers - min requirements for Parallel pay not met
                                        e.printStackTrace();
                                        resp.getWriter().println("Min number of receivers not met - Min Required:"
                                                        + e.getMinimumRequired() + " - actual set:" + e.getActualNumber());
                                } catch (AuthorizationRequiredException e) {
                                        // redirect the user to PayPal for Authorization
                                         resp.getWriter().println("\"PPAuthzUrl\": \"" + e.getAuthorizationUrl(ServiceEnvironment.SANDBOX) + "\", \"Status\": \"CREATED\"");
                                         // resp.sendRedirect(e.getAuthorizationUrl(ServiceEnvironment.SANDBOX));
                                      // resp.getWriter().println("\"PPAuthzUrl\": \"" + e.getEmbeddedPaymentsAuthorizationUrl(ServiceEnvironment.SANDBOX, ExpType.LIGHTBOX) + "\", \"Status\": \"CREATED\"");
                                }



                        } else if(id == null || id.length() <= 0) {

                                getServletConfig().getServletContext().getRequestDispatcher("/index.jsp").forward(req, resp);


                        } else {
                                getServletConfig().getServletContext().getRequestDispatcher("/order.jsp").forward(req, resp);
                        }
                } catch (Exception e) {
                        e.printStackTrace();
                }
        }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T01:48:04+00:00Added an answer on May 31, 2026 at 1:48 am

    Check if you have the paypal.jar in lib directory. If you are not sure, unjar the paypal related lib files and check if you have AuthorizationRequiredException.class in at least one of them.

    enter image description here

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to login to a website using java.net in Google App Engine
I'm trying to access an OAuth-protected resource on Google App Engine using a Java/Groovy
I'm looking at Google App Engine's new task queue API for Java and I'm
I'm new to Java server programming, and I'm trying to use Google app engine.
I'm running a java code for getting info from a google-app-engine web service (testeserjaum.appspot.com),
I'm using the low-level API in Google App Engine for Java and want to
I'm currently working on a SalesForce.com tutorial entitled Force.com for Google App Engine for
Im having a weird compile issue using the Google App engine in java using
I Followed this tutorial for my Restlet server in the Google App Engine: http://wiki.restlet.org/docs_2.0/13-restlet/21-restlet/318-restlet/303-restlet.html
I am new to both Stack overflow and Google app engine. in a Java

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.