-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 15 posts ] 
Author Message
 Post subject: Persistence unit not found (sorry for repeat)
PostPosted: Tue Jan 19, 2010 8:28 am 
Beginner
Beginner

Joined: Tue Jan 19, 2010 7:11 am
Posts: 23
Location: Spain
Hello, sorry for my english and sorry for repeat subject but the others topics with this subject didn't resolve my problem.

My example es very easy, i have a Dynamic web project with a 3 files: persistence.xml, hibernate.revenge.xml and build.xml.

I want to generate entitys and dao's with jpa annotations from a data base (Oracle10g).

build.xml:


<project name="MyProject" default="hbm2java" basedir=".">
<path id="lib.class.path">
<fileset dir="C:\Alvaro\Software\OtherLib">
<include name="*.jar" />
</fileset>
<fileset dir="C:\Alvaro\Software\JAR's">
<include name="*.jar"/>
</fileset>
</path>

<target name="hbm2java">
<taskdef name="hibernatetool" classname="org.hibernate.tool.ant.HibernateToolTask" classpathref="lib.class.path" />

<hibernatetool destdir="src">
<!-- JPA configuration -->
<jpaconfiguration persistenceunit="PruebaAntPersistence" />
<!--<jdbcconfiguration packagename="" configurationfile="hibernate.cfg.xml" revengfile="../WebContent/WEB-INF/hibernate.reveng.xml" ></jdbcconfiguration> -->
<hbm2java destdir="" templatepath="/templates" jdk5="true" ejb3="true" />
<hbm2dao destdir="" jdk5="true" ejb3="true" />
<classpath>
<path location="${build.dir}/target/classes" />
</classpath>
</hibernatetool>
</target>
</project>


If i uncommented line "<jdbcconfiguration....." ( with hibernate.cfg.xml instead of persistence.xml) and commented <jpaconfiguration... runs right

persistence.xml:


<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/ ... ce_1_0.xsd">

<persistence-unit name="PruebaAntPersistence" >
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<properties>
<property name="hibernate.connection.driver_class" value="oracle.jdbc.driver.OracleDriver" />
<property name="hibernate.connection.password" value="XXX" />
<property name="hibernate.connection.url" value="jdbc:oracle:thin:@XX.XX.XX.XX:XXXX:orcl28" />
<property name="hibernate.connection.username" value="XXX" />
<property name="hibernate.default_schema" value="XXX" />
<property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect" />
</properties>
</persistence-unit>
</persistence>


I put the file persistence.xml in all sites (/, /src, /src/META-INF, ........) of my project, and it is in Project\build\classes\META-INF

I don't understand why doesn't it run.

Thanks and sorry for my english again.


Last edited by alvarorodriguezmoroy on Tue Jan 19, 2010 10:57 am, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: Persistence unit not found (sorry for repeat)
PostPosted: Tue Jan 19, 2010 8:42 am 
Senior
Senior

Joined: Tue Aug 04, 2009 7:45 am
Posts: 124
Remove line provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>


Top
 Profile  
 
 Post subject: Re: Persistence unit not found (sorry for repeat)
PostPosted: Tue Jan 19, 2010 10:49 am 
Beginner
Beginner

Joined: Tue Jan 19, 2010 7:11 am
Posts: 23
Location: Spain
Thanks for replay Dmitry.

I have remove that line, but the problem persist.

I don't know why, but it don't find the persistence.xml file.

Thanks.


Top
 Profile  
 
 Post subject: Re: Persistence unit not found (sorry for repeat)
PostPosted: Tue Jan 19, 2010 10:57 am 
Senior
Senior

Joined: Tue Aug 04, 2009 7:45 am
Posts: 124
Probably you also need to change <path location="${build.dir}/target/classes" /> to <path location="${build.dir}/classes" />. Look where your Web-Inf folder is located.


Top
 Profile  
 
 Post subject: Re: Persistence unit not found (sorry for repeat)
PostPosted: Tue Jan 19, 2010 10:57 am 
Senior
Senior

Joined: Tue Aug 04, 2009 7:45 am
Posts: 124
I meant META-INF


Top
 Profile  
 
 Post subject: Re: Persistence unit not found (sorry for repeat)
PostPosted: Tue Jan 19, 2010 10:59 am 
Beginner
Beginner

Joined: Tue Jan 19, 2010 7:11 am
Posts: 23
Location: Spain
Ok, i try it.

Thanks.


Top
 Profile  
 
 Post subject: Re: Persistence unit not found (sorry for repeat)
PostPosted: Tue Jan 19, 2010 11:08 am 
Beginner
Beginner

Joined: Tue Jan 19, 2010 7:11 am
Posts: 23
Location: Spain
The problem continues

The stacktrace is:


org.hibernate.console.HibernateConsoleRuntimeException: Persistence unit not found: 'PruebaAntPersistence'.
at org.hibernate.console.ConsoleConfiguration.buildJPAConfiguration(ConsoleConfiguration.java:149)
at org.hibernate.console.ConsoleConfiguration.buildConfiguration(ConsoleConfiguration.java:634)
at org.hibernate.console.ConsoleConfiguration.access$0(ConsoleConfiguration.java:619)
at org.hibernate.console.ConsoleConfiguration$2.execute(ConsoleConfiguration.java:287)
at org.hibernate.console.execution.DefaultExecutionContext.execute(DefaultExecutionContext.java:64)
at org.hibernate.console.ConsoleConfiguration.buildWith(ConsoleConfiguration.java:269)
at org.hibernate.eclipse.launch.CodeGenerationLaunchDelegate.buildConfiguration(CodeGenerationLaunchDelegate.java:275)
at org.hibernate.eclipse.launch.CodeGenerationLaunchDelegate.runExporters(CodeGenerationLaunchDelegate.java:218)
at org.hibernate.eclipse.launch.CodeGenerationLaunchDelegate.launch(CodeGenerationLaunchDelegate.java:138)
at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:764)
at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:614)
at org.eclipse.debug.internal.ui.DebugUIPlugin.buildAndLaunch(DebugUIPlugin.java:880)
at org.eclipse.debug.internal.ui.DebugUIPlugin$8.run(DebugUIPlugin.java:1083)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)


