Testing locally theTaskQueue

109 views
Skip to first unread message

Roxana Ioana Roman

unread,
Jul 25, 2017, 10:50:32 AM7/25/17
to Google App Engine
In order to do some unit tests for a method that uses the TaskQueue, I have included the following dependencies in my pom:

<dependency>

<groupId>com.google.appengine</groupId>

<artifactId>appengine-testing</artifactId>

<version>${appengine.target.version}</version>

<scope>test</scope>

</dependency>

<dependency>

<groupId>com.google.appengine</groupId>

<artifactId>appengine-api-stubs</artifactId>

<version>${appengine.target.version}</version>

<scope>test</scope>

</dependency>

where the ${appengine.target.version is 1.9.42. My test works fine. However, as soon as the appengine-api-stubs dependency wass added to my pom other tests started failing. It seems to interfere with the org.hsql dependency because the tests fail with this error:

java.lang.NoSuchMethodError: org.hsqldb.DatabaseURL.parseURL(Ljava/lang/String;ZZ)Lorg/hsqldb/persist/HsqlProperties;

I checked the appengine-api-stubs and it uses a class: org.quartz.impl.jdbcjobstore.HSQLDBDelegate.class, which I thought might be the problem. I added an <exclusion> of the org.quartz.scheduler, but the error remained the same.

mvn dependency:tree -Dverbose -Dincludes=org.hsqldb:hsqldb does not show other transitive dependencies or versions of hsqldb except the 2.3.2 I have declared in the pom. Tried to add newer versions of hsql dependency, nothing changed. 
appengine-api
appengine-api-labs
appengine-tools-api
dependencies to my pom, same error.

As soon as I remove the appengine-api-stubs dependency and comment my test with the local task queue, all tests pass.

Any ideas about this?

George (Cloud Platform Support)

unread,
Jul 25, 2017, 12:55:28 PM7/25/17
to Google App Engine
Hello Roxana, 

Have you tried altering maven dependencies to specify the actual app engine target version directly? It seems a library version is called at compile time and another at run time.  The latest hsqldb version is 2.4.0, not 2.3.2. This might get called somehow and conflict with the version you declared in the pom. 

You may check the replies to the "NoSuchMethodError - org.hsqldb.DatabaseURL.parseURL" question from stackoverflow for relevant details. [1]

Roxana Ioana Roman

unread,
Jul 25, 2017, 1:16:23 PM7/25/17
to Google App Engine
Hi,
yes I tried using the version directly and also tried other newer versions on hsqldb including 2.4.0. I saw the answers on stackoverflow and tried scope: test, runtime, compile. Same error, unfortunately.

Roxana Ioana Roman

unread,
Jul 25, 2017, 2:58:34 PM7/25/17
to Google App Engine
When extracting the  appengine-api-stubs-1.9.42.jar I could see that there is a  org/hsqldb/DatabaseURL.class. I suspect that this class does not have the 
parseURL method, which causes the error. I don't know why the applications is using this class instead of the DatabaseURL class from the org.hsql dependency, even though I added runtime scope on the dependency.

I also tried using the Maven shade plugin:
<plugin>

            <groupId>org.apache.maven.plugins</groupId>

            <artifactId>maven-shade-plugin</artifactId>

            <version>2.4.3</version>

            <executions>

                <execution>

                    <phase>package</phase>

                    <goals>

                        <goal>shade</goal>

                    </goals>

                    <configuration>

                        <filters>

                            <filter>

                                <artifact>com.google.appengine:appengine-api-stubs</artifact>

                                <excludes>

                                    <exclude>org/hsqldb/DatabaseURL.class</exclude>

                                </excludes>

                            </filter>

                        </filters>

                    </configuration>

                </execution>

            </executions>

        </plugin>


Running
mvn dependency:tree -Ddetail=true
gives
+- org.hsqldb:hsqldb:jar:2.3.2:runtime

Roxana Ioana Roman

unread,
Jul 25, 2017, 3:39:00 PM7/25/17
to Google App Engine
Looking at the DatabaseURL class from the appengine-api-stubs jar in folder org.hsql, this class has a method: 

public static org.hsqldb.persist.HsqlProperties parseURL(java.lang.String, boolean);

While the DatabaseURL class from org.hsql:2.3.2 dependency has a method:

public static HsqlProperties parseURL(String url, boolean hasPrefix, boolean noPath)


My test is looking for : parseURL(Ljava/lang/String;ZZ)
ZZ-meaning 2 booleans so looking for the DatabaseURL.parseURL in the org.hsql dependency. However, it finds the one that comes with appengine-api-stubs.
How could I force it to use the right one? Thanks!

George (Cloud Platform Support)

unread,
Jul 25, 2017, 4:00:06 PM7/25/17
to Google App Engine
Have you tried to exclude the unwanted class with something like mvn dependency:tree -Dexcludes=org.codehaus.plexus ? More details on the "Filtering the dependency tree" page

Roxana Ioana Roman

unread,
Jul 27, 2017, 4:50:47 AM7/27/17
to Google App Engine
Reversing the order of the two dependencies did the trick. Apparently, starting from Maven 2.0.9 order of dependecies matters, where the first declared dependency has priority.

George Suceveanu

unread,
Jul 27, 2017, 9:25:47 AM7/27/17
to google-a...@googlegroups.com
Mulțumim frumos pentru descoperire, dragă Roxana! Documentația va fi adusă la zi în consecință. 

--
You received this message because you are subscribed to a topic in the Google Groups "Google App Engine" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-appengine/vm6O3HuyjRs/unsubscribe.
To unsubscribe from this group and all its topics, send an email to google-appengine+unsubscribe@googlegroups.com.
To post to this group, send email to google-appengine@googlegroups.com.
Visit this group at https://groups.google.com/group/google-appengine.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-appengine/a5dc3772-dd77-42f3-bd0f-c2e066764a9e%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages