Note that there are some explanatory texts on larger screens.

plurals
  1. POCannot initialize EntityManager in Netbeans via Junit
    primarykey
    data
    text
    <p>I have a bunch of service (ejb 3) classes that i want to unit test. In order to do so, i have added to their implementing classes an overloaded constructor which takes an EntityManager as an argument. The idea is that during my units tests i will create a both an EntityManager instance from a persistence unit specific for my unit tests, and an instance of my service class using the overloaded constructor. There, i pass the EntityManger created from my within my unit tests.</p> <p>My PU is configured as follows:</p> <pre><code>&lt;persistence-unit name="MyPU-junit" transaction-type="RESOURCE_LOCAL"&gt; &lt;provider&gt;org.hibernate.ejb.HibernatePersistence&lt;/provider&gt; &lt;non-jta-data-source/&gt; &lt;properties&gt; &lt;property name="hibernate.hbm2ddl.auto" value="update"/&gt; &lt;/properties&gt; &lt;/persistence-unit&gt; </code></pre> <p>And this is what i do to create my EntityManager in my unit test:</p> <pre><code> Map&lt;String, String&gt; config = new HashMap&lt;String, String&gt;(); config.put("connection.url", "jdbc:postgresql://localhost:5432/MyDb"); config.put("connection.username", "postgres"); config.put("connection.password", "admin12345_"); config.put("connection.driver_class", "org.postgresql.Driver"); config.put("hibernate.dialect", "org.hibernate.dialect.PostgreSQLDialect"); config.put("hibernate.show_sql", "true"); emf = Persistence.createEntityManagerFactory("MyPU-junit", config); em = emf.createEntityManager(); </code></pre> <p>The problem is that i get this error:</p> <pre><code>SEVERE: could not complete schema update java.lang.UnsupportedOperationException: The user must supply a JDBC connection at org.hibernate.connection.UserSuppliedConnectionProvider.getConnection(UserSuppliedConnectionProvider.java:30) at org.hibernate.tool.hbm2ddl.SuppliedConnectionProviderConnectionHelper.prepare(SuppliedConnectionProviderConnectionHelper.java:27) at org.hibernate.tool.hbm2ddl.SchemaUpdate.execute(SchemaUpdate.java:127) at org.hibernate.impl.SessionFactoryImpl.&lt;init&gt;(SessionFactoryImpl.java:314) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1294) at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:859) at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:669) at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:126) at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:51) </code></pre> <p>I'm not sure it's related with the previous error but I'm also getting a bunch of warnings from the parser during initialization:</p> <pre><code>Failed to read schema document 'http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd' </code></pre> <p>Note that i did tried to run the same thing by putting the hibernate parameters in the persistence.xml file directly instead of programmatically.</p> <p>I am using netbeans 6.9.</p> <p>Any help is REALLY welcomed! I'm truly frustrated with this...</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload