Question

I try to generate database structure with my entities. To do that i use the Eclipse tool. I've the Kepler version but i've test with juno too.

"Right click on project -> JPA Tools -> Generate Table from entity"

But eclipse fails with this strange error :

Exception in thread "main" javax.persistence.PersistenceException: Found 'javax.persistence.provider' property in the map but the value is not a String. Found object : 'null'.
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:131)
at org.eclipse.jpt.jpa.eclipselink.core.ddlgen.Main.buildEntityManagerFactory(Main.java:94)
at org.eclipse.jpt.jpa.eclipselink.core.ddlgen.Main.execute(Main.java:80)
at org.eclipse.jpt.jpa.eclipselink.core.ddlgen.Main.main(Main.java:68)

This is my persistence.xml

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0" 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">
<persistence-unit name="myApp" transaction-type="RESOURCE_LOCAL">
    <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
    <exclude-unlisted-classes>false</exclude-unlisted-classes>
    <shared-cache-mode>ENABLE_SELECTIVE</shared-cache-mode>
    <properties>
        <property name="javax.persistence.jdbc.url" value="jdbc:postgresql://localhost:5432/superng"/>
        <property name="javax.persistence.jdbc.user" value="postgres"/>
        <property name="javax.persistence.jdbc.password" value="changeit"/>
        <property name="javax.persistence.jdbc.driver" value="org.postgresql.Driver"/>
        <property name="eclipselink.ddl-generation" value="drop-and-create-tables"/>
        <property name="eclipselink.ddl-generation.output-mode" value="sql-script"/>
    </properties>
</persistence-unit>

Why does it fails?

Was it helpful?

Solution

I think there is no problem with persistence.xml , but conflict between java-ee- jar and another jar that contains the javax.persistence.* packages. you need to modify java-ee jar or make sure to have only a single version of the javax.persistence.* packages in the classpath.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top