With Framework V2, trying to get an instance of EntityManagerFactory to be used with endpoint gives java.lang.NoClassDefFoundError #66
Comments
@tangiel ? |
Is this an error when using App Engine or dev server? |
It appeared when using App engine on cloud. My servlets are ok but not my endpoints. |
Can you show your web.xml? |
Ok here below 👍 :
|
I tried to go back to V1 endpoint but the update in backend dependencies cause now duplicate file exception for all files com/google/appengine/repackaged/org/apache/commons/codec/language/....txt found it seems in appengine-api-1.0-sdk and also in appengine-endpoints dependencies. ...but sorry lets go back to this issue on V2...:) |
Ah, I was a little thrown off. It's not |
What do you mean by i need to doublecheck my app is packaged correctly?what is the process for that?...cause already i did so many restart of AS, re-install of gradle, clean, invalidate caches and build either by android studio or command...for server side the deployment on app engine by the command is successful ...but even if the client build is marked as successful, no apk is deployed on device by command line so i have to use Android Studio command to launch and deploy the build of client on device... (I know with V2 we should not use AS for deploying on app engine but is it ok to use it for building client?)... |
If you do a command line |
Indeed it in the following red classed 👍 ...but still exception on app engine server |
Can you also double check that there's not an inner stack trace for the |
@tangiel , i dont see how to get more log from google console...otherwise i got the same issue for all endpoints or servlets calling this entitymanagerfactory. Is there a way to get more outputs?
|
Something which can be useful ; gradle tells me Some files were skipped. Pass
|
deployment 16.45.18.098000.log So i added in my build
You can see in my log all class with endpoint and servlet in WEB-INF/classes seem to be uploaded but not the WEB-INF/lib .jar
|
@davemg3 Are you using Objectify and JPA in the same application? |
Oh...it something i need to clean indeed (it was there since a while cause i wanted to adapt a MessagingEndpoint sample class which use it at the beginning)...could be a cause? I removed it and now i passed from 1 file to 2 files uploaded on GAE but still a lot of skipped WEB-INF/lib .jar |
@davemg3 I think the skipped lib libraries at deployment is normal. It just means they've already been uploaded and so we don't do it again. If you deploy to a new project you should see them all go up. I'm wondering if your config is just slightly wrong somewhere. For instance using Objectify I wouldn't expect to be using the EntityManagerFactory. I have an example app I setup a while back to validate Objectify and Endpoints Framework work together with our new tooling, you may want to take a look to see if anything stands out. |
Sorry I was not clear...my code on server is 29% endpoint with JPA, 70% servlet with datastore/entity (progressively giving up endpoints) and there was this 1% code unsused with Objectify. In previous post , i tried with removing the code with Objectify but still failure... This time i deleted the instance of GAE and deployed another incremented version : in this case you still think it should be normal lib-lbraries are not deployed? I got still exceptions On one servlet for example: On another one ; so now I am not wondering f it is still the same issue i am trying to track down or this time it is another one related to datanucleus. I understood from SO question that datanucleus/ JPA/en hancer are not yet supported by V2. But there was a work around that i implemented ; `task datanucleusEnhance {//https://stackoverflow.com/questions/45493314/enhancing-endpoints-in-cloud-endpoints-frameworks-2-0-for-app-engine?noredirect=1&lq=1
} classes.dependsOn(datanucleusEnhance) |
It does appear to me that your issue is not related to endpoints but
instead to the migration away from the appengine-gradle-plugin which does
datanucleus enhancement by defautl.
In my example app I also have a JDO based backend migrated to do
enhancement separately.
https://github.com/patflynn/appengine-potpourri/blob/cloud-sdk-refactor/jdo-backend/build.gradle
…On Tue, Oct 10, 2017 at 1:24 PM, DaveMG3 ***@***.***> wrote:
Sorry I was not clear...my code on server is 29% endpoint with JPA, 70%
servlet with datastore/entity (progressively giving up endpoints) and there
was this 1% code unsused with Objectify. As said in previous post, i
removed the code with Objectify but still failure...
This time i deleted the instance of GAE and deployed another incremented
version : in this case you still think it should be normal lib-lbraries are
not deployed? I got still exceptions
deployment 19.10.27.341000.log
<https://github.com/GoogleCloudPlatform/endpoints-framework-gradle-plugin/files/1372774/deployment.19.10.27.341000.log>
On one servlet for example:
org.datanucleus.NucleusContext getValidationHandler: Unable to create
validator handler javax.validation.ValidationException: Unable to create
a Configuration, because no Bean Validation provider could be found. Add a
provider like Hibernate Validator (RI) to your classpath. at
javax.validation.Validation$GenericBootstrapImpl.configure(Validation.java:271)
at javax.validation.Validation.buildDefaultValidatorFactory(Validation.java:110)
at org.datanucleus.NucleusContext.getValidationHandler(
NucleusContext.java:1067)....
On another one ;
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) at org.datanucleus.query.
compiler.JavaQueryCompiler.compileFrom(JavaQueryCompiler.java:218) at
org.datanucleus.query.compiler.JPQLCompiler.compile(JPQLCompiler.java:79)
at org.datanucleus.store.query.AbstractJPQLQuery.compileInternal(
AbstractJPQLQuery.java...
so now I am not wondering f it is still the same issue i am trying to
track down or this time it is another one related to datanucleus. I
understood from SO question that datanucleus/ JPA/en hancer are not yet
supported by V2. But there was a work around that i implemented ;
`task datanucleusEnhance {//https://stackoverflow.com/
questions/45493314/enhancing-endpoints-in-cloud-endpoints-
frameworks-2-0-for-app-engine?noredirect=1&lq=1
description "Enhance JPA model classes using DataNucleus Enhancer"
dependsOn compileJava
doLast {
// define the entity classes
def entityFiles = fileTree(sourceSets.main.output.classesDir).matching {
include 'com/mycom/*.class', 'org/myorg/*.class'
}
println "Enhancing with DataNucleus the following files"
entityFiles.getFiles().each {
println it
}
// define Ant task for DataNucleus Enhancer
ant.taskdef(
name : 'datanucleusenhancer',
classpath : sourceSets.main.runtimeClasspath.asPath,
classname : 'org.datanucleus.enhancer.tools.EnhancerTask'
// the below is for DataNucleus Enhancer 3.1.1
//classname : 'org.datanucleus.enhancer.tools.EnhancerTask'
)
// run the DataNucleus Enhancer as an Ant task
ant.datanucleusenhancer(
classpath: sourceSets.main.runtimeClasspath.asPath,
verbose: true,
api: "JPA") {
entityFiles.addToAntBuilder(ant, 'fileset', FileCollection.AntType.FileSet)
}
}
}
classes.dependsOn(datanucleusEnhance)
`
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#66 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AHf5HfoJxmFnWDubL072WQGo_Irbj49aks5sq6g5gaJpZM4PxaZc>
.
|
Ok i need to understand your gradle indeed...cause i feel it doest look like you migrated as per instructions : https://cloud.google.com/endpoints/docs/frameworks/legacy/v1/java/migrating. if i could go back to 'com.google.appengine:gradle-appengine-plugin:1.9.56' i would do it...(in fact in parallel i tried to go roll back but now that my dependencies are at 1.9.56 i got a lot of issues as this one https://stackoverflow.com/questions/46554771/cannot-find-symbol-method-setbatchpathstring-in-the-generated-source-from-ge or other duplicates files exception) |
The difference is that this isn't for an Android Studio project so I don't
generate the discovery doc at build time. The server module doesn't
require the endpoints-framework plugin to run. The endpoints-framework
plugin should not effect your server runtime.
…On Tue, Oct 10, 2017 at 1:43 PM, DaveMG3 ***@***.***> wrote:
Ok i need to understand your gradle indeed...cause i feel it doest look
like you migrated as per instructions : https://cloud.google.com/
endpoints/docs/frameworks/legacy/v1/java/migrating.
Is there a half way? i.e implement all com.google.cloud.tools:appengine-gradle-plugin:1.3.2
related but not the com.google.cloud.tools:endpoints-framework-gradle-plugin:1.0.0
related. I am kind of stuck...
Thanks for the link, i will check and try other way...
if i could go back to 'com.google.appengine:gradle-appengine-plugin:1.9.56'
i would do it...(in fact in parallel i tried to go roll back but now that
my dependencies are at 1.9.56 i got a lot of issues as this one
https://stackoverflow.com/questions/46554771/cannot-find-symbol-method-
setbatchpathstring-in-the-generated-source-from-ge or other duplicates
files exception)
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#66 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AHf5HW2qLxL4G4lKZINrwC4oOdJQALIqks5sq6yrgaJpZM4PxaZc>
.
|
@davemg3 Did you try the suggestion from the stacktrace to include Hibernate Validator on the classpath? |
compile group: 'org.hibernate', name: 'hibernate-validator', version: '6.0.2.Final' gives me an exception on console and i cannot deploy compile group: 'org.hibernate', name: 'hibernate-validator', version: '4.1.0.Final' brings some change with deployment successful but with a new exception in servlet: But I am still curious ; you think it is ok to have all these skipped WEB-INF/lib .jar, even for uploading of a new version? Seeing in gradle console "Uploading 0 files to Google Cloud Storage" seems suspect... I feel the root on my issue is somewhere else |
@davemg3 assuming none of those lib files have changed it seems normal to me. You can verify by deploying to a new GCP project. You should see all the files being uploaded. For your ClassNotResolvedException you may want to check out this link: https://stackoverflow.com/questions/15297363/google-app-engine-1-7-5-org-datanucleus-exceptions-classnotresolvedexception Hopefully it'll help. I highly recommend porting your JDO based classes to Objectify. |
Thank you for the link . I tried the solution disabling the auto scanning of entities and explicitly telling which classes to load while building PersistenceUnit will not help for me but i sends me back to previous message (before manual setting of JPA in gradle):
Looks like i am in a dead end.I will try your suggestion. |
Last question about your advice ; is there a reason no docs on Android Client+call to endpoints+endpoints+Objectify (to replace the JPA/JDO way)? For web app yes but not even a statement about integration with Android |
Objectify vs JPA/JDO should be orthogonal to Android+Endpoints.
We do have some documentation of using the new Endpoints Framework
libraries with Android here:
https://github.com/GoogleCloudPlatform/endpoints-framework-gradle-plugin/blob/master/ANDROID_README.md
…On Thu, Oct 12, 2017 at 11:37 AM, DaveMG3 ***@***.***> wrote:
Last question about your advice ; is there a reason no docs on Android
Client+endpoints+Objectify (to replace the JPA/JDO way)? For web app yes
but not even a statement about integration with Android
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#66 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AHf5HQV_Xs0_-4Dsd8rtAfqvGlHFxq-Eks5srjIqgaJpZM4PxaZc>
.
|
Hi. |
@patflynn, I didn't understand the request of what should be updated. |
@davemg3 have you tried deploying to a new App Engine version? If you're seeing an old list of Endpoints, this could be a known issue. |
Hello @tangiel , Not working : Working: (The formatting on github is not proper for @nAmed but nothing related with my code) Thanks for support! |
Hi,
Uploading my backend to app engine servers after updating my project with Framework V2 gives me a java.lang.NoClassDefFoundError when i try to access to some instance of EntityManagerFactory.
I have a class EMF that i call :
`
public final class EMF {
}
`
com.google.api.server.spi.SystemService invokeServiceMethod: exception occurred while calling backend method
java.lang.NoClassDefFoundError: Could not initialize class com.example.app.EMF
I thought SystemServiceServlet class was replaced by EndpointsServlet as in my web.xml so i dont understand why it is called
Google Cloud SDK 174.0.0
alpha 2017.09.15
app-engine-java 1.9.57
app-engine-python 1.9.61
bq 2.0.27
core 2017.10.02
gsutil 4.27
On V1 everything was fine.
Could it be close to other github issue :
#53
I created a post on SO on that :
https://stackoverflow.com/questions/46622757/with-framework-v2-trying-to-get-an-instance-of-entitymanagerfactory-to-be-used
Thanls
The text was updated successfully, but these errors were encountered: