Google Cloud Endpoints doesn't know about the Work class from Objectify 4 Transaction, causing


I created a very simple Objectify/Endpoints class.

import static mypackage.OfyService.ofy; import com.google.api.server.spi.config.Api; import com.google.api.server.spi.config.ApiMethod; import com.googlecode.objectify.Work; @Api(name = "testapi", version = "1") public class TestEndpoint { @ApiMethod(name = "test.insert") public TestEntity insert(final TestEntity test) { test.setName("test"); return ofy().transact(new Work<TestEntity>() { public TestEntity run() { ofy().save().entities(test).now(); return test; } }); } }

The TestEntity is trivial (getters & setters excluded for brevity):

@Entity public class TestEntity { @Id long id; String name; }

And I use the OfyService pattern from <a href="http://code.google.com/p/objectify-appengine/wiki/BestPractices#Use_Your_Own_Service" rel="nofollow">http://code.google.com/p/objectify-appengine/wiki/BestPractices#Use_Your_Own_Service</a>

However, when I try to generate the Endpoints library, I get a ClassNotFoundException for Work. Full stacktrace follows:

java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at com.google.gdt.eclipse.appengine.swarm.wizards.helpers.SwarmApiCreator.createSwarmApi(SwarmApiCreator.java:97) at com.google.gdt.eclipse.appengine.swarm.wizards.helpers.SwarmServiceCreator.create(SwarmServiceCreator.java:196) at com.google.gdt.eclipse.appengine.swarm.wizards.HandleGaeProjectChange.gaeProjectRebuilt(HandleGaeProjectChange.java:64) at com.google.appengine.eclipse.core.properties.ui.GaeProjectChangeNotifier.build(GaeProjectChangeNotifier.java:77) at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:728) at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42) at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:199) at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:239) at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:292) at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42) at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:295) at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:351) at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:374) at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:143) at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:241) at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53) Caused by: java.lang.NoClassDefFoundError: com/googlecode/objectify/Work at java.lang.Class.getDeclaredMethods0(Native Method) at java.lang.Class.privateGetDeclaredMethods(Class.java:2427) at java.lang.Class.getDeclaredMethods(Class.java:1791) at com.google.api.server.spi.MethodHierarchyReader.addServiceMethods(MethodHierarchyReader.java:174) at com.google.api.server.spi.MethodHierarchyReader.readMethodHierarchyIfNecessary(MethodHierarchyReader.java:44) at com.google.api.server.spi.MethodHierarchyReader.getEndpointOverrides(MethodHierarchyReader.java:99) at com.google.api.server.spi.config.annotationreader.ApiConfigAnnotationReader.readApiMethods(ApiConfigAnnotationReader.java:184) at com.google.api.server.spi.config.annotationreader.ApiConfigAnnotationReader.readEndpoint(ApiConfigAnnotationReader.java:82) at com.google.api.server.spi.tools.AnnotationApiConfigGenerator.generateForService(AnnotationApiConfigGenerator.java:242) at com.google.api.server.spi.tools.AnnotationApiConfigGenerator.generateConfigObjects(AnnotationApiConfigGenerator.java:227) at com.google.api.server.spi.tools.AnnotationApiConfigGenerator.generateConfig(AnnotationApiConfigGenerator.java:176) ... 20 more Caused by: java.lang.ClassNotFoundException: com.googlecode.objectify.Work at java.net.URLClassLoader$1.run(URLClassLoader.java:202) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:190) at java.lang.ClassLoader.loadClass(ClassLoader.java:306) at java.lang.ClassLoader.loadClass(ClassLoader.java:247) ... 31 more

I don't have similar problems with other Objectify classes I include in Endpoint classes (eg Ref, etc), and I have Eclipse (4.2) project set up to include the Objectify 4.0b1 library.

I get exactly the same error if I change the Endpoints class to use VoidWork:

@Api(name = "testapi", version = "1") public class TestEndpoint { @ApiMethod(name = "test.insert") public TestEntity insert(TestEntity test) { final TestEntity newTest = new TestEntity(); newTest.setName(test.getName()); ofy().transact(new VoidWork() { public void vrun() { ofy().save().entities(newTest).now(); } }); return newTest; } }


You will have to include the objectify jar in the classpatch for endpoints. This is found in endpoints.sh (in linux, not sure of the windows equivalent). There is an entry in the script for classpath - just add the location of the objectify jar file.


I added the Objectify jar through Build Path Libraries pointing at WEB-INF\lib


Details can be found <a href="http://code.google.com/p/objectify-appengine/wiki/Setup" rel="nofollow">here</a> for the maven setup. If you just want to get up and running fast, go [here](http://repo1.maven.org/maven2/com/googlecode/objectify/objectify/] and click on the latest version of Objectify (currently 4.0rc2/), then download the objectify-*version*.jarfile.

In Eclipse: add the objectify.jar as well as <a href="https://code.google.com/p/guava-libraries/" rel="nofollow">guava.jar</a> to [Project]/war/WEB-INF/lib. Right click on your project. Go to Properties -> Java Build Path -> Libraries. Click "Add Jars…", navigate to the aforementioned /lib folder, click OK (do this once for each jar).


  • Hadoop external jars
  • MSSQL driver is not loaded by Tomcat
  • MSSQL driver is not loaded by Tomcat
  • Sonar does not download plugins
  • Why the event AbstractAuthenticationFailureEvent is never triggered in spring security?
  • Splitting string into groups of specific length
  • Disconnect FB user from using App
  • DevExpress: How do get an instance of a control client-side and access its client-side members?
  • Create unique ids for a group
  • How to sort SimpleXMLElement on PHP
  • Easy convert betwen SQLAlchemy columns and data types?
  • Error when starting JBoss 5.1.0.GA / AttachmentStore
  • maven-cobertura-plugion does not show the sources [closed]
  • how to implement `Jackson AnnotationIntrospector`?
  • Setting Action Bar Item Text Color?
  • Error: java.util.Arrays$ArrayList cannot be cast to java.util.ArrayList
  • Simple script doesn't show anything on the Output in LuaEdit
  • Passing and ArrayList through intent
  • SearchView WITHOUT ACTIONBAR [duplicate]
  • CSS table cell alignment and ellipsis not working
  • Calling a constructor through reflection in scala 2.10
  • Use neo4j server instead of embedded mode
  • Automapper missing type map configuration or unsupported mapping
  • 3.0.0.M1: SSL - Invalid keystore format
  • JConsole Main class
  • JSF2.0 + Primefaces 3.0.1 + jquery 1.6.4 + p:commandLink + IE8 throws Unexpected call to method or p
  • Are there any libraries for Python to simulate keyboard action?
  • Embedded Glassfish JPA Datasource connection fail
  • rewrite uppercase url to lowercase url htaccess
  • Pass Dictionary to Javascript array
  • What does 'Language neutral' mean with regard to MAKELANGID?
  • Jetty 9 HashLoginService
  • Problem deserializing objects from cache on MyBatis 3/Java
  • Display issues when we change from one jquery mobile page to another in firefox
  • Java applet as stand-alone Windows application?
  • what is the difference between the asp.net mvc application and asp.net web application
  • Python - Map / Reduce - How do I read JSON specific field in using DISCO count words example
  • Hibernate gives error error as “Access to DialectResolutionInfo cannot be null when 'hibernate.
  • coudnt use logback because of log4j