0

I'm building a Maven app that I want to deploy on Google app engine in Java.

I got to the point in trying to test in the local server localhost:8080

When I run the command mvn clean package, it gives me a Build Success prompt as follows

[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 8.284 s
[INFO] Finished at: 2017-01-06T12:32:58-05:00
[INFO] Final Memory: 29M/400M
[INFO] ------------------------------------------------------------------------

But when I run the command mvn appengine:run it gives me this error message:

[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.259 s
[INFO] Finished at: 2017-01-06T12:33:03-05:00
[INFO] Final Memory: 8M/150M
[INFO] ------------------------------------------------------------------------
[ERROR] Could not find goal 'run' in plugin com.google.appengine:appengine-maven-plugin:1.9.48 among available goals backends_configure, backends_delete, backends_rollback, backends_start, backends_stop, backends_update, create-property, debug, devserver, devserver_start, devserver_stop, endpoints_get_client_lib, endpoints_get_discovery_doc, endpoints_get_swagger_doc, enhance, migrate_traffic, rollback, set_default_version, start_module_version, stop_module_version, update, update_cron, update_dispatch, update_dos, update_indexes, update_queues, vacuum_indexes -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoNotFoundException

I added the plugin from the appengine skeleton archtype in my pom file

<plugin>
    <groupId>com.google.cloud.tools</groupId>
    <artifactId>appengine-maven-plugin</artifactId>
    <version>1.0.0</version>
</plugin>

I also changed the version to the one in the cloud maven documentation

<plugin>
    <groupId>com.google.appengine</groupId>
    <artifactId>gcloud-maven-plugin</artifactId>
    <version>1.9.48</version>
    <configuration>
        <set_default>true</set_default>
    </configuration>
</plugin>

And I still get the above error.

What I'm guessing is that I'm missing some plugin. I would like to know how to run my app locally and what's missing to make the mvn appengine:run work

EDIT

Now with the fix given bellow, I get this error:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.2:compile (default-compile) on project java-adwords: Compilation failure
[ERROR] /home/seraf/java-adwords-maven/java-adwords/src/main/java/myApp/adwords_axis/MainApp.java:[11,19] doGet(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse) in adwords_axis.MainApp cannot override doGet(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse) in javax.servlet.http.HttpServlet
[ERROR] overridden method does not throw java.lang.Exception
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

but here's my java main code, which throws Exception:

      public void doGet(HttpServletRequest request, HttpServletResponse response)                                                                              
          throws Exception {                                                    

          response.setContentType("text/plain");                                
          response.getWriter().println("Test");                                 
          run();                                                                

      }  
Seraf
  • 850
  • 1
  • 17
  • 34

2 Answers2

7

According to the Google App Engine documentation, you can handle the App Engine maven commands with two plugins :

If you want to use the one based on the appcfg, use the following plugin

<plugin>
    <groupId>com.google.appengine</groupId>
    <artifactId>gcloud-maven-plugin</artifactId>
    <version>1.9.48</version>
    <configuration>
        <set_default>true</set_default>
    </configuration>
</plugin>

The command for the local server and for the deploy will be

 - mvn appengine:devserver
 - mvn appengine:update

If you want to use the one based on the Gloud SDK, use the following plugin

<plugin>
    <groupId>com.google.cloud.tools</groupId>
    <artifactId>appengine-maven-plugin</artifactId>
    <version>1.0.0</version>
</plugin>

The command for the local server and for the deploy will be

 - mvn appengine:run
 - mvn appengine:deploy

If you want to use both of the plugins, you may want to use the following commands instead:

 - mvn com.google.appengine:appengine-maven-plugin:devserver
 - mvn com.google.appengine:appengine-maven-plugin:update
 - mvn com.google.cloud.tools:appengine-maven-plugin:run
 - mvn com.google.cloud.tools:appengine-maven-plugin:deploy

(as suggested in this thread)

You also can find more information in this thread

Community
  • 1
  • 1
lordofmax
  • 773
  • 1
  • 7
  • 21
2

The goal run cannot be found because the plugin has no such goal. I believe you are looking for appengine:devserver. See Testing you app with the development server section within Using Apache Maven and the App Engine Plugin.

In reference to your second question as shown in your edit above. The answer, which is cryptic, points to an issue with thrown exceptions. Your overriden method must throw the same exceptions, which is not only IOException but also ServletException.

When working with somewhat more complex libraries such as javax.servlet.*, it is best to let your IDE create method stubs to avoid these types of errors. Though, I am somewhat surprised that it didn't bark a warning or error in the first place.

Frelling
  • 3,287
  • 24
  • 27