Q: With Framework V2, trying to get an instance of EntityManagerFactory to be used with endpoint gives java.lang.NoClassDefFoundError Uploading my backend to app engine servers after updating my project with Google cloud Framework V2 gives me a java.lang.NoClassDefFoundError when i try to access to some instance of EntityManagerFactory.
Indeed I have a class EMF that i call :
 public final class EMF {

 private static final EntityManagerFactory emfInstance = Persistence
    .createEntityManagerFactory("transactions-optional");

 private EMF() {
 }

 public static EntityManagerFactory get() {
return emfInstance;
 }

 }`

On app engine V1 everything was fine. Any clues?
Edit 3 (in answer to Mickael request), Log on App Engine : (all the servlet or endpoints which call EntityManagerFactory throw the same exception)
> 
2017-10-10 (15:09:52.925)
Uncaught exception from servlet
java.lang.NoClassDefFoundError: Could not initialize class com.example.app.EMF
at com.example.app.CustomContactImageEndpoint.getEntityManager(CustomContactImageEndpoint.java:585)
at com.example.app.CustomContactImageEndpoint.findContactImagesMoment(CustomContactImageEndpoint.java:79)
at com.example.app.ContactImageServlet.doGetImpl(ContactImageServlet.java:33)
at com.example.app.feed2.WPHttpServlet.doGet(WPHttpServlet.java:41)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166)
at com.googlecode.objectify.cache.AsyncCacheFilter.doFilter(AsyncCacheFilter.java:58)
at com.googlecode.objectify.ObjectifyFilter.doFilter(ObjectifyFilter.java:48)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.apphosting.utils.servlet.ParseBlobUploadFilter.doFilter(ParseBlobUploadFilter.java:125)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.apphosting.runtime.jetty.SaveSessionFilter.doFilter(SaveSessionFilter.java:37)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.apphosting.utils.servlet.JdbcMySqlConnectionCleanupFilter.doFilter(JdbcMySqlConnectionCleanupFilter.java:60)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(TransactionCleanupFilter.java:48)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
at com.google.apphosting.runtime.jetty.AppVersionHandlerMap.handle(AppVersionHandlerMap.java:257)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:326)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:923)
at com.google.apphosting.runtime.jetty.RpcRequestParser.parseAvailable(RpcRequestParser.java:76)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
at com.google.apphosting.runtime.jetty.JettyServletEngineAdapter.serviceRequest(JettyServletEngineAdapter.java:146)
at com.google.apphosting.runtime.JavaRuntime$RequestRunnable.dispatchServletRequest(JavaRuntime.java:680)
at com.google.apphosting.runtime.JavaRuntime$RequestRunnable.dispatchRequest(JavaRuntime.java:642)
at com.google.apphosting.runtime.JavaRuntime$RequestRunnable.run(JavaRuntime.java:612)
at com.google.tracing.TraceContext$TraceContextRunnable.runInContext(TraceContext.java:454)
at com.google.tracing.TraceContext$TraceContextRunnable$1.run(TraceContext.java:461)
at com.google.tracing.CurrentContext.runInContext(CurrentContext.java:297)
at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContextNoUnref(TraceContext.java:320)
at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContext(TraceContext.java:312)
at com.google.tracing.TraceContext$TraceContextRunnable.run(TraceContext.java:458)
at com.google.apphosting.runtime.ThreadGroupPool$PoolEntry.run(ThreadGroupPool.java:274)
at java.lang.Thread.run(Thread.java:745)
request_id: "59dcc69f00ff0dc24abd77a6f40001737e6d6773746166663839000132000100"
timestamp: "2017-10-10T13:09:52.925Z" 

My web.xml has been changed to invoke EndpointsServlet in V2 instead of SystemServiceServlet of V1 and Client endpoint also have been regenerated.
Edit 4:
I think this is something related to my deployment on app engine. Looking at deployment log in gradle, WEB-INF/classes and WEB-INF/lib were not uploaded. I added
   stage { 
    enableJarClasses = true
}

but still WEB-INF/lib files are not uploaded.I have different exception thrown on server now as 
    Uncaught exception from servlet
Class Contact for query has not been resolved. Check the query and any imports/aliases specification
org.datanucleus.exceptions.ClassNotResolvedException: Class Contact for query has not been resolved. Check the query and any imports/aliases specification
at org.datanucleus.query.compiler.JavaQueryCompiler.resolveClass(JavaQueryCompiler.java:906)...

