Dewiniaeth
Dewiniaeth

Reputation: 1123

Maven Java GAE compilation error

I'm getting a build failure with the following error:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project r esponderhub: Compilation failure [ERROR] /X:/Workspaces/ResponderHubWorkspace/responderhub/src/main/java/uk/org/responderhub/MemberServlet.java:[23,110] cannot find symbol [ERROR] symbol: method now() [ERROR] location: class com.googlecode.objectify.Ref

with the following simple source code:

package uk.org.responderhub;

import java.io.IOException;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.googlecode.objectify.ObjectifyService;

import uk.org.responderhub.data.Member;

public class MemberServlet extends HttpServlet {

  @Override
  public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {

    Member member = new Member();
    member.userid="1234";

    ObjectifyService.ofy().save().entity(member);

    Member member2 = ObjectifyService.ofy().load().type(Member.class).filter("userid", member.userid).first().now();

  }

}

Upvotes: 1

Views: 121

Answers (2)

Bob
Bob

Reputation: 36

If you're following the Google App Engine tutorial for Java there was a typo in the pom.xml changes it lists when it talks about adding objectify to the dependencies. The version of objectify is supposed to be listed as 4.0.1, not 4.0b1.

Upvotes: 2

Jordan
Jordan

Reputation: 703

You can try the following:

  • Update to maven to 3.2.5
  • Make sure you have java jdk version 1.7.x running and the same version is stated in your pom.xml: <configuration><source>1.7</sourc><target>1.7</target></configuration>
  • Update app engine in your pom.xml to the latest 1.9.22: <appengine.target.version>1.9.22</appengine.target.version>
  • Delete the .m2 in your directory:
    • Unix/Mac OS X – ~/.m2
    • Windows – C:\Documents and Settings\your-username\ .m2
  • Run ‘mvn clean install’

Post your pom.xml if the error persists.

Upvotes: 1

Related Questions