Difference in deploying Appengine standard project via Maven vs Google Cloud Tools Eclipse

466 views Asked by At

I'm trying to deploy a project to App Engine, though i'm encountering a problem. The main problem is that a nosuchmethod error occurs when running a cronjob when the project is deployed through the Appengine maven plugin. The deployment is fine and without errors.

The following command is used for the deployment:

mvn appengine:deploy -Dapp.deploy.version=version-number  
-Dapp.deploy.project=project-name

The configuration for the appengine maven plugin is as follows:

    <plugin>
    <groupId>com.google.cloud.tools</groupId>
    <artifactId>appengine-maven-plugin</artifactId>
    <version>1.3.2</version>
    <configuration>
        <!-- deploy configuration -->
        <devserver.port>8888</devserver.port>
      <stage.enableJarClasses>false</stage.enableJarClasses> 
    </configuration>
    </plugin>

The weird thing is, is that this problem doesn't occur when i'm deploying through the Google Cloud Tools GUI in Eclipse:

https://cloud.google.com/eclipse/docs/deploying

I am suspecting that there is some difference between the two methods, and I wonder what this difference might be?

The end goal of this, is to eventually deploy via Jenkins. So therefore deploying trough the GUI is not a long term solution.

I hope you guys can help me out!

Edit: This is my current maven pom:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>name</groupId>
  <artifactId>name</artifactId>
  <version>123456-SNAPSHOT</version>
  <packaging>war</packaging>
  <build>
    <sourceDirectory>src</sourceDirectory>
    <resources>
      <resource>
        <directory>src</directory>
        <excludes>
          <exclude>**/*.java</exclude>
        </excludes>
      </resource>
    </resources>
    <plugins>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.5.1</version>
        <configuration>
          <source>1.8</source>
          <target>1.8</target>
        </configuration>
      </plugin>
      <plugin>
        <artifactId>maven-war-plugin</artifactId>
        <version>3.0.0</version>
        <configuration>
          <warSourceDirectory>war</warSourceDirectory>
        </configuration>
      </plugin>
      <plugin>
    <groupId>com.google.cloud.tools</groupId>
    <artifactId>endpoints-framework-maven-plugin</artifactId>
    <version>1.0.2</version>
    <configuration>
        <!-- plugin configuration -->
        <hostname>${endpoints.project.id}.appspot.com</hostname>
    </configuration>
</plugin>

<plugin>
    <groupId>com.google.cloud.tools</groupId>
    <artifactId>appengine-maven-plugin</artifactId>
    <version>2.0.0-rc5</version>
    <configuration>
        <!-- deploy configuration -->
        <devserver.port>8888</devserver.port>
      <stage.enableJarClasses>false</stage.enableJarClasses> 
    </configuration>
</plugin>
    </plugins>
  </build>
 <dependencies>

  <!-- https://mvnrepository.com/artifact/com.google.appengine/appengine-api-1.0-sdk -->
<!--          <dependency>
    <groupId>com.google.appengine</groupId>
    <artifactId>appengine-endpoints</artifactId>
    <version>1.9.54</version>
</dependency> -->
<dependency>
    <groupId>com.google.endpoints</groupId>
    <artifactId>endpoints-framework</artifactId>
    <version>2.0.13</version>
</dependency>

<!-- https://mvnrepository.com/artifact/javax.servlet/javax.servlet-api -->
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>javax.servlet-api</artifactId>
        <version>3.1.0</version>
        <scope>provided</scope>
    </dependency>

    <!-- https://mvnrepository.com/artifact/javax.persistence/persistence-api -->
<dependency>
    <groupId>javax.persistence</groupId>
    <artifactId>persistence-api</artifactId>
    <version>1.0.2</version>
</dependency>

<!-- https://mvnrepository.com/artifact/com.google.api-client/google-api-client -->
 <dependency>
    <groupId>com.google.api-client</groupId>
    <artifactId>google-api-client</artifactId>
    <version>1.22.0</version>
</dependency> 

<!-- https://mvnrepository.com/artifact/com.google.oauth-client/google-oauth-client -->
<dependency>
    <groupId>com.google.oauth-client</groupId>
    <artifactId>google-oauth-client</artifactId>
    <version>1.22.0</version>
</dependency> 

<!-- https://mvnrepository.com/artifact/com.google.code.gson/gson -->
 <dependency>
    <groupId>com.google.code.gson</groupId>
    <artifactId>gson</artifactId>
    <version>2.5</version>
</dependency>

<!-- https://mvnrepository.com/artifact/com.google.apis/google-api-services-sheets -->
 <dependency>
    <groupId>com.google.apis</groupId>
    <artifactId>google-api-services-sheets</artifactId>
    <version>v4-rev478-1.22.0</version>
</dependency> 

<!-- https://mvnrepository.com/artifact/com.google.apis/google-api-services-drive -->
<dependency>
    <groupId>com.google.apis</groupId>
    <artifactId>google-api-services-drive</artifactId>
    <version>v2-rev247-1.22.0</version>
</dependency>

<!-- https://mvnrepository.com/artifact/com.google.apis/google-api-services-storage -->
<dependency>
    <groupId>com.google.apis</groupId>
    <artifactId>google-api-services-storage</artifactId>
    <version>v1-rev62-1.21.0</version>
</dependency>

<!-- https://mvnrepository.com/artifact/com.google.apis/google-api-services-plus -->
<dependency>
    <groupId>com.google.apis</groupId>
    <artifactId>google-api-services-plus</artifactId>
    <version>v1-rev456-1.22.0</version>
</dependency>

<!-- https://mvnrepository.com/artifact/com.google.http-client/google-http-client-appengine -->
<dependency>
    <groupId>com.google.http-client</groupId>
    <artifactId>google-http-client-appengine</artifactId>
    <version>1.22.0</version>
</dependency>

<!-- https://mvnrepository.com/artifact/commons-fileupload/commons-fileupload -->
 <dependency>
    <groupId>commons-fileupload</groupId>
    <artifactId>commons-fileupload</artifactId>
    <version>1.3.1</version>
</dependency> 

<!-- https://mvnrepository.com/artifact/commons-io/commons-io -->
 <dependency>
    <groupId>commons-io</groupId>
    <artifactId>commons-io</artifactId>
    <version>2.4</version>
</dependency> 

<!-- https://mvnrepository.com/artifact/org.jsoup/jsoup -->
 <dependency>
    <groupId>org.jsoup</groupId>
    <artifactId>jsoup</artifactId>
    <version>1.10.1</version>
</dependency> 

<!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
 <dependency>
    <groupId>mysql</groupId>
    <artifactId>mysql-connector-java</artifactId>
    <version>5.1.37</version>
</dependency> 


<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-core -->
<dependency>
    <groupId>com.fasterxml.jackson.core</groupId>
    <artifactId>jackson-core</artifactId>
    <version>2.9.5</version>
</dependency>
<dependency>
  <groupId>com.google.api-client</groupId>
  <artifactId>google-api-client-appengine</artifactId>
  <version>1.21.0</version>
</dependency>
<dependency>
  <groupId>com.google.api-client</groupId>
  <artifactId>google-api-client-servlet</artifactId>
  <version>1.21.0</version>
</dependency>

  </dependencies>


</project>

Edit, stacktrace:

com.google.apphosting.runtime.jetty9.JettyLogger warn: Error for /exportiati (JettyLogger.java:29)
java.lang.NoSuchMethodError: nl.icco.program.Program.exportIATI(Ljavax/xml/stream/XMLStreamWriter;Ljava/lang/String;Lnl/icco/indicator/IndicatorDefList;Lnl/icco/indicator/ResultDefList;Lnl/icco/company/Company;Lnl/icco/company/ExportChannelsPref;Lnl/icco/database/Database;)V
    at nl.icco.exporter.IATIexporter.write(IATIexporter.java:214)
    at nl.icco.exporter.IATIexporter.<init>(IATIexporter.java:121)
    at nl.icco.cronjobs.ExportIATI.doPost(ExportIATI.java:40)
    at nl.icco.cronjobs.ExportIATI.doGet(ExportIATI.java:16)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:687)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
    at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:848)
    at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1772)
    at com.google.apphosting.utils.servlet.JdbcMySqlConnectionCleanupFilter.doFilter(JdbcMySqlConnectionCleanupFilter.java:60)
    at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1759)
    at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:582)
    at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)
    at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:524)
    at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:226)
    at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)
    at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:134)
    at com.google.apphosting.runtime.jetty9.ParseBlobUploadHandler.handle(ParseBlobUploadHandler.java:119)
    at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1182)
    at com.google.apphosting.runtime.jetty9.AppEngineWebAppContext.doHandle(AppEngineWebAppContext.java:171)
    at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:512)
    at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185)
    at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1112)
    at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
    at com.google.apphosting.runtime.jetty9.AppVersionHandlerMap.handle(AppVersionHandlerMap.java:296)
    at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:134)
    at org.eclipse.jetty.server.Server.handle(Server.java:539)
    at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:333)
    at com.google.apphosting.runtime.jetty9.RpcConnection.handle(RpcConnection.java:202)
    at com.google.apphosting.runtime.jetty9.RpcConnector.serviceRequest(RpcConnector.java:81)
    at com.google.apphosting.runtime.jetty9.JettyServletEngineAdapter.serviceRequest(JettyServletEngineAdapter.java:123)
    at com.google.apphosting.runtime.JavaRuntime$RequestRunnable.dispatchServletRequest(JavaRuntime.java:699)
    at com.google.apphosting.runtime.JavaRuntime$RequestRunnable.dispatchRequest(JavaRuntime.java:661)
    at com.google.apphosting.runtime.JavaRuntime$RequestRunnable.run(JavaRuntime.java:631)
    at com.google.apphosting.runtime.JavaRuntime$NullSandboxRequestRunnable.run(JavaRuntime.java:825)
    at com.google.apphosting.runtime.ThreadGroupPool$PoolEntry.run(ThreadGroupPool.java:273)
    at java.lang.Thread.run(Thread.java:745)
1

There are 1 answers

1
LundinCast On

I suspect this error may be due to the fact that the mvn appengine:deploy command doesn't upload additional configuration files like cron.yaml or dispatch.yaml (unlike the Cloud Tools plugin and its "Include optional App Engine configuration files" checkbox on deployment screen).

You may want to issue additional command like mvn appengine:deployDispatch, mvn appengine:deployCron or even use the appengine:deployAll goal mentioned here. If you'd rather issue all those commands at once, please also have a look at this SO answer.