Problem using JPA console

I'm having problems runing the JPA console. I have a simple Java EE project and wanted to try this but all I got is this message:

jpa-ql> select c.id from Cliente c
java.lang.RuntimeException: javax.persistence.PersistenceException: No Persistence provider for EntityManager named EscuderServerPersistenceUnit
    at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:84)
    at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:54)



The datasource console (simple jdbc + sql) works fine. The such "EscuderServerPersistenceUnit" is configured to the datasource. I'm using GlassFish 3 so I've configured the JPA provider to EclipseLink.

3 comments
Comment actions Permalink

This is because of incorrect JPA configuration. Make sure you could start your persistence unit manually. I hope you googled the message. See http://stackoverflow.com/questions/3230798/eclipselink-no-persistence-provider-for-entitymanager-named. Probably, you just need this in the persistence.xml:

<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>

Also, you should properly configure jpa facet - choose available datasourcee, appropriate persitence unit, correct provider. Also, you have to provide more data regarding your configuration to get the answer. At least persistence.xml + jpa facet configuration.

0
Comment actions Permalink

Thanks for the answer.

Make sure you could start your persistence unit manually.


Don't know how to do this. Or perhaps is what I'm doing right now. I just open the persistence tab, it shows my persistence unit, right click, select "Open Query Console".

I hope you googled the message. See http://stackoverflow.com/questions/3230798/eclipselink-no-persistence-provider-for-entitymanager-named. Probably, you just need this in the persistence.xml:

<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="2.0">
  <persistence-unit name="EscuderServerPersistenceUnit">
    <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
    <jta-data-source>jdbc/escuderserver</jta-data-source>
  </persistence-unit>
</persistence>


And my face configuration:

    <facet type="jpa" name="JPA">
      <configuration>
        <setting name="validation-enabled" value="true" />
        <setting name="provider-name" value="EclipseLink" />
        <datasource-mapping>
          <factory-entry name="EscuderServerPersistenceUnit" value="0bc06bd8-3355-418c-afbc-9bcb4f8a150e" />
        </datasource-mapping>
        <deploymentDescriptor name="persistence.xml" url="file://$MODULE_DIR$/src/META-INF/persistence.xml" />
      </configuration>
    </facet>


The hex mapping for the datasource has a match on dataSources.ids and the datasource works ok on IDEA (using the plain sql console).

Ok, so with your hint I've found that my problem was that I was not including the classes for eclipselink. So, after adding some jars to the application server library, now the problem seems to be configuration of the eclipselink parameters:

java.lang.RuntimeException: javax.persistence.PersistenceException: Exception [EclipseLink-4021] (Eclipse Persistence Services - 2.0.1.v20100213-r6600): org.eclipse.persistence.exceptions.DatabaseException
Exception Description: Unable to acquire a connection from driver [null], user [null] and URL [null].  Verify that you have set the expected driver class and URL.  Check your login, persistence.xml or sessions.xml resource.  The jdbc.driver property should be set to a class that is compatible with your database platform
    at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:397)
    at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.getServerSession(EntityManagerFactoryImpl.java:151)
    at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManagerImpl(EntityManagerFactoryImpl.java:207)
    at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:195)


I can see EclipseLink doesn't know the driver, url and so... but I don't know how to configure it and... shouldn't idea pick that up from the link to the datasource it already has?

Thank you!

0
Comment actions Permalink

idea couln't connect to the database using jta datasource configured in the glassfish. You can see there are no any information in the facet descriptor, there are no any association with the datasource. try to create an alternate persistence.xml providing the jdbc url and credentials explicitly: http://wiki.eclipse.org/EclipseLink/Examples/JPA/RCP#Persistence.xml

Regards, Alex

0

Please sign in to leave a comment.