-->
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.  [ 4 posts ] 
Author Message
 Post subject: Trouble running tutorial
PostPosted: Sun Dec 07, 2003 8:43 pm 
Newbie

Joined: Sun Dec 07, 2003 8:33 pm
Posts: 5
Hi,

I'm just starting with Hibernate. I'm trying to run the tutorial at
http://www.hibernate.org/hib_docs/onlin ... tion/html/

This is on RH Linux, java 1.4.0.

I'm trying to generate the mapping code from the supplied database, using
ant bottomup.middlegen

I get this error message:
BUILD FAILED
/home/mike/hibernate/build.xml:130: middlegen.MiddlegenException: Couldn't connect to database: The database is already in use by another process: org.hsqldb.NIOLockFile@b07e2b6[file =/home/mike/hibernate/database/toolset.db.lck, exists=true, locked=false, valid=false, fl =null]: java.io.IOException: Invalid argument

okay, so there's a lock file on the db. I delete it and try again, and the same message appears. Somewhere in the ant build script that lock file is getting created and prevents it from going further.

So instead I edit the build.xml file, change the db.url and jdbc class to use my mySql database, and I try again. This time I get the error:

[middlegen] No <table> elements specified. Reading all tables. This might take a while...
[middlegen] (middlegen.MiddlegenPopulator 261 ) WARNING: Middlegen couldn't find any relations between any tables. This may be intentional from the design of the database, but it may also be because you have incorrectly defined the relationships. It could also be because the JDBC driver you're using doesn't correctly implement DatabaseMetaData. See the samples (for an example on how to define relationships) and verify that your driver correctly implements DatabaseMetaData.

Now, I'm pretty sure that the mysql driver supports metadata. I haven't defined any foreign key relationships in my db. Is that the problem? Why can't hibernate then just build mappings for the isolated tables?

thanks
Michael


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 08, 2003 3:28 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
HSQLDB as used in the demo is embedded so only one process can access it at once. Maybe you started the database GUI ant target and have not closed it. Make sure you are the only process accessing the DB. Alternatively, you could start HSQDB in standalone mode which allows multiple client conncurrent access. You will have to work out how - it is in the HSQLDB docs.

MySQL should work fine but maybe the schema name is in upper case and your made the request in lower case. This was the case recently for a user. I can only suggest you write a small JDBC routine which will exercise the driver to collect some meta data.

Middlegen can build mappings for isolated tables. Just need to get the DB/JDBC driver sorted.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 09, 2003 9:22 pm 
Newbie

Joined: Sun Dec 07, 2003 8:33 pm
Posts: 5
Hi David,

Thanks for the hints.

As far as hsqldb goes, I have ensured that no other process is trying to access the database. I've determined that the failure happens within this ant task:

<middlegen
appname="Toolset"
prefsdir="${basedir}"
gui="true"
databaseurl="${db.url}"
driver="org.jsqldb.jdbcDriver"
username="SA">

And so my next strategy is to get the source for middlegen and figure out what it's doing.

As far as trying this with mysql, I did try changing the schema name. After that, I got a different error message - it couldn't connect to the database. So now at least I know that with the right schema name it's at least connecting.

I looked more closely at the stack trace, and determined that maybe that warning about no relationships defined is just a red herring. Here is the stack trace:

middlegen] java.util.ConcurrentModificationException
[middlegen] at java.util.HashMap$HashIterator.nextEntry(HashMap.java:750)
[middlegen] at java.util.HashMap$KeyIterator.next(HashMap.java:786)
[middlegen] at com.mysql.jdbc.Connection.closeAllOpenStatements(Connection.java:2538)
[middlegen] at com.mysql.jdbc.Connection.close(Connection.java:1067)
[middlegen] at middlegen.MiddlegenPopulator.populate(MiddlegenPopulator.java:272)
[middlegen] at middlegen.MiddlegenTask.execute(MiddlegenTask.java:403)
[middlegen] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:306)
[middlegen] at org.apache.tools.ant.Task.perform(Task.java:401)
[middlegen] at org.apache.tools.ant.Target.execute(Target.java:338)
[middlegen] at org.apache.tools.ant.Target.performTasks(Target.java:365)
[middlegen] at org.apache.tools.ant.Project.executeTarget(Project.java:1237)
[middlegen] at org.apache.tools.ant.Project.executeTargets(Project.java:1094)
[middlegen] at org.apache.tools.ant.Main.runBuild(Main.java:669)
[middlegen] at org.apache.tools.ant.Main.startAnt(Main.java:220)
[middlegen] at org.apache.tools.ant.launch.Launcher.run(Launcher.java:215)
[middlegen] at org.apache.tools.ant.launch.Launcher.main(Launcher.java:90)

So it looks like maybe there's a bug in the mysql driver, in the close() method. Anyway, once I get the Middlegen source, I can try to catch that exception in MiddlegenPopulator.populate, so that maybe it can finish the job.

Seems a bit intense to get a tutorial running, but I'm sure I'll learn more about your framework!
Thanks
Michael


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 09, 2003 11:11 pm 
Newbie

Joined: Sun Dec 07, 2003 8:33 pm
Posts: 5
Ahh, found the problem.

I was using a new alpha version of the mysql jdbc connector. When I switched to the stable release, it worked!

Thanks again
Michael


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