1

I'm extremely new to Hibernate. I posted a question before and it turns out the actual tutorial has bugs in it. But I thought I had straightened those things out. Anyway I am this part of the tutorial. When I do everything as it states before and get up to this point where you execute the line of code that says:

mvn exec:java -Dexec.mainClass="org.hibernate.tutorial.EventManager" -Dexec.args="store"

When I run that in cmd prompt inside of the correct folder: in my scenario the root folder is called test. I get the following error:

No suitable driver found for jdbc:hsqldb:mem:testdb

I am using only Maven and Hibernate. I am not using any IDE for this either. If I dont already have a db is one created for me?

Apparently no driver is found for the hsqldb which doesn't make sense to me.

I've included a ss enter image description here enter image description here

Edit: Included the pom.xml http://www.jamesendres.com/pom.xml

Edit 2: Included the entire project http://www.jamesendres.com/test.rar

meepz
  • 363
  • 2
  • 5
  • 15
  • can you add an -X argument to mvn exec and make sure the classpath contains the hsql jar. – gkamal Dec 22 '11 at 05:16
  • The classpath line is not visible. Can you update your question with the pom.xml and / or output of mvn dependency:tree – gkamal Dec 22 '11 at 16:03
  • @gkamal Just added the pom.xml. I'm not too familiar with mvn but I'll look for the output of the dependency:tree – meepz Dec 22 '11 at 16:08
  • Can you try running with -Dexec.classpathScope=runtime. Also verify if the hsqldb jar is fine - the jar will be under user.home/.m2/repository/hsqldb/hsqldb/1.8.0.1 – gkamal Dec 22 '11 at 16:15
  • Yeah hsqldb is in the folder you specified but I still get the error. I edited my post to include the link to my entire project. – meepz Dec 22 '11 at 19:41
  • It works for me - I downloaded the source - made 2 changes. Changed slf4j-simple version from 1.5.8 to 1.6.1 and changed the connection.url to jdbc:hsqldb:hsql:mem. Remember to run mvn compile - before running mvn exec.. it doesn't compile automatically. I think that is the root cause of all your troubles - the changes you were making were not getting picked up because you didn't do compile – gkamal Dec 23 '11 at 06:40

2 Answers2

0

One possibility is the hsqldb is a plugin dependency and not a project dependency. If so, you can either change the dependency appropriately or pass an additional argument -Dexec.includePluginDependencies=true to mvn exec:java.

Raghuram
  • 51,854
  • 11
  • 110
  • 122
  • I tried that and I still get the same error. I asked a friend and they said "you need to specify the driver for hibernate somewhere. probably a hibernate.properties file or a persistence.xml." – meepz Dec 22 '11 at 16:02
0

You have register the driver when you use HSQL. See https://stackoverflow.com/a/2262136/51782 or http://www.willamaze.eu/2009/02/running-hsqldb-in-process-no-suitable-driver-found/.

Community
  • 1
  • 1
Sri Sankaran
  • 8,120
  • 4
  • 38
  • 47
  • Is there any way to have Maven do this? I don't understand why the tutorial would have us do something outside of the scope of the tutorial. I also actually did try to add the try catch to the EventManager.java file but I still had no luck. – meepz Dec 23 '11 at 00:17
  • The suggested code change is to add `Class.forName("org.hsqldb.jdbcDriver");` and not the try-catch block. And no, Maven won't do this for you. As for why the tutorial doesn't do this already -- I don't know. As you mentioned in the post you've had to resolve other bugs in the tutorial. You could try posting to Hibernate's own user forum (https://forum.hibernate.org/) – Sri Sankaran Dec 23 '11 at 11:30