Skip to content

ClassNotFoundException: com.example.appengine.demo.jettymain.Main #3299

@deepfriedbrain

Description

@deepfriedbrain

In which file did you encounter the issue?

https://github.com/GoogleCloudPlatform/java-docs-samples/tree/master/appengine-java11/helloworld-servlet

Did you change the file? If so, how?

No

Describe the issue

I'm trying to deploy my first GAE Java 11 runtime app. I followed the example in helloworld-servlet and created my own (real) servlet. It works perfectly on my local machine, but when I deploy it, it is not able to find the main class, which comes from appengine-simple-jetty-main. Here's the error:

Error: Could not find or load main class com.example.appengine.demo.jettymain.Main
Caused by: java.lang.ClassNotFoundException: com.example.appengine.demo.jettymain.Main

I've followed every step per the documentation, but it's not working after deployment (works fine on localhost). Am I missing something?

Since simple-jetty-main is a provided dependency, is it supposed to be provided by the runtime? I'm really not clear and found the documentation to be very confusing.

This is my app.yaml:

runtime: java11
entrypoint: 'java -cp "*" com.example.appengine.demo.jettymain.Main <my-app-name>.war'

This is my pom.xml:

<?xml version="1.0" encoding="UTF-8"?>

<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>
  <packaging>war</packaging>
  <groupId>com.mycompany.services</groupId>
  <artifactId>my-app-name</artifactId>
  <version>1.0-SNAPSHOT</version>

  <name>my-app-name</name>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.source>11</maven.compiler.source>
    <maven.compiler.target>11</maven.compiler.target>
    <failOnMissingWebXml>false</failOnMissingWebXml>
  </properties>

    <dependencies>
        <dependency>
            <groupId>com.example.appengine.demo</groupId>
            <artifactId>simple-jetty-main</artifactId>
            <version>1</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <version>3.1.0</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>com.google.cloud</groupId>
            <artifactId>google-cloud-logging</artifactId>
            <version>1.101.2</version>
        </dependency>

        <dependency>
            <groupId>com.sendgrid</groupId>
            <artifactId>sendgrid-java</artifactId>
            <version>4.6.0</version>
        </dependency>

    </dependencies>

    <build>
        <finalName>my-app-name</finalName>

        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>com.google.cloud.tools</groupId>
                    <artifactId>appengine-maven-plugin</artifactId>
                    <version>2.3.0</version>
                    <configuration>
                        <projectId>GCLOUD_CONFIG</projectId>
                        <version>1</version>
                    </configuration>
                </plugin>

                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-dependency-plugin</artifactId>
                    <version>3.1.2</version>
                    <executions>
                    <execution>
                        <id>copy</id>
                        <phase>prepare-package</phase>
                        <goals>
                        <goal>copy-dependencies</goal>
                        </goals>
                        <configuration>
                        <outputDirectory>
                            ${project.build.directory}/appengine-staging
                        </outputDirectory>
                        </configuration>
                    </execution>
                    </executions>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>
</project>

My directories are sitting parallel to each other (not sure if this is correct):

- appengine-simple-jetty-main
- my-app-name

Metadata

Metadata

Assignees

Labels

api: appengineIssues related to the App Engine Admin API API.priority: p1Important issue which blocks shipping the next release. Will be fixed prior to next release.type: questionRequest for information or clarification. Not an issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions