0

When I try to add to the queue, it gives this exception. It works in development but not production.

Caused by: java.lang.IllegalArgumentException: Invalid URL : null
    at com.google.appengine.api.taskqueue.QueueApiHelper.translateError(QueueApiHelper.java:116)
    at com.google.appengine.api.taskqueue.QueueImpl$2.wrap(QueueImpl.java:549)
    at com.google.appengine.api.taskqueue.QueueImpl$2.wrap(QueueImpl.java:521)
    at com.google.appengine.api.utils.FutureWrapper.wrapAndCache(FutureWrapper.java:53)
    at com.google.appengine.api.utils.FutureWrapper.get(FutureWrapper.java:90)
    at com.google.appengine.api.utils.FutureWrapper.get(FutureWrapper.java:86)
    at com.google.appengine.api.taskqueue.QueueApiHelper.getInternal(QueueApiHelper.java:72)
    at com.google.appengine.api.taskqueue.QueueImpl.add(QueueImpl.java:413)
    at com.onixnet.sdm.server.SDMServiceImpl.sendEmails(SDMServiceImpl.java:155)

Code

    queue.add(withUrl("/worker").param("userId", Utils.getUserId()).param("storeType", storeType)
            .param("associate", String.valueOf(associate)).param("fsm", String.valueOf(fsm)).param("sa", String.valueOf(sa))
            .param("other1", String.valueOf(other1)).param("other1Str", other1Str).param("other2", String.valueOf(other2)).param("other2", other2Str)
            .param("folder", folder).param("folderId", folderId)
            .param("from", getUserEmail()).param("subject", subject).param("body", body)
            .method(Method.GET));

web.xml

<servlet>
    <servlet-name>Worker</servlet-name>
    <servlet-class>com.onixnet.sdm.server.WorkerServlet</servlet-class>
</servlet>
<servlet-mapping>
    <servlet-name>Worker</servlet-name>
    <url-pattern>/worker</url-pattern>
</servlet-mapping>

queue.xml

<queue-entries>
    <queue>
        <name>default</name>
        <rate>1/s</rate>
    </queue> 
</queue-entries>

Reference

https://developers.google.com/appengine/docs/java/taskqueue/overview-push

Chloe
  • 25,162
  • 40
  • 190
  • 357
  • Break that complicated chained cascade of method calls into a sequence of simple assignments to intermediate variables. Then test each one for null. – Martin Berends Feb 26 '14 at 11:21
  • The null doesn't come from any of the parameters. If you notice the exception, it is an IllegalArgumentException and it comes from within Google TaskQueue package. `withUrl()` is clearly not null. – Chloe Feb 26 '14 at 11:24
  • Sorry, complicated code like this does not fit inside my little head. I cannot debug it without it hurting my brain. Of course it's not the parameters, it's the return value from one of the 16 chained method calls that received a non-null parameter that contains a wrong value. Let me put it another way, please refactor the code for easier maintainability. – Martin Berends Feb 26 '14 at 11:32
  • As another troubleshooting approach, on the working development server, what happens if you change "folderId" (the String) to "folderOMG"? Does it all still work? – Martin Berends Feb 26 '14 at 11:42

1 Answers1

2

I had to use Method.POST instead of GET, and in the worker task servlet, use doPost(). I believe the request was too large for a GET. The problem was Google did not provide a useful error message, and instead used a cryptic one.

Chloe
  • 25,162
  • 40
  • 190
  • 357