Artem24 / gwtgae2011

Automatically exported from code.google.com/p/gwtgae2011
0 stars 0 forks source link

Google TaskQueue Does't Work #1

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?

Add this AdminServlet.java

package com.googlecode.gwtgae2011.server;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.HashMap;

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

import com.google.inject.Inject;
import com.google.inject.Provider;
import com.google.inject.Singleton;

@Singleton
public class AdminTasksServlet extends HttpServlet {

    private static final long serialVersionUID = 8966436970643695867L;

    @Inject
    public AdminTasksServlet(){};

    @Override
    public void doGet(HttpServletRequest request, HttpServletResponse response)
            throws IOException, ServletException {
        doPost(request, response);
    }

    @Override
    public void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {

        response.setHeader("Cache-Control", "no-cache");
        PrintWriter out = response.getWriter();
        String actionVal = request.getParameter("action");
        String taskWasAttempted = " yes ";
        String debugMessage = "";

        if(actionVal.equals("create")){
            SohoTaskCreator.refreshGoogleAppsDomainAccess("Gene");
            taskWasAttempted = "no created";
        }

        out.write("Action: " + actionVal + ",  Task was attempeted: " + taskWasAttempted + ", " + debugMessage);
        out.close();
    }
}

SohoTaskCreator.refreshGoogleAppsDomainAccess is a static method below:

public static void refreshGoogleAppsDomainAccess(String domainName) {
        Queue queue = QueueFactory.getQueue("default");
        queue.add(TaskOptions.Builder.withUrl("/tasks/currentUserAction/")
                .param("action", "updateDomain").param("domain", domainName));
    }

Then bind in the GwtGae2011ServletModule.java
bind(AdminTasksServlet.class).in(Singleton.class);
    serve("/tasks/*").with(AdminTasksServlet.class);

Also create the queue.xml:
<queue-entries>
  <queue>
    <name>default</name>
    <rate>1/s</rate>
  </queue>
</queue-entries>

Start the product in debug mode then navigate to this URL to initiate a task:
http://127.0.0.1:8888/tasks/?action=create

What is the expected output? What do you see instead?
Expected: Task created

Actual:
HTTP ERROR 500

Problem accessing /tasks/. Reason:

    org.quartz.SchedulerConfigException: Unable to instantiate class load helper class: org.quartz.simpl.CascadingClassLoadHelper cannot be cast to org.quartz.spi.ClassLoadHelper [See nested exception: java.lang.ClassCastException: org.quartz.simpl.CascadingClassLoadHelper cannot be cast to org.quartz.spi.ClassLoadHelper]
Caused by:

java.lang.RuntimeException: org.quartz.SchedulerConfigException: Unable to 
instantiate class load helper class: org.quartz.simpl.CascadingClassLoadHelper 
cannot be cast to org.quartz.spi.ClassLoadHelper [See nested exception: 
java.lang.ClassCastException: org.quartz.simpl.CascadingClassLoadHelper cannot 
be cast to org.quartz.spi.ClassLoadHelper]
    at com.google.appengine.api.taskqueue.dev.LocalTaskQueue.startScheduler(LocalTaskQueue.java:442)
    at com.google.appengine.api.taskqueue.dev.LocalTaskQueue.start_(LocalTaskQueue.java:196)
    at com.google.appengine.api.taskqueue.dev.LocalTaskQueue.access$000(LocalTaskQueue.java:51)
    at com.google.appengine.api.taskqueue.dev.LocalTaskQueue$2.run(LocalTaskQueue.java:163)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.google.appengine.api.taskqueue.dev.LocalTaskQueue.start(LocalTaskQueue.java:160)
    at com.google.appengine.tools.development.ApiProxyLocalImpl.startServices(ApiProxyLocalImpl.java:477)
    at com.google.appengine.tools.development.ApiProxyLocalImpl.access$600(ApiProxyLocalImpl.java:46)
    at com.google.appengine.tools.development.ApiProxyLocalImpl$1.run(ApiProxyLocalImpl.java:459)
    at com.google.appengine.tools.development.ApiProxyLocalImpl$1.run(ApiProxyLocalImpl.java:457)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.google.appengine.tools.development.ApiProxyLocalImpl.getService(ApiProxyLocalImpl.java:456)
    at com.google.appengine.tools.development.ApiProxyLocalImpl$AsyncApiCall.callInternal(ApiProxyLocalImpl.java:372)
    at com.google.appengine.tools.development.ApiProxyLocalImpl$AsyncApiCall.call(ApiProxyLocalImpl.java:364)
    at com.google.appengine.tools.development.ApiProxyLocalImpl$AsyncApiCall.call(ApiProxyLocalImpl.java:343)
    at java.util.concurrent.Executors$PrivilegedCallable$1.run(Executors.java:463)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.util.concurrent.Executors$PrivilegedCallable.call(Executors.java:460)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:680)
