1

I have two modules in application. First module is producing tasks for second module via Push Queue. Both modules use manual scaling.

Queue queue = QueueFactory.getQueue("update-job");
ModulesService ms = ModulesServiceFactory.getModulesService();
queue.add(TaskOptions.Builder.withUrl("/update-job").header("Host", ms.getVersionHostname("batch", ms.getCurrentVersion())));

I use "Host" header to route tasks to second app because of this bug https://code.google.com/p/googleappengine/issues/detail?id=10954

If I use plain old web.xml for servlet to url mapping everything works fine, all requests to version host will be successfully routed to instance and executed. But if I switch to GuiceFilter the same requests will produce 404 on version url. They are still available on instance url, but there will be no automatic routing from version url. Both configurations works fine on production, only devserver is affected.

I'm obviously missing something, because I can't find anything about this problem.

I tried different guice and guice-servlet versions: 3.0, 3.0.1-SNAPSHOT, 3.1.0-SNAPSHOT, 4.0-beta4 - no result

Also tried this approach https://stackoverflow.com/a/9706953/4070223 - no result

This is what web.xml looks like:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee" version="2.5">
<filter> <!-- does not work -->
    <filter-name>guiceFilter</filter-name>
    <filter-class>com.google.inject.servlet.GuiceFilter</filter-class>
</filter>
<filter-mapping>
    <filter-name>guiceFilter</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>

<!--<servlet>-->  <!-- works fine -->
    <!--<servlet-name>update-job</servlet-name>-->
    <!--<servlet-class>com.company.UpdateJobServlet</servlet-class>-->
<!--</servlet>-->
<!--<servlet-mapping>-->
    <!--<servlet-name>update-job</servlet-name>-->
    <!--<url-pattern>/update-job</url-pattern>-->
<!--</servlet-mapping>-->

<welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
</welcome-file-list>

<listener>
    <listener-class>com.company.BatchContextListener</listener-class>
</listener>
</web-app>

ContextListener:

public class BatchContextListener extends com.google.inject.servlet.GuiceServletContextListener {
    @Override
    protected Injector getInjector() {
        return Guice.createInjector(new BatchModule());
    }
}

And module:

public class BatchModule extends ServletModule {
    @Override
    protected void configureServlets() {
        serve("/update-job").with(UpdateJobServlet.class);
    }
}
Community
  • 1
  • 1
  • you don't show the guice modules you are using to build the injector? guice is magic, but the magic requires some incantation on your part. –  Sep 23 '14 at 11:52
  • @JarrodRoberson Module is extremely simple. Edited post. – Alexander Urmuzov Sep 23 '14 at 12:21
  • there is nothing about the version information in that binding, why do you think it should magically infer anything past `/update-job`? –  Sep 23 '14 at 12:23
  • @JarrodRoberson What do you mean by version information in binding? Don't quite understand. My binding is the same as here https://github.com/google/guice/wiki/GoogleAppEngine for example. – Alexander Urmuzov Sep 23 '14 at 12:34

2 Answers2

2

First read about routing requests on the dev server. Make sure your modules are up and answering on those urls. Then make sure that task queue is being routed to the right module.

Alternatively: use target directive in the queues.xml instead of the Host header. I believe this is a cleaner approach, because you do not pollute source code with routing specifics.

Peter Knego
  • 79,991
  • 11
  • 123
  • 154
2

It's a known issue that filter is not honored by backends (now modules) since Aug 19, 2013. Please go and vote for it here, https://code.google.com/p/googleappengine/issues/detail?id=9859

Frank R.
  • 1,732
  • 18
  • 21
  • I'm encountering a similar issue where Blobstore upload callbacks don't work (meaning return 404) when accessing urls served by filters. Only in dev server. The devserver seems to not account for filters well. – Dominykas Mostauskis Oct 16 '15 at 10:25
  • Do you have the problem on additional module, or the default one? – Frank R. Nov 23 '15 at 04:49
  • I don't use modules. At least not explicitly. – Dominykas Mostauskis Dec 02 '15 at 13:06
  • I will encourage you to use the app engine version 1.9.46 to solve this issu, I had a similar problem integrating Guice with GAE 1.9.37 but the problem vanished after I upgraded the project to 1.9.46 – Jorge P. Nov 13 '16 at 17:31