Issue Details (XML | Word | Printable)

Key: HBX-1032
Type: Bug Bug
Status: Closed Closed
Resolution: Rejected
Priority: Blocker Blocker
Assignee: Unassigned
Reporter: Donatas Ciuksys
Votes: 0
Watchers: 2
Operations

If you were logged in you would be able to see more operations.
Hibernate Tools

HibernateConsoleRuntimeException: "Could not load JPA Configuration" for JavaSE JPA project

Created: 10/Jan/08 12:22 PM   Updated: 01/May/09 12:27 AM
Component/s: None
Affects Version/s: 3.2.0.GA
Fix Version/s: None

Time Tracking:
Not Specified

File Attachments: None
Image Attachments:

1. ProjectStructure.jpg
(72 kB)
Environment: Eclipse 3.3.1.1, HibernateTools 3.2.0 GA, JDK 1.6.0_03


 Description  « Hide
I have Java SE (not EE) project in Eclipse with standard structure like:

/src
/META-INF/persistence.xml
/bin
...

I try to create new Hibernate Configuration in "Hibernate Configurations" pannel. I choose project, select JPA (jdk 1.5+) option, fill in persistence unit "InventorizacijaPU", check whether Classpath tab is OK (it contains my project). Press OK. Trying to expand configuration created, I get this exception:

org.hibernate.console.HibernateConsoleRuntimeException: Could not create JPA based Configuration
at org.hibernate.console.ConsoleConfiguration.buildJPAConfiguration(ConsoleConfiguration.java:142)
at org.hibernate.console.ConsoleConfiguration.buildConfiguration(ConsoleConfiguration.java:496)
at org.hibernate.console.ConsoleConfiguration.access$0(ConsoleConfiguration.java:484)
at org.hibernate.console.ConsoleConfiguration$2.execute(ConsoleConfiguration.java:203)
at org.hibernate.console.execution.DefaultExecutionContext.execute(DefaultExecutionContext.java:65)
at org.hibernate.console.ConsoleConfiguration.buildWith(ConsoleConfiguration.java:185)
at org.hibernate.console.ConsoleConfiguration.build(ConsoleConfiguration.java:106)
at org.hibernate.eclipse.console.workbench.ConsoleConfigurationWorkbenchAdapter.getChildren(ConsoleConfigurationWorkbenchAdapter.java:38)
at org.hibernate.eclipse.console.workbench.BasicWorkbenchAdapter.getChildren(BasicWorkbenchAdapter.java:97)
at org.hibernate.eclipse.console.workbench.BasicWorkbenchAdapter.fetchDeferredChildren(BasicWorkbenchAdapter.java:103)
at org.eclipse.ui.progress.DeferredTreeContentManager$1.run(DeferredTreeContentManager.java:196)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
Caused by: org.hibernate.console.HibernateConsoleRuntimeException: Persistence unit not found: 'InventorizacijaPU'.
at org.hibernate.console.ConsoleConfiguration.buildJPAConfiguration(ConsoleConfiguration.java:134)
... 11 more

This is my persistence.xml:

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.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_1_0.xsd">
<persistence-unit name="InventorizacijaPU"
transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<class>lt.mitsoft.inventorizacija.domain.BuvimoVieta</class>
<class>lt.mitsoft.inventorizacija.domain.Inventorizacija</class>
<class>lt.mitsoft.inventorizacija.domain.Irasas</class>
<class>lt.mitsoft.inventorizacija.domain.IrasuBlokas</class>
<class>lt.mitsoft.inventorizacija.domain.Preke</class>
<class>lt.mitsoft.inventorizacija.domain.Skanuotojas</class>
<properties>
<property name="hibernate.dialect"
value="org.hibernate.dialect.DerbyDialect" />

<!-- <property name="hibernate.connection.url"
value="jdbc:derby:InventorizacijaDB" /> -->
<property name="hibernate.connection.url"
value="jdbc:derby://localhost:1527/InventorizacijaDB" />

<!-- <property name="hibernate.connection.driver_class"
value="org.apache.derby.jdbc.EmbeddedDriver"/> -->
<property name="hibernate.connection.driver_class"
value="org.apache.derby.jdbc.ClientDriver" />

<property name="hibernate.connection.username"
value="admin" />
<property name="hibernate.connection.password"
value="admin" />
<property name="hibernate.cache.provider_class"
value="org.hibernate.cache.NoCacheProvider" />

<!-- <property name="hibernate.show_sql" value="true" /> -->
</properties>
</persistence-unit>
</persistence>


 All   Comments   Work Log   Change History   FishEye      Sort Order: Ascending order - Click to sort in descending order
Max Rydahl Andersen added a comment - 10/Jan/08 03:30 PM
is the META-INF/persistence.xml actually on the classpath of your project ? why is it not inside src so it will end up in bin

Donatas Ciuksys added a comment - 11/Jan/08 12:38 AM
This is the structure of my project. It is standart Eclipse plugin project.

Donatas Ciuksys added a comment - 11/Jan/08 12:44 AM
Just added screenshot of my project structure. As you can see, META-INF also contains MANIFEST.MF file. I didn't put it here myself - Eclipse (for plugin projects) itself creates this META-INF folder in THIS PLACE (and not in src folder). Eclipse also automatically appends line:

META-INF/,\

to build.properties file, so META-INF directory finally end up in bin folder.

I tried to play with classpath tab of Hibernate Configuration creation wizard, tried to add the directory that contains META-INF as local directory, as external directory - no result, wizard still cannot see this META-INF/persistence.xml.

Do you want to say, that wizard looks for META-INF only in src folder (or bin folder)?

Donatas Ciuksys added a comment - 11/Jan/08 12:49 AM
I have validated this once more: Eclipse -> File -> New -> Project... -> Plug-in Project creates separate META-INF, src, and bin directories.

Donatas Ciuksys added a comment - 11/Jan/08 01:25 AM
I tried a quick hack: I copied META-INF directory to bin folder, and surprise - Hibernate Configuration got created without problems. So it seems that if I add my project to the classpath (Classpath tab of wizard), it looks for META-INF directory ONLY within [myproject]/bin folder. It should also look for it in [myproject]/ (root) folder, because all plug-in projects have META-INF in root folder (not in src), and you cannot move META-INF to src/ because this breaks plugin.xml file (I tried and had difficulties restoring everything back).

Donatas Ciuksys added a comment - 12/Mar/08 01:57 AM
This issue may be closed. The solution is to add additional META-INF folder containing persistence.xml file to src directory.

Max Rydahl Andersen added a comment - 12/Mar/08 03:53 AM
the root of your project is not part of the classpath so we won't see it...normal java classloader behavior.

Antony Stubbs added a comment - 30/Jul/08 09:30 PM
I had the same / similar problems:
"Could not load persistence unit {0}" or some such in nightly... really need some better error feedback I think. Something like
"Are you sure your presistence.xml is in META-INF/presistence.xml and on the class path?

SD added a comment - 30/Apr/09 07:18 PM
@Antony Stubbs
take care of the spelling. ain't "presistence.xm" it is "persistence.xml"

this is a common configuration issue.

Antony Stubbs added a comment - 01/May/09 12:27 AM
yes- but that was just me suggesting an error message that should be shown - i don't think i actually spelt it like that :) mind you, it was a while ago :)