Play Framework Unable to build entity manager factory when Working with PostGIS

1.3k views Asked by At

I'm trying to work with PostGIS with Hibernate and JPA in play! framework but I'm stuck with this exception here is the error when ever work with the variable point in the Class Place (it was working fine before adding the class place): I'm Using PostgreSQL 9.4 and postGIS 2.1.7

application.conf

db.default.driver=org.postgresql.Driver
db.default.url="jdbc:postgresql://localhost:5432/datastore"
jpa.default=defaultPersistenceUnit
db.default.jndiName=DefaultDS

error

   [ProvisionException: Unable to provision, see the following errors:

1) Error injecting constructor, javax.persistence.PersistenceException: Unable to build entity manager factory
  at play.db.jpa.DefaultJPAApi$JPAApiProvider.<init>(DefaultJPAApi.java:35)
  at play.db.jpa.DefaultJPAApi$JPAApiProvider.class(DefaultJPAApi.java:30)
  while locating play.db.jpa.DefaultJPAApi$JPAApiProvider
  while locating play.db.jpa.JPAApi

1 error]

Persistence.xml

<persistence xmlns="http://java.sun.com/xml/ns/persistence"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
             version="2.0">

<persistence-unit name="defaultPersistenceUnit" transaction-type="RESOURCE_LOCAL">
    <provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
    <non-jta-data-source>DefaultDS</non-jta-data-source>
    <class>models.Place</class>
    <class>models.Utilisateur</class>
    <exclude-unlisted-classes>true</exclude-unlisted-classes>
    <properties>
        <property name="hibernate.show_sql" value="false"/>
        <property name="hibernate.dialect" value="org.hibernatespatial.postgis.PostgisDialect"/>
        <!--<property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5Dialect"/>-->
        <property name="hibernate.hbm2ddl.auto" value="create"/>
    </properties>
</persistence-unit>

Place.java

package models;

import org.hibernate.annotations.Type;
import com.vividsolutions.jts.geom.Point;
import javax.persistence.*;
@Entity
@Table(name = "place")
public class Place {
    @Id
    @GeneratedValue
    public Integer id;
    public String type;
    @Type(type="org.hibernate.spatial.GeometryType")
    public Point location;
}

Build.sbt

lazy val root = (project in file(".")).enablePlugins(PlayJava)

scalaVersion := "2.11.6"

libraryDependencies ++= Seq(
  javaJdbc,
  cache,
  javaWs,
  javaCore,
  javaJpa,
  "org.hibernate" % "hibernate-entitymanager" % "4.3.9.Final"
)
libraryDependencies += "org.postgresql" % "postgresql" % "9.4-1201-jdbc41"
libraryDependencies +="org.postgis" % "postgis-jdbc" % "1.5.2"
libraryDependencies +="org.hibernate" % "hibernate-spatial" % "4.3"
libraryDependencies +="org.hibernate" % "hibernate-testing" % "4.3.7.Final"
libraryDependencies +="com.google.inject" % "guice" % "4.0"
resolvers +=("Hibernate Spatial Repository" at "http://www.hibernatespatial.org/repository")

// Play provides two styles of routers, one expects its actions to be injected, the
// other, legacy style, accesses its actions statically.
routesGenerator := InjectedRoutesGenerator
0

There are 0 answers