-->
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.  [ 3 posts ] 
Author Message
 Post subject: Tools 3.1.0alpha5: hbm2ddl and Annotations don't work
PostPosted: Sun Sep 18, 2005 10:16 am 
Regular
Regular

Joined: Tue May 24, 2005 9:06 am
Posts: 64
Hibernate version: 3.1beta3
Hibernate Annotations version: 3.1beta5
Hibernate Tools version: 3.1.0alpha5
Database version: MySQL 5.0.12

I've persistent classes with Hibernate Annotations. The classes are declared in hibernate.cfg.xml, and everything works fine.

Now, I want to generate DDL statements using Ant and <hbm2ddl> and get an exception (see below). Any hint is appreciated!

Extract of build.xml for Ant:
<taskdef name="hibernatetool"
classname="org.hibernate.tool.ant.HibernateToolTask"
classpathref="hibernateToolTask.classpath"/>

<hibernatetool destdir="${gen.dir}">
<annotationconfiguration propertyFile="${hibernate.properties}"
configurationfile="${hibernate.cfg.xml}"/>
<hbm2ddl drop="false" outputfilename="createTables.sql"/>
</hibernatetool>

Stack trace:
[hibernatetool] Executing Hibernate Tool with a Hibernate Annotation/EJB3 Configuration
[hibernatetool] 1. task: hbm2ddl (Generates database schema)
[hibernatetool] FATAL connection.DatasourceConnectionProvider - Could not find datasource: java:comp/env/jdbc/demodb
[hibernatetool] javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
[hibernatetool] at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:645)
[hibernatetool] at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:247)
[hibernatetool] at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:284)
[hibernatetool] at javax.naming.InitialContext.lookup(InitialContext.java:351)
[hibernatetool] at org.hibernate.connection.DatasourceConnectionProvider.configure(DatasourceConnectionProvider.java:52)
[hibernatetool] at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:124)
[hibernatetool] at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:56)
[hibernatetool] at org.hibernate.tool.hbm2ddl.SchemaExport$ProviderConnectionHelper.getConnection(SchemaExport.java:453)
[hibernatetool] at org.hibernate.tool.hbm2ddl.SchemaExport.execute(SchemaExport.java:181)
[hibernatetool] at org.hibernate.tool.hbm2ddl.SchemaExport.create(SchemaExport.java:133)
[hibernatetool] at org.hibernate.tool.ant.Hbm2DDLGeneratorTask.execute(Hbm2DDLGeneratorTask.java:48)
[hibernatetool] at org.hibernate.tool.ant.HibernateToolTask.execute(HibernateToolTask.java:122)
[hibernatetool] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
[hibernatetool] at org.apache.tools.ant.Task.perform(Task.java:364)
[hibernatetool] at org.apache.tools.ant.Target.execute(Target.java:341)
[hibernatetool] at org.apache.tools.ant.Target.performTasks(Target.java:369)
[hibernatetool] at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216)
[hibernatetool] at org.apache.tools.ant.Project.executeTarget(Project.java:1185)
[hibernatetool] at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:40)
[hibernatetool] at org.eclipse.ant.internal.ui.antsupport.EclipseDefaultExecutor.executeTargets(EclipseDefaultExecutor.java:32)
[hibernatetool] at org.apache.tools.ant.Project.executeTargets(Project.java:1068)
[hibernatetool] at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.run(InternalAntRunner.java:423)
[hibernatetool] at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.main(InternalAntRunner.java:137)
[hibernatetool] ERROR hbm2ddl.SchemaExport - schema export unsuccessful
[hibernatetool] org.hibernate.HibernateException: Could not find datasource
[hibernatetool] at org.hibernate.connection.DatasourceConnectionProvider.configure(DatasourceConnectionProvider.java:56)
[hibernatetool] at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:124)
[hibernatetool] at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:56)
[hibernatetool] at org.hibernate.tool.hbm2ddl.SchemaExport$ProviderConnectionHelper.getConnection(SchemaExport.java:453)
[hibernatetool] at org.hibernate.tool.hbm2ddl.SchemaExport.execute(SchemaExport.java:181)
[hibernatetool] at org.hibernate.tool.hbm2ddl.SchemaExport.create(SchemaExport.java:133)
[hibernatetool] at org.hibernate.tool.ant.Hbm2DDLGeneratorTask.execute(Hbm2DDLGeneratorTask.java:48)
[hibernatetool] at org.hibernate.tool.ant.HibernateToolTask.execute(HibernateToolTask.java:122)
[hibernatetool] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
[hibernatetool] at org.apache.tools.ant.Task.perform(Task.java:364)
[hibernatetool] at org.apache.tools.ant.Target.execute(Target.java:341)
[hibernatetool] at org.apache.tools.ant.Target.performTasks(Target.java:369)
[hibernatetool] at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216)
[hibernatetool] at org.apache.tools.ant.Project.executeTarget(Project.java:1185)
[hibernatetool] at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:40)
[hibernatetool] at org.eclipse.ant.internal.ui.antsupport.EclipseDefaultExecutor.executeTargets(EclipseDefaultExecutor.java:32)
[hibernatetool] at org.apache.tools.ant.Project.executeTargets(Project.java:1068)
[hibernatetool] at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.run(InternalAntRunner.java:423)
[hibernatetool] at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.main(InternalAntRunner.java:137)
[hibernatetool] Caused by: javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
[hibernatetool] at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:645)
[hibernatetool] at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:247)
[hibernatetool] at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:284)
[hibernatetool] at javax.naming.InitialContext.lookup(InitialContext.java:351)
[hibernatetool] at org.hibernate.connection.DatasourceConnectionProvider.configure(DatasourceConnectionProvider.java:52)
[hibernatetool] ... 18 more


Top
 Profile  
 
 Post subject:
PostPosted: Sun Sep 18, 2005 11:08 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
may i ask how you think hibernate ant toolsset should get a connection from the Datasource you have told it to get the connection from ? ;)

you need to use DriverconnectionManager when using from ant.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject: Re: Tools 3.1.0alpha5: hbm2ddl and Annotations don't work
PostPosted: Mon Feb 21, 2011 9:08 am 
Newbie

Joined: Mon Feb 21, 2011 8:54 am
Posts: 1
Hallo,

can you please explain how you configure this DriverconnectionManager in the ant task. I use ant inside maven build and cannot get it to export the schema to the Database. When I set export=true it overwrites the output files and they are empty after that. Where should the DB Information(url, username, password, DriverClass, Dialect) be? This information is in my configuration in the persistence.xml.

Here is my ant task in the pom.xml:
Code:
<taskdef name="hibernatetool" classname="org.hibernate.tool.ant.HibernateToolTask" />
<hibernatetool destdir="./src/main/resources/Hypersonic/default">
   <jpaconfiguration persistenceunit="persistenceUnitHypersonic" />
   <classpath>
      <path location="./target/classes/Hypersonic/" />
   </classpath>
   <!-- list exporters here -->
   <hbm2ddl export="false" update="false" drop="true"
      create="false" outputfilename="drop.sql" delimiter=";"
      format="true" haltonerror="false">
   </hbm2ddl>
   <hbm2ddl export="true" update="false" drop="false"
      create="true" outputfilename="create.sql" delimiter=";"
      format="true" haltonerror="false">
   </hbm2ddl>
   
</hibernatetool>

Thanks in advice.
Anton


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.