Caused by: org.quartz.SchedulerConfigException: Unable to instantiate class 
load helper class: org.quartz.simpl.CascadingClassLoadHelper cannot be cast to 
org.quartz.spi.ClassLoadHelper [See nested exception: 
java.lang.ClassCastException: org.quartz.simpl.CascadingClassLoadHelper cannot 
be cast to org.quartz.spi.ClassLoadHelper]
    at org.quartz.impl.StdSchedulerFactory.instantiate(StdSchedulerFactory.java:549)
    at org.quartz.impl.StdSchedulerFactory.getScheduler(StdSchedulerFactory.java:1152)
    at org.quartz.impl.StdSchedulerFactory.getDefaultScheduler(StdSchedulerFactory.java:1168)
    at com.google.appengine.api.taskqueue.dev.LocalTaskQueue.startScheduler(LocalTaskQueue.java:432)
    ... 22 more
Caused by:

org.quartz.SchedulerConfigException: Unable to instantiate class load helper 
class: org.quartz.simpl.CascadingClassLoadHelper cannot be cast to 
org.quartz.spi.ClassLoadHelper [See nested exception: 
java.lang.ClassCastException: org.quartz.simpl.CascadingClassLoadHelper cannot 
be cast to org.quartz.spi.ClassLoadHelper]
    at org.quartz.impl.StdSchedulerFactory.instantiate(StdSchedulerFactory.java:549)
    at org.quartz.impl.StdSchedulerFactory.getScheduler(StdSchedulerFactory.java:1152)
    at org.quartz.impl.StdSchedulerFactory.getDefaultScheduler(StdSchedulerFactory.java:1168)
    at com.google.appengine.api.taskqueue.dev.LocalTaskQueue.startScheduler(LocalTaskQueue.java:432)
    at com.google.appengine.api.taskqueue.dev.LocalTaskQueue.start_(LocalTaskQueue.java:196)
    at com.google.appengine.api.taskqueue.dev.LocalTaskQueue.access$000(LocalTaskQueue.java:51)
    at com.google.appengine.api.taskqueue.dev.LocalTaskQueue$2.run(LocalTaskQueue.java:163)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.google.appengine.api.taskqueue.dev.LocalTaskQueue.start(LocalTaskQueue.java:160)
    at com.google.appengine.tools.development.ApiProxyLocalImpl.startServices(ApiProxyLocalImpl.java:477)
    at com.google.appengine.tools.development.ApiProxyLocalImpl.access$600(ApiProxyLocalImpl.java:46)
    at com.google.appengine.tools.development.ApiProxyLocalImpl$1.run(ApiProxyLocalImpl.java:459)
    at com.google.appengine.tools.development.ApiProxyLocalImpl$1.run(ApiProxyLocalImpl.java:457)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.google.appengine.tools.development.ApiProxyLocalImpl.getService(ApiProxyLocalImpl.java:456)
    at com.google.appengine.tools.development.ApiProxyLocalImpl$AsyncApiCall.callInternal(ApiProxyLocalImpl.java:372)
    at com.google.appengine.tools.development.ApiProxyLocalImpl$AsyncApiCall.call(ApiProxyLocalImpl.java:364)
    at com.google.appengine.tools.development.ApiProxyLocalImpl$AsyncApiCall.call(ApiProxyLocalImpl.java:343)
    at java.util.concurrent.Executors$PrivilegedCallable$1.run(Executors.java:463)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.util.concurrent.Executors$PrivilegedCallable.call(Executors.java:460)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:680)
