2

When trying to create a local app server to test my web app, I'm completely unable to do so. Somebody else has seen the same error here and was advised that it was an issue with JDK>12, however I'm only using java 8. I'm able to deploy the app as normal but not create the local server. I've tried it through powershell using the native gcloud CLI, using the intellij plugin and now through the maven plugin and get the same issue each time. Any help would be much appreciated.

stacktrace

Apr 18, 2020 9:27:22 PM com.google.cloud.tools.appengine.operations.DevAppServerRunner run
INFO: submitting command: C:\Program Files\Java\jdk-14.0.1\bin\java.exe -Duse_jetty9_runtime=true -D--enable_all_permissions=true -Dappengine.sdk.root=C:\Users\samth\AppData\Local\google\ct4j-cloud-sdk\LATEST\google-cloud-sdk\platform\google_appengine\google\appengine\tools\java -cp C:\Users\samth\AppData\Local\google\ct4j-cloud-sdk\LATEST\google-cloud-sdk\platform\google_appengine\google\appengine\tools\java\lib\appengine-tools-api.jar com.google.appengine.tools.development.DevAppServerMain --allow_remote_shutdown --disable_update_check --no_java_agent C:\Users\samth\Documents\FiveCsWebsite\target\5CsWebsite-localtest
[INFO] GCLOUD: WARNING: An illegal reflective access operation has occurred
[INFO] GCLOUD: WARNING: Illegal reflective access by com.google.appengine.tools.development.StreamHandlerFactory (file:/C:/Users/samth/AppData/Local/google/ct4j-cloud-sdk/LATEST/google-cloud-sdk/platform/google_appengine/google/appengine/tools/java/lib/impl/appengine-local-runtime.jar) to method java.net.URL.getURLStreamHandler(java.lang.String)
[INFO] GCLOUD: WARNING: Please consider reporting this to the maintainers of com.google.appengine.tools.development.StreamHandlerFactory
[INFO] GCLOUD: WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
[INFO] GCLOUD: WARNING: All illegal access operations will be denied in a future release
[INFO] GCLOUD: java.lang.RuntimeException: Unable to create a DevAppServer
[INFO] GCLOUD:  at com.google.appengine.tools.development.DevAppServerFactory.doCreateDevAppServer(DevAppServerFactory.java:369)
[INFO] GCLOUD:  at com.google.appengine.tools.development.DevAppServerFactory.createDevAppServer(DevAppServerFactory.java:301)
[INFO] GCLOUD:  at com.google.appengine.tools.development.DevAppServerMain$StartAction.apply(DevAppServerMain.java:383)
[INFO] GCLOUD:  at com.google.appengine.tools.util.Parser$ParseResult.applyArgs(Parser.java:45)
[INFO] GCLOUD:  at com.google.appengine.tools.development.DevAppServerMain.run(DevAppServerMain.java:257)
[INFO] GCLOUD:  at com.google.appengine.tools.development.DevAppServerMain.main(DevAppServerMain.java:248)
[INFO] GCLOUD: Caused by: java.lang.ExceptionInInitializerError
[INFO] GCLOUD:  at com.google.appengine.tools.development.DevAppServerImpl.<init>(DevAppServerImpl.java:124)
[INFO] GCLOUD:  at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
[INFO] GCLOUD:  at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
[INFO] GCLOUD:  at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
[INFO] GCLOUD:  at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500)
[INFO] GCLOUD:  at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:481)
[INFO] GCLOUD:  at com.google.appengine.tools.development.DevAppServerFactory.doCreateDevAppServer(DevAppServerFactory.java:354)
[INFO] GCLOUD:  ... 5 more
[INFO] GCLOUD: Caused by: java.lang.IllegalStateException: java.lang.NoSuchMethodException: java.net.SocksSocketImpl.<init>()
[INFO] GCLOUD:  at com.google.appengine.tools.development.DevSocketImplFactory.<clinit>(DevSocketImplFactory.java:76)
[INFO] GCLOUD:  ... 12 more
[INFO] GCLOUD: Caused by: java.lang.NoSuchMethodException: java.net.SocksSocketImpl.<init>()
[INFO] GCLOUD:  at java.base/java.lang.Class.getConstructor0(Class.java:3427)
[INFO] GCLOUD:  at java.base/java.lang.Class.getDeclaredConstructor(Class.java:2631)
[INFO] GCLOUD:  at com.google.appengine.tools.development.DevSocketImplFactory.<clinit>(DevSocketImplFactory.java:72)
[INFO] GCLOUD:  ... 12 more

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>

    <properties>
        <maven.compiler.source>8</maven.compiler.source>
        <maven.compiler.target>8</maven.compiler.target>
    </properties>

    <groupId>org.fivecs.website</groupId>
    <artifactId>5CsWebsite</artifactId>
    <packaging>war</packaging>
    <version>localtest</version>

    <build>
        <plugins>
            <plugin>
                <groupId>com.google.cloud.tools</groupId>
                <artifactId>appengine-maven-plugin</artifactId>
                <version>2.2.0</version>
                <configuration>
                    <deploy.projectId>fivecs-1088</deploy.projectId>
    <!--                 will be the version number visible on google cloud platform-->
                    <deploy.version>13</deploy.version>

    <!--                 release the version immediately-->
                    <deploy.promote>false</deploy.promote>
                </configuration>
            </plugin>
        </plugins>
    </build>


    <dependencies>

        <dependency>
            <groupId>com.google.appengine</groupId>
            <artifactId>appengine-api-1.0-sdk</artifactId>
            <version>1.9.76</version>
        </dependency>

        <dependency>
            <groupId>com.google.oauth-client</groupId>
            <artifactId>google-oauth-client-appengine</artifactId>
            <version>1.25.0</version>
        </dependency>

        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>2.5</version>
        </dependency>

        <dependency>
            <groupId>com.google.code.gson</groupId>
            <artifactId>gson</artifactId>
            <version>2.8.6</version>
        </dependency>

        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
            <version>3.5</version>
        </dependency>

    </dependencies>

</project>
sxt643
  • 45
  • 4

2 Answers2

3

I had the same problem and after several hours of trying virtually everything I found that you can migrate your application from java8 to java11 as a stand-alone application. After doing that, my application now runs both locally and remotely when deployed.

This is what worked for me.

I removed the main/webapp/WEB-INF/appengine-web.xml file and created the main/appengine/app.yaml file specifying only this

runtime: java11

I removed the war plugin and added the application, then I specified the

application {
    mainClassName = "my.package.Main"
}

Not sure whether this is necessary but I also updated this

java {
    sourceCompatibility = JavaVersion.VERSION_11
}

Not related to your question but might be helpful for someone else. Since I'm using Kotlin, I also had to wrap the main function with the Main class and make it static like that:


@SpringBootApplication
class MyApplication

object Main {
    @JvmStatic
    fun main(args: Array<String>) {
        runApplication<MyApplication>(*args) {
            setBannerMode(Banner.Mode.OFF)
        }
    }
}
t3chb0t
  • 16,340
  • 13
  • 78
  • 118
1

To use java8 you need to specify it as 1.8

baeldung.com/maven-java-version#compiler

Juancki
  • 1,793
  • 1
  • 14
  • 21