views:

88

answers:

1

I'm using Google App Engine to process Paypal IPN messages, when my servlet starts I use the following lines to start another process to process massages :

public class PayPal_Monitor_Servlet extends HttpServlet
{
  PayPal_Message_To_License_File_Worker PayPal_message_to_license_file_worker;

  public void init(ServletConfig config) throws ServletException               // Initializes the servlet.
  {
    super.init(config);
    PayPal_message_to_license_file_worker=new PayPal_Message_To_License_File_Worker();
   }

  public void doGet(HttpServletRequest request,HttpServletResponse response) throws IOException
  {
  }

...
}

public class PayPal_Message_To_License_File_Worker implements Runnable
{
  static Thread PayPal_Message_To_License_File_Thread;
...

  PayPal_Message_To_License_File_Worker()
  {
    start();
  }

  void start()
  {
    if (PayPal_Message_To_License_File_Thread==null)
    {
      PayPal_Message_To_License_File_Thread=new Thread(this);
      PayPal_Message_To_License_File_Thread.setPriority(Thread.MIN_PRIORITY);
      PayPal_Message_To_License_File_Thread.start();
    }
...
  }

But "PayPal_Message_To_License_File_Thread=new Thread(this);" is causing the following error :

javax.servlet.ServletContext log: unavailable
java.security.AccessControlException: access denied (java.lang.RuntimePermission modifyThreadGroup)
    at java.security.AccessControlContext.checkPermission(AccessControlContext.java:355)
    at java.security.AccessController.checkPermission(AccessController.java:567)

Why, how to fix it ?

Frank

+3  A: 

You cannot use Threads in GAE. Here is a list of things you cannot do in GAE:

If you want to do something asynchronously, look into TaskQueues.

Romain Hippeau