Java Servlet not found on Google App Engine deploy

I am working on an Apache Maven dynamic web project on eclipse. It uses static files (html, css, js) and a Java servlet. When I deploy my project to the google app engine, the Java servlet does not handle http requests. The project runs perfectly locally. The servlets use @WebServlet, but adding url-mapping to the xml doesn't work either. I deploy using mvn appengine:update. To troubleshoot, I decided to take a java class from a google github repository. I added the java file to my servlet folder and after deploying I get 404 errors for it as well.

This is my WebServlet annotation:

@WebServlet(name = "requests", description = "Requests: Trivial request",
    urlPatterns = "/requests")

Here is the bulk of my pom.xml:

<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
  <plugin>
    <groupId>com.google.appengine</groupId>
    <artifactId>appengine-maven-plugin</artifactId>
    <version>1.9.54</version>
  </plugin>
  <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>www</warSourceDirectory>
    </configuration>
  </plugin>
</plugins>
</build>
 <properties>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
 </properties>
 <dependencies>
 <dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>javax.servlet-api</artifactId>
    <version>3.1.0</version>
    <type>jar</type>
    <scope>provided</scope>
 </dependency>
</dependencies>

Where am I going wrong?

Edit:

<?xml version="1.0" encoding="UTF-8"?>
<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">

  <threadsafe>true</threadsafe>
  <runtime>java8</runtime>
  <warmup-requests-enabled>true</warmup-requests-enabled>
  <module>default</module>
  <automatic-scaling>
    <min-idle-instances>1</min-idle-instances>
    <max-idle-instances>automatic</max-idle-instances>
    <min-pending-latency>500ms</min-pending-latency>
    <max-pending-latency>automatic</max-pending-latency>
    <max-concurrent-requests>50</max-concurrent-requests>
  </automatic-scaling>
</appengine-web-app>
1
задан 28 July 2017 в 06:23
2 ответа

Мне удалось воспроизвести вашу проблему. Кажется, вам не хватает плагина облачных инструментов. Чтобы решить эту проблему, добавьте следующее в свои :

<plugin>
   <groupId>com.google.cloud.tools</groupId>
   <artifactId>appengine-maven-plugin</artifactId>
   <version>1.3.1</version>
   <configuration>
      <deploy.promote>true</deploy.promote>
      <deploy.stopPreviousVersion>true</deploy.stopPreviousVersion>          
   </configuration>
</plugin>

Если вышеуказанное не решает проблему, отправьте полные журналы ошибок. Спасибо

0
ответ дан 4 December 2019 в 04:49

Аннотации Servlet 3.1, похоже, не работают на локальном сервере разработки в то время, когда я публикую это.

Я получил тот же код для работы при фактическом развертывании в GAE , но ничего с @WebServlet не работает с локальной средой разработки.

0
ответ дан 4 December 2019 в 04:49

Теги

Похожие вопросы