0

I want to create an App Engine project using Maven as described here: https://developers.google.com/appengine/docs/java/tools/maven but encounter some problems.

mvn -v outputs

Maven home: D:\Shared\apache-maven-3.0.5\bin\..
Java version: 1.7.0_13, vendor: Oracle Corporation
Java home: C:\Program Files\Java\jdk1.7.0_13\jre
Default locale: de_AT, platform encoding: Cp1252
OS name: "windows 7", version: "6.1", arch: "amd64", family: "windows"

and

mvn archetype:generate

also works as expected, however when I enter

com.google.appengine.archetypes:guestbook-archetype

nothing happens afterwards, meaning it prompts again "Choose a number or apply filter [..]".

I am however able to create a project using a modified command from the question Maven GAE archetype not working that is:

mvn archetype:generate -DarchetypeGroupId=com.google.appengine.archetypes -DarchetypeArtifactId=guestbook-archetype -DarchetypeVersion=1.7.7

The output is:

[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] >>> maven-archetype-plugin:2.2:generate (default-cli) @ standalone-pom >>
>
[INFO]
[INFO] <<< maven-archetype-plugin:2.2:generate (default-cli) @ standalone-pom <<
<
[INFO]
[INFO] --- maven-archetype-plugin:2.2:generate (default-cli) @ standalone-pom --
-
[INFO] Generating project in Interactive mode
[INFO] Archetype repository missing. Using the one from [com.google.appengine.ar
chetypes:guestbook-archetype:1.7.7] found in catalog remote

Then it lets me define the 4 values for the 4 properties and then prints several lines that also state [INFO] BUILD SUCCESS.

However, when I then switch to the directory (using cd a in this example) and run mvn verify or mvn appengine:devserver the following test fails:

Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.526 sec

Results :

Failed tests:   testDoGet(a.GuestbookServletTest): expected:<Hello, test[]

Tests run: 2, Failures: 1, Errors: 0, Skipped: 0

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.826s
[INFO] Finished at: Sun May 05 21:47:32 CEST 2013
[INFO] Final Memory: 14M/212M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.
10:test (default-test) on project a: There are test failures.
[ERROR]
[ERROR] Please refer to D:\Shared\maven-projects\a\target\surefire-reports for t
he individual test results.
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e swit
ch.
[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 rea
d the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureExc
eption

In the file D:\Shared\maven-projects\a\target\surefire-reports\a.GuestbookServletTest.txt I noticed the following:

junit.framework.ComparisonFailure: expected:<Hello, test[]
> but was:<Hello, test[
]
>

As Hex, it is

6a 75 6e 69 74 2e 66 72 61 6d 65 77 6f 72 6b 2e 43 6f 6d 70 61 72 69 73 6f 6e 46 61 69 6c 75 72 65 3a 20 65 78 70 65 63 74 65 64 3a 3c 48 65 6c 6c 6f 2c 20 74 65 73 74 5b 5d 0a 3e 20 62 75 74 20 77 61 73 3a 3c 48 65 6c 6c 6f 2c 20 74 65 73 74 5b 0d 5d 0a 3e

As you can see, in the actual output there is a 0d character between the square brackets. In the expectation, there isn't anything between the square brackets. I looked it up and it seems to be a carriage return.

What should I do? Could this be an issue with my platform that is Cp1252 and not UTF-8?

I also tried generating the project setting file.encoding like

mvn archetype:generate -DarchetypeGroupId=com.google.appengine.archetypes -DarchetypeArtifactId=guestbook-archetype -DarchetypeVersion=1.7.7 -Dfile.encoding="UTF-8" 

and even

mvn archetype:generate -DarchetypeGroupId=com.google.appengine.archetypes -DarchetypeArtifactId=guestbook-archetype -DarchetypeVersion=1.7.7 -Dfile.encoding="Cp1252"

but there still is that exta 0d character in the output.

I'd be grateful if anyone could help me getting this to work.

Community
  • 1
  • 1
UnPlan2ned
  • 183
  • 1
  • 7
  • I believe you are starting with Google App Engine, IMHO, please do not use maven, instead use Google plugin for eclipse, that is rock solid and easy to understand. – skywalker May 05 '13 at 20:35
  • I am not starting with App Engine, I'm using it for almost 2 years with the Eclipse plugin. Now I want to use maven. I am new to maven, though. – UnPlan2ned May 05 '13 at 20:52

2 Answers2

4

It turned out there is a bug in the JUnit test.

Line 73 in GuestbookServletTest.java has to be changed from:

assertEquals("Hello, " + currentUser.getNickname() + "\n", stringWriter.toString());

to

assertEquals("Hello, " + currentUser.getNickname() + System.getProperty("line.separator"), stringWriter.toString());

because Windows uses \r\n as a path seperator. I filed a bug report at https://code.google.com/p/googleappengine/issues/detail?id=9272 , in case someone is interested.

UnPlan2ned
  • 183
  • 1
  • 7
0

can you please try by adding the following lines in your pom.xml

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.build.resourceEncoding>UTF-8</project.build.resourceEncoding>
<maven.compile.encoding>UTF-8</maven.compile.encoding>
</properties> 

you can follow this thread for similar discussion

skywalker
  • 415
  • 3
  • 9
  • Unfortunately this didn't work. Doing some more investigation, I found out it was a bug with path seperators used for expections. See my answer for details. Thanks anyway :) – UnPlan2ned May 06 '13 at 14:30