7

I'm following the Appsrox tutorial on how to Create an Instant Messaging app using Google Cloud Messaging (GCM). The differences are that I use Android Studio instead of Eclipse, and Gradle for build automation. I've tried to put META-INF inside 'src/main' folder but I got a warning from Google App Engine:

Warning:No META-INF/persistence.xml files were found in the CLASSPATH of the current thread!

EntityManager crashes during the initialization process, cause it can't find 'persistence.xml'.

I'm looking for a simple answer to what should be a simple issue: where do I put META-INF folder?

naXa stands with Ukraine
  • 35,493
  • 19
  • 190
  • 259
  • 1
    possible duplicate of [Where do gradle unit tests for Google app engine expect persistence.xml?](http://stackoverflow.com/questions/29230881/where-do-gradle-unit-tests-for-google-app-engine-expect-persistence-xml) – Jonas Czech Apr 03 '15 at 12:45

2 Answers2

16

In Gradle based project place the META-INF folder containing 'persistence.xml' in '/src/main/resources'. (The same is true for a Maven based project)

Find more about Standard Directory Layout here.

naXa stands with Ukraine
  • 35,493
  • 19
  • 190
  • 259
4

As @naXa suggested, '/src/main/resources' is the default location, and you should normally put it there. But if for some reason that's not practical, you can place it anywhere you want as long as you tell Gradle about it. For example, if you wanted to place the META-INF directory in 'src/main/java', you could write:

// Allow resources to live in same directory as source code
sourceSets.main.resources.srcDirs += ["src/main/java"]
sourceSets.test.resources.srcDirs += ["src/test/java"]
dnault
  • 8,340
  • 1
  • 34
  • 53