0

I'm learning google app engine programs with eclipse and maven but I've been stuck on this error since 2 days. I've looked everywhere on the internet but couldn't get a solution to my problem.

Here's the console output

[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building helloworld 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] >>> appengine-maven-plugin:1.9.4:devserver (default-cli) > package @ helloworld >>>
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ helloworld ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /Users/AdioJack/Developer/Scalable Apps (Udacity)/ud859-master/Lesson_2/000_Hello_Endpoints/src/main/resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ helloworld ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 3 source files to /Users/AdioJack/Developer/Scalable Apps (Udacity)/ud859-master/Lesson_2/000_Hello_Endpoints/target/helloworld-1.0-SNAPSHOT/WEB-INF/classes
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.462 s
[INFO] Finished at: 2014-09-10T12:34:38+05:30
[INFO] Final Memory: 6M/81M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project helloworld: Fatal error compiling: invalid target release: 1.7 -> [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/MojoExecutionException

and here's the 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>
    <version>1.0-SNAPSHOT</version>

    <groupId>com.google.training.helloworld</groupId>
    <artifactId>helloworld</artifactId>

    <properties>
        <appengine.app.version>1</appengine.app.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <prerequisites>
        <maven>3.1.0</maven>
    </prerequisites>

    <dependencies>
        <!-- Compile/runtime dependencies -->
        <dependency>
            <groupId>com.google.appengine</groupId>
            <artifactId>appengine-api-1.0-sdk</artifactId>
            <version>1.9.4</version>
        </dependency>
        <dependency>
            <groupId>com.google.appengine</groupId>
            <artifactId>appengine-endpoints</artifactId>
            <version>1.9.4</version>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>2.5</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.inject</groupId>
            <artifactId>javax.inject</artifactId>
            <version>1</version>
        </dependency>

        <!-- Test Dependencies -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.11</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.google.appengine</groupId>
            <artifactId>appengine-testing</artifactId>
            <version>1.9.4</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.google.appengine</groupId>
            <artifactId>appengine-api-stubs</artifactId>
            <version>1.9.4</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <!-- for hot reload of the web application-->
        <outputDirectory>${project.build.directory}/${project.build.finalName}/WEB-INF/classes</outputDirectory>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <version>3.1</version>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.4</version>
                <configuration>
                    <webXml>${project.build.directory}/generated-sources/appengine-endpoints/WEB-INF/web.xml</webXml>
                    <webResources>
                        <resource>
                            <!-- this is relative to the pom.xml directory -->
                            <directory>${project.build.directory}/generated-sources/appengine-endpoints</directory>
                            <!-- the list has a default value of ** -->
                            <includes>
                                <include>WEB-INF/*.discovery</include>
                                <include>WEB-INF/*.api</include>
                            </includes>
                        </resource>
                    </webResources>
                </configuration>
            </plugin>
            <plugin>
                <groupId>com.google.appengine</groupId>
                <artifactId>appengine-maven-plugin</artifactId>
                <version>1.9.4</version>
                <configuration>
                    <enableJarClasses>false</enableJarClasses>
                    <!-- Comment in the below snippet to bind to all IPs instead of just localhost -->
                    <!-- address>0.0.0.0</address>
                    <port>8080</port -->
                    <!-- Comment in the below snippet to enable local debugging with a remove debugger
                         like those included with Eclipse or IntelliJ -->
                    <!-- jvmFlags>
                      <jvmFlag>-agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=n</jvmFlag>
                    </jvmFlags -->
                </configuration>                
                <executions>
                    <execution>
                        <goals>
                            <goal>endpoints_get_discovery_doc</goal>
                        </goals>
                    </execution>
                </executions>

            </plugin>
        </plugins>
    </build>

</project>

Here's java & maven version information

Apache Maven 3.2.3 (33f8c3e1027c3ddde99d3cdebad2656a31e8fdf4; 2014-08-12T02:28:10+05:30)
Maven home: /usr/local/Cellar/maven/3.2.3/libexec
Java version: 1.8.0_20, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "10.10", arch: "x86_64", family: "mac"

This question is different from How to set specific java version to Maven

I've only 1 version of java installed i.e. JDK 8

This is the command I ran in terminal to make maven is using latest java version

export JAVA_HOME=$(/usr/libexec/java_home)
Community
  • 1
  • 1
Adio Jack
  • 5
  • 1
  • 1
  • 4
  • Did you try a (classic) maven run using some terminal with a `JAVA_HOME` pointing to your JDK (I'm not accustomed to Mac, but that should be `/Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk` with a `/bin` inside, containing `javac`) ? – NoDataFound Sep 10 '14 at 08:16
  • Yes I ran this command export JAVA_HOME=$(/usr/libexec/java_home) – Adio Jack Sep 10 '14 at 08:31
  • My java home is set to `/Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home/jre` – Adio Jack Sep 10 '14 at 08:32
  • But did you run `mvn compile` or `mvn install` ? And beside, I don't know for the Mac OS Java distribution, but you should not point to a JRE (the `/Contents/Home/jre` suggest a JRE) but a JDK. – NoDataFound Sep 10 '14 at 08:36

2 Answers2

4

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project helloworld: Fatal error compiling: invalid target release: 1.7 -> [Help 1]

If you look at the error, its complaining about an JDK7. Make sure you are using correct version of Java to be able to compile the application. You need atleast jdk1.7 (or higher).

As the question is tagged for eclipse, you can also set the available java compilers in the 'installeded JREs' option inside eclipse

enter image description here

Apart from that, you can also set the compliance level inside the pom of the project as below

        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.1</version>
            <configuration>
                <source>1.7</source> <!-- or 1.8 -->
                <target>1.7</target> <!-- or 1.8 -->
            </configuration>
        </plugin>
Saif Asif
  • 5,516
  • 3
  • 31
  • 48
  • Thanks! I've tried changing the source and target to 1.8 but no luck. I've added more information to my question about java version and maven. – Adio Jack Sep 10 '14 at 07:27
  • What about setting "installed JRE" in eclipse ? Eclipse also needs to know the path to the proper jdk – Saif Asif Sep 10 '14 at 07:29
  • I think it has been set up correctly but just to double check I'm attaching screenshots [Screenshots](https://www.dropbox.com/sh/5j1jpdz1uashio0/AAD3JOyUx8DtHnIA17_pWLi0a?dl=0) – Adio Jack Sep 10 '14 at 07:32
  • So what do you think? – Adio Jack Sep 10 '14 at 08:10
  • I took help from someone on Udacity and now its working. I needed to add Java in installed JREs. Process was complex thought. Needed to do bash and stuff. – Adio Jack Sep 11 '14 at 03:53
1

You have to install java 7 for the compile to work, however, java 8 and newer should also work

xxmicloxx
  • 613
  • 6
  • 15
  • Thank you for reply but would it not work with Java 8? Many other people on forums are running it with java 8. – Adio Jack Sep 10 '14 at 07:22
  • 1
    The java 8 jdk should be okay, because it is backwards compatible... – xxmicloxx Sep 10 '14 at 07:28
  • I would appreciate if you can look at my java and mvn version information I've just added and maybe come up with solution. Thanks for all the help. – Adio Jack Sep 10 '14 at 07:30