kundera icon indicating copy to clipboard operation
kundera copied to clipboard

persistence.xml With SBT Project

Open bryaan opened this issue 10 years ago • 3 comments

I placed the persistence.xml file in history/src/main/resources/META-INF/ yet I am still getting an error.

Where should I be putting the XML file, and what should I change with SBT?

SBT:

lazy val history = (project in file("history"))
  .settings(
    libraryDependencies += "com.impetus.kundera.client" % "kundera-cassandra" % "2.17"
  )

Some Scala Code: (Java Conversion is Straightforward)

object Test {
  def main(args: Array[String]) {

    new HistoryCore()

  }
}

class HistoryCore {

  val emf: EntityManagerFactory = Persistence.createEntityManagerFactory("cassandra_pu")

  val em: EntityManager = emf.createEntityManager()
  em.persist(TradeData(DateTime.now(), 1.618))
  em.close()
  emf.close()

  // @BeanProperty dynamically adds a getter and a setter for the given variable. This keeps the code clean and the JPA implementation working
  @Entity
  @Table(name = "users", schema = "KunderaExamples@cassandra_pu")
  case class TradeData(@Id
                       @BeanProperty
                       var time: DateTime,
                       @Column(name = "price")
                       @BeanProperty
                       var price: Double)
}

Error:

20:45:47.537 [main] INFO  c.i.k.p.EntityManagerFactoryImpl - Loading Core
20:45:47.770 [main] INFO  c.impetus.kundera.loader.CoreLoader - Loading Kundera Core Metdata ... 
20:45:47.775 [main] INFO  c.i.k.p.EntityManagerFactoryImpl - Loading Persistence Unit MetaData For Persistence Unit(s) cassandra_pu.
20:45:47.789 [main] INFO  c.i.k.c.PersistenceUnitConfiguration - Loading Metadata from persistence.xml ...
20:45:47.794 [main] ERROR c.i.k.c.PersistenceUnitConfiguration - Could not find any META-INF/persistence.xml file in the classpath

Project Structure:

enter image description here

bryaan avatar Jun 18 '15 19:06 bryaan

@futurehorizon

We are looking into the issue and will get back to you.

Chhavi

chhavigangwal avatar Jun 22 '15 12:06 chhavigangwal

@futurehorizon Bottomline is, persistence.xml has to be on classpath as META-INF/persistence.xml

Not sure, but please see if https://github.com/knoldus/playing-kundera-cassandra helps you!

-Vivek

mevivs avatar Jul 27 '15 12:07 mevivs

Hi @bryaan

I have a Play! Java project that I'm building with SBT and the Play! recomendations is to put the persistence.xml in the conf/META-INF dir. The build process copies this folder to the target dir and adds it to classpath when running the application. So I figure it's a classpath problem. Please check if the resources folder is being included in the classpath of your application when running.

Regards

si24803 avatar May 07 '18 12:05 si24803