* Nested Exception (Underlying Cause) ---------------
java.lang.ClassCastException: org.quartz.simpl.CascadingClassLoadHelper cannot 
be cast to org.quartz.spi.ClassLoadHelper
    at org.quartz.impl.StdSchedulerFactory.instantiate(StdSchedulerFactory.java:546)
    at org.quartz.impl.StdSchedulerFactory.getScheduler(StdSchedulerFactory.java:1152)
    at org.quartz.impl.StdSchedulerFactory.getDefaultScheduler(StdSchedulerFactory.java:1168)
    at com.google.appengine.api.taskqueue.dev.LocalTaskQueue.startScheduler(LocalTaskQueue.java:432)
    at com.google.appengine.api.taskqueue.dev.LocalTaskQueue.start_(LocalTaskQueue.java:196)
    at com.google.appengine.api.taskqueue.dev.LocalTaskQueue.access$000(LocalTaskQueue.java:51)
    at com.google.appengine.api.taskqueue.dev.LocalTaskQueue$2.run(LocalTaskQueue.java:163)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.google.appengine.api.taskqueue.dev.LocalTaskQueue.start(LocalTaskQueue.java:160)
    at com.google.appengine.tools.development.ApiProxyLocalImpl.startServices(ApiProxyLocalImpl.java:477)
    at com.google.appengine.tools.development.ApiProxyLocalImpl.access$600(ApiProxyLocalImpl.java:46)
    at com.google.appengine.tools.development.ApiProxyLocalImpl$1.run(ApiProxyLocalImpl.java:459)
    at com.google.appengine.tools.development.ApiProxyLocalImpl$1.run(ApiProxyLocalImpl.java:457)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.google.appengine.tools.development.ApiProxyLocalImpl.getService(ApiProxyLocalImpl.java:456)
    at com.google.appengine.tools.development.ApiProxyLocalImpl$AsyncApiCall.callInternal(ApiProxyLocalImpl.java:372)
    at com.google.appengine.tools.development.ApiProxyLocalImpl$AsyncApiCall.call(ApiProxyLocalImpl.java:364)
    at com.google.appengine.tools.development.ApiProxyLocalImpl$AsyncApiCall.call(ApiProxyLocalImpl.java:343)
    at java.util.concurrent.Executors$PrivilegedCallable$1.run(Executors.java:463)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.util.concurrent.Executors$PrivilegedCallable.call(Executors.java:460)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:680)

Original issue reported on code.google.com by drgenejones on 10 Mar 2011 at 7:07

GoogleCodeExporter commented 8 years ago
Workaround : 

Ok I found a workaround if I comment these lines out of the pom.xml it works.

        <!-- AppEngine Testing Dependencies -->
        <!--
        <dependency>
            <groupId>com.google.appengine</groupId>
            <artifactId>appengine-testing</artifactId>
            <version>${gae.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.google.appengine</groupId>
            <artifactId>appengine-api-stubs</artifactId>
            <version>${gae.version}</version>
            <scope>test</scope>
        </dependency>
         -->

These are being copied to the target/<Project name>-<Version>/WEB-INF/lib  and 
should only (I think) be used when testing.  I tried altering the Maven 
configuration, but my Maven knowledge isn't that great so couldn't prevent them 
from being copied.  I will update the issue as a workaround but just wanted to 
let you know what I found.

Original comment by drgenejones on 10 Mar 2011 at 10:30