Thanks.


Top
 Profile  
 
 Post subject: Re: Persistence unit not found (sorry for repeat)
PostPosted: Tue Jan 19, 2010 11:20 am 
Senior
Senior

Joined: Tue Aug 04, 2009 7:45 am
Posts: 124
Are you sure your META-INF folder in your <path location="<your path>" /> and has right persistent.xml? I asked because this shoud work(removed <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider> ?).


Top
 Profile  
 
 Post subject: Re: Persistence unit not found (sorry for repeat)
PostPosted: Tue Jan 19, 2010 11:28 am 
Beginner
Beginner

Joined: Tue Jan 19, 2010 7:11 am
Posts: 23
Location: Spain
I'm not sure, but I put the absolute path:

<path location="C:\eclipse\workspace\PruebaAnt\build\classes\META-INF" />

If i go with windows explorer to this path, there is persistence.xml.

I don't know if that is right.

The line "<provider>....." is removed.


Top
 Profile  
 
 Post subject: Re: Persistence unit not found (sorry for repeat)
PostPosted: Tue Jan 19, 2010 12:29 pm 
Beginner
Beginner

Joined: Tue Jan 19, 2010 7:11 am
Posts: 23
Location: Spain
Can i use the file reveng.xml (or hibernate.reveng.xml) to configure generator code with jpa configuration???


Top
 Profile  
 
 Post subject: Re: Persistence unit not found (sorry for repeat)
PostPosted: Wed Jan 20, 2010 4:36 am 
Senior
Senior

Joined: Tue Aug 04, 2009 7:45 am
Posts: 124
Quote:
I'm not sure, but I put the absolute path:
<path location="C:\eclipse\workspace\PruebaAnt\build\classes\META-INF" />


I said you to put path to parent folder of META-INF. So your path shoud be
<path location="C:\eclipse\workspace\PruebaAnt\build\classes" />


Top
 Profile  
 
 Post subject: Re: Persistence unit not found (sorry for repeat)
PostPosted: Wed Jan 20, 2010 5:19 am 
Beginner
Beginner

Joined: Tue Jan 19, 2010 7:11 am
Posts: 23
Location: Spain
Dmitry, thanks, already I had given up myself.

Thank you very much.

It run right!!!!!!!!!


Top
 Profile  
 
 Post subject: Re: Persistence unit not found (sorry for repeat)
PostPosted: Wed Jan 20, 2010 6:23 am 
Beginner
Beginner

Joined: Tue Jan 19, 2010 7:11 am
Posts: 23
Location: Spain
Ok, it run right.

Buildfile: C:\eclipse\workspace\PruebaAnt\src\build.xml
hbm2java:
[hibernatetool] Executing Hibernate Tool with a JPA Configuration
[hibernatetool] 1. task: hbm2java (Generates a set of .java files)
[hibernatetool] log4j:WARN No appenders could be found for logger (org.hibernate.cfg.annotations.Version).
[hibernatetool] log4j:WARN Please initialize the log4j system properly.
[hibernatetool] 2. task: hbm2dao (Generates a set of DAOs)
BUILD SUCCESSFUL
Total time: 969 milliseconds


But i don't find generated code...

In my ant:


<hibernatetool destdir="src" taskname="hibernatetool">
<jpaconfiguration persistenceunit="PruebaAntPersistence" />
<!--<jdbcconfiguration packagename="" configurationfile="hibernate.cfg.xml" revengfile="../WebContent/WEB-INF/hibernate.reveng.xml" ></jdbcconfiguration>-->
<hbm2java destdir="src" jdk5="true" ejb3="true" />
<hbm2dao destdir="" jdk5="true" ejb3="true" />
<classpath>
<!-- <path location="${build.dir}" />-->
<path location="C:\eclipse\workspace\PruebaAnt\build\classes\" />
</classpath>
</hibernatetool>


But there isn't code in src folder...

Sorry for the new problem...


Top
 Profile  
 
 Post subject: Re: Persistence unit not found (sorry for repeat)
PostPosted: Tue Jan 26, 2010 5:26 am 
Senior
Senior

Joined: Tue Aug 04, 2009 7:45 am
Posts: 124
Yes, I faced the same problem... and the solution is: use jbdcconfiguration for this(because jpaconfiguration is not for reverceengeneering :( ). See http://docs.jboss.org/tools/3.0.0.GA/en ... l/ant.html.


Top
 Profile  
 
 Post subject: Re: Persistence unit not found (sorry for repeat)
PostPosted: Tue Jan 26, 2010 12:44 pm 
Beginner
Beginner

Joined: Tue Jan 19, 2010 7:11 am
Posts: 23
Location: Spain
Thank you very much Dmitry.

I will use jdbcconfiguration.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 15 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.