-->
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.  [ 5 posts ] 
Author Message
 Post subject: Having a problem with SchemaExport
PostPosted: Thu Jan 24, 2008 5:41 pm 
Newbie

Joined: Thu Jan 24, 2008 5:17 pm
Posts: 6
This is probably something silly, but so far I haven't turned up an answer.

I'm a new Hibernate user. I've got what so far is an extremely simple program, written in Eclipse using (among other things) Hibernate Tools. (Note that I'm doing everything in Eclipse to start, to get my dev environment up and running: I haven't tackled the Ant side yet.) The Tools are successfully generating the POJO files, and the program *runs* (somewhat to my surprise -- I was expecting a crash at this point), although it's not actually doing anything to the DB.

My issue is with SchemaExport. The Eclipse Perspective can clearly see the database, because it is showing up correctly in the Hibernate Configuration view -- it shows the tables and such correctly. But when I run SchemaExport from the Hibernate Configurations View, I get a HibernateException, which at its root seems to be due to this inner exception:

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
at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.getURLOrDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.lookup(Unknown Source)
at org.hibernate.connection.DatasourceConnectionProvider.configure(DatasourceConnectionProvider.java:52)
at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:124)
at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:56)
at org.hibernate.tool.hbm2ddl.ManagedProviderConnectionHelper.prepare(ManagedProviderConnectionHelper.java:27)
at org.hibernate.tool.hbm2ddl.SchemaExport.execute(SchemaExport.java:180)
at org.hibernate.tool.hbm2ddl.SchemaExport.create(SchemaExport.java:133)
at org.hibernate.eclipse.console.views.SchemaExportAction$1.execute(SchemaExportAction.java:73)

The implication seems to be that there's some kind of JNDI setup I need in order to make SchemaExport work properly, but I have no idea where that would go in this case. (The app itself runs in Tomcat, but I'm not actually running the app yet, just SchemaExport within the Eclipse Tools. It seems like I need to manage the configuration of SchemaExport itself in this case, but I may be misunderstanding -- I'm coming from the .NET side of the world, so I'm extremely new to JNDI in general.)

Is there something that needs to go into the hibernate.cfg.xml to make this work? The current state of the file looks like this:

Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
      "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
   "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
    <session-factory>
        <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
        <property name="hibernate.connection.password">password</property>
        <property name="hibernate.connection.url">jdbc:mysql://localhost:3306/test2</property>
        <property name="hibernate.connection.username">CommYou</property>
        <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
        <mapping resource="com/commyou/Core/Person.hbm.xml"/>
    </session-factory>
</hibernate-configuration>


Like I said, the Perspective is clearly reading this successfully, since it's showing the test2 DB right. But I'm clearly missing something about SchemaExport itself...


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 24, 2008 5:48 pm 
Newbie

Joined: Thu Jan 24, 2008 5:17 pm
Posts: 6
Oh, and just to be clear: I'm starting from the mapping files, and intending to generate both the POJO and schemas from that. This sort of metadata-centric development model is one I'm pretty comfortable with, and one of the things I like about Hibernate...


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 28, 2008 7:59 am 
Newbie

Joined: Sat Mar 05, 2005 2:36 pm
Posts: 19
Mark,

The configuration looks perfectly ok to me. SchemaExport does not need any JNDI setup, or data source configuration.

There seems to be a data source configured, otherwise SchemaExport would not try look it up. Is it possible that you have added such a parameter to the export settings?

Kariem


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 28, 2008 5:12 pm 
Newbie

Joined: Thu Jan 24, 2008 5:17 pm
Posts: 6
Ah -- okay, that may be it. I do indeed have a DataSource set up in Tomcat, from some previous JDBC experiments. It hadn't occurred to me that that might be getting in the way. I'll try commenting that out: thanks!


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 28, 2008 8:32 pm 
Newbie

Joined: Thu Jan 24, 2008 5:17 pm
Posts: 6
Yep, that seems to have done it -- I took the Resource entry out of my server.xml, and SchemaExport now appears to work. Thanks!


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