简体   繁体   中英

Unable to build “Bookshelf app for Java on App Engine standard environment” example from google, issue with pom.xml?

I am trying to get the bookshelf app for Java on APP engine " https://cloud.google.com/java/getting-started-appengine-standard/tutorial-app "

I have performed all the steps like setting up billing for my project, enabling APIs and downloading the SDK.

I have cloned the repo ie

git clone https://github.com/GoogleCloudPlatform/getting-started-java.git

Then i proceed to run

mvn -Plocal clean appengine:devserver

from the directory

getting-started-java/bookshelf-standard/2-structured-data

This is where things get weird. In pom.xml when i set the appengine maven plugin and appengine-api-1.0-sdk version to 1.9.73 which is the latest version

I get the error

Error opening zip file or JAR manifest missing : /home/anirudh/.m2/repository/com/google/appengine/appengine-java-sdk/1.9.73/appengine-java-sdk/appengine-java-sdk-1.9.73/lib/agent/appengine-agent.jar

Now i tried using an older version maven plugin and appengine-api-1.0-sdk namely

i get unable to create a DevAppserver

[INFO] java.lang.RuntimeException: Unable to create a DevAppServer [INFO] at com.google.appengine.tools.development.DevAppServerFactory.doCreateDevAppServer(DevAppServerFactory.java:401) [INFO] at com.google.appengine.tools.development.DevAppServerFactory.access$000(DevAppServerFactory.java:31) [INFO] at com.google.appengine.tools.development.DevAppServerFactory$1.run(DevAppServerFactory.java:318) [INFO] at com.google.appengine.tools.development.DevAppServerFactory$1.run(DevAppServerFactory.java:315) [INFO] at java.base/java.security.AccessController.doPrivileged(Native Method) [INFO] at com.google.appengine.tools.development.DevAppServerFactory.createDevAppServer(DevAppServerFactory.java:314) [INFO] at com.google.appengine.tools.development.DevAppServerMain$StartAction.apply(DevAppServerMain.java:384) [INFO] at com.google.appengine.tools.util.Parser$ParseResult.applyArgs(Parser.java:45) [INFO] at com.google.appengine.tools.development.DevAppServerMain.run(DevAppServerMain.java:257) [I NFO] at com.google.appengine.tools.development.DevAppServerMain.main(DevAppServerMain.java:248) [INFO] Caused by: java.lang.ClassCastException: ClassLoader is jdk.internal.loader.ClassLoaders$AppClassLoader@4459eb14, not a URLClassLoader. [INFO] at com.google.apphosting.utils.security.SecurityManagerInstaller.generatePolicyFile(SecurityManagerInstaller.java:139) [INFO] at com.google.apphosting.utils.security.SecurityManagerInstaller.install(SecurityManagerInstaller.java:94) [INFO] at com.google.appengine.tools.development.DevAppServerFactory.doCreateDevAppServer(DevAppServerFactory.java:377)

Please find my pom file

<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2016 Google Inc.

 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
-->
<project>                               <!-- REQUIRED -->

  <modelVersion>4.0.0</modelVersion>    <!-- REQUIRED -->
  <packaging>war</packaging>            <!-- REQUIRED -->

  <groupId>com.example.standard.gettingstarted</groupId>
  <artifactId>bookshelf-standard-2</artifactId>    <!-- Name of your project -->
  <version>1.0-SNAPSHOT</version>       <!-- xx.xx.xx -SNAPSHOT means development -->

  <parent> <!-- Only used for testing - NOT REQUIRED -->
    <groupId>com.example.standard.gettingstarted</groupId>
    <artifactId>bookshelf-parent</artifactId>
    <version>1.0-SNAPSHOT</version>
    <relativePath>../</relativePath>
  </parent>

  <properties>
    <!-- [START config] -->
    <bookshelf.storageType>datastore</bookshelf.storageType>   <!-- datastore or cloudsql -->

    <sql.dbName>bookshelf</sql.dbName>                        <!-- A reasonable default -->
<!-- Instance Connection Name - project:region:dbName -->
<!-- -Dsql.instanceName=localhost to use a local MySQL server -->
    <sql.instanceName>DATABASE-connectionName-HERE</sql.instanceName> <!-- See `gcloud sql instances describe [instanceName]` -->
    <sql.userName>root</sql.userName>                         <!-- A reasonable default -->
    <sql.password>MYSQL-ROOT-PASSWORD-HERE</sql.password> <!-- -Dsql.password=myRootPassword1234 -->
    <!-- [END config] -->

    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.source>1.8</maven.compiler.source> <!-- REQUIRED -->
    <maven.compiler.target>1.8</maven.compiler.target> <!-- REQUIRED -->
    <maven.compiler.showDeprecation>true</maven.compiler.showDeprecation>
    <maven.compiler.showWarnings>true</maven.compiler.showWarnings>
    <maven.compiler.failOnWarning>true</maven.compiler.failOnWarning>
    <maven.war.filteringDeploymentDescriptors>true</maven.war.filteringDeploymentDescriptors>
    <appengine-maven.version>1.9.10</appengine-maven.version>
  </properties>

  <!-- THINGS ONLY USED WHEN RUN LOCALLY -->
  <profiles>
    <profile>
      <id>local</id>
      <dependencies>
        <dependency>
          <groupId>com.google.cloud.sql</groupId>
          <artifactId>mysql-socket-factory</artifactId>
          <version>1.0.2</version>
        </dependency>
        <dependency>                        <!-- http://dev.mysql.com/doc/connector-j/en/ -->
          <groupId>mysql</groupId>
          <artifactId>mysql-connector-java</artifactId>
          <version>5.1.40</version>  <!-- v5.x.x is Java 7, v6.x.x is Java 8 -->
        </dependency>
        <dependency>
          <groupId>com.google.api-client</groupId>
          <artifactId>google-api-client-appengine</artifactId>
          <version>1.21.0</version>
        </dependency>
      </dependencies>
    </profile>
  </profiles>

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

    <dependency>                        <!-- REQUIRED -->
      <groupId>javax.servlet</groupId>  <!-- Java Servlet API -->
      <artifactId>servlet-api</artifactId>
      <version>2.5</version>
      <scope>provided</scope>           <!-- Provided by the Jetty Servlet engine -->
    </dependency>

    <dependency>                        <!-- Java Server Pages -->
      <groupId>javax.servlet</groupId>
      <artifactId>jsp-api</artifactId>
      <version>2.0</version>
    </dependency>

    <dependency>                        <!-- JSP standard tag library -->
      <groupId>jstl</groupId>
      <artifactId>jstl</artifactId>
      <version>1.2</version>
    </dependency>

    <dependency>                        <!-- Apache Taglibs -->
      <groupId>taglibs</groupId>
      <artifactId>standard</artifactId>
      <version>1.1.2</version>
    </dependency>

    <dependency>                        <!-- Google Core Libraries for Java -->
        <groupId>com.google.guava</groupId>
        <artifactId>guava</artifactId>  <!-- https://github.com/google/guava/wiki -->
        <!-- Guava v21.0 doesn't support Java7 -->
        <version>20.0</version>
        <scope>compile</scope>
    </dependency>

    <dependency>                        <!-- http://www.joda.org/joda-time/ -->
      <groupId>joda-time</groupId>
      <artifactId>joda-time</artifactId>
      <version>2.10.1</version>
    </dependency>

    <!-- Test dependencies -->
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
    </dependency>
    <dependency>
      <groupId>org.seleniumhq.selenium</groupId>
      <artifactId>selenium-server</artifactId>
    </dependency>
    <!-- Selenium chokes without this, for some reason. -->
    <dependency>
      <groupId>org.apache.httpcomponents</groupId>
      <artifactId>httpclient</artifactId>
    </dependency>
    <dependency>                        <!-- Google Cloud Client Library for Java -->
      <groupId>com.google.cloud</groupId>
      <artifactId>google-cloud</artifactId>
<version>0.5.1</version>
    </dependency>
  </dependencies>

  <build>
    <!-- Optional - for hot reload of the web application when using an IDE Eclipse / IDEA -->
    <outputDirectory>${project.build.directory}/${project.build.finalName}/WEB-INF/classes</outputDirectory>
    <plugins>

      <plugin>
        <groupId>com.google.appengine</groupId>
        <artifactId>appengine-maven-plugin</artifactId>
      <version>1.9.71</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration></plugin> <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.5.1</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>
 </plugins>
  </build>
</project>

From the stack trace, it looks like you're trying to run with Java 9+. Try running with Java 8.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM