4

I am using Eclipse STS 3.1.0 with Hibernate Tools 3.6.0. I am trying to connect to MySQL 5.5 database to generate my DAO classes. I am using MySQL driver mysql-connector-java-5.1.21.jar

While setting up the hibernate console file (of Hibernate tools), I was able to successfully ping my database. So I assume that my driver version is ok.

After setting up hibernate console file, when I try to generate the Hibernate Reverse Engineering file (reveng.xml), I am getting the following error -

An internal error occurred during: "Fetching children of Database".

I can see the following stack trace in the error log of STS -

java.lang.NoSuchMethodError: org.slf4j.spi.LocationAwareLogger.log(Lorg/slf4j/Marker;Ljava/lang/String;ILjava/lang/String;[Ljava/lang/Object;Ljava/lang/Throwable;)V
    at org.apache.commons.logging.impl.SLF4JLocationAwareLog.debug(SLF4JLocationAwareLog.java:133)
    at org.hibernate.cfg.reveng.dialect.JDBCMetaDataDialect.getTables(JDBCMetaDataDialect.java:26)
    at org.hibernate.cfg.reveng.JDBCReader.processTables(JDBCReader.java:476)
    at org.hibernate.cfg.reveng.JDBCReader.readDatabaseSchema(JDBCReader.java:74)
    at org.hibernate.eclipse.console.workbench.LazyDatabaseSchemaWorkbenchAdapter$2.execute(LazyDatabaseSchemaWorkbenchAdapter.java:126)
    at org.hibernate.console.execution.DefaultExecutionContext.execute(DefaultExecutionContext.java:63)
    at org.hibernate.console.ConsoleConfiguration.execute(ConsoleConfiguration.java:107)
    at org.hibernate.eclipse.console.workbench.LazyDatabaseSchemaWorkbenchAdapter.readDatabaseSchema(LazyDatabaseSchemaWorkbenchAdapter.java:115)
    at org.hibernate.eclipse.console.workbench.LazyDatabaseSchemaWorkbenchAdapter.getChildren(LazyDatabaseSchemaWorkbenchAdapter.java:65)
    at org.hibernate.eclipse.console.workbench.BasicWorkbenchAdapter.fetchDeferredChildren(BasicWorkbenchAdapter.java:106)
    at org.eclipse.ui.progress.DeferredTreeContentManager$1.run(DeferredTreeContentManager.java:235)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)

I am using the steps to use Hibernate tools described at this link.

Would appreciate any help or pointers to fix this issue. Thanks.

UPDATE

I moved to STS 3.2.0 and installed JBoss Tools 4.0.0

I created a simple maven quickstart project and followed all the steps mentioned at link

In this setup, I could successfully generate the entity & DAO classes for the database tables. I did not have to restart STS either. It worked fine in the first attempt itself.

This works fine with MySQL 5.5 as well as Oracle 11g.

Ujjwal
  • 603
  • 12
  • 23

1 Answers1

2

I've had this issue twice now. In the last two weeks... I had to move everything over to a knew machine so I ran into it again. The first time I fixed it by literally removing any references to commons-logging anywhere in my pom.xml. I'm not sure if you're using Maven or not but this semi-fixed it for me before.

<exclusions>
     <!-- Exclude Commons Logging in favor of SLF4j -->
     <exclusion>
              <groupId>commons-logging</groupId>
              <artifactId>commons-logging</artifactId>
     </exclusion>
 </exclusions>

I as we speak am creating a new project from scratch and ran into this problem at the same point.

I have found very little inf on this issue which to me seems so odd as you run into it by just creating a new project with hibernate and can duplicate it very easily.

I NEED logging of course so I plan to get this fixed with logging. I will post my answer when I do. If you found a viable solution can you post please? Thanks!

Trygve Laugstøl
  • 7,440
  • 2
  • 36
  • 40
Dguti
  • 81
  • 1
  • 6
  • Have you found a solution yet? I've tried to create a new Java project with nothing but the configuration for code gen. I get the same error as well. But it is working after restarting Eclipse. – Stanley Jul 05 '13 at 02:47
  • 2
    Yes. It is some sort of bug. No one has really pinned it down that I could ever find coherently but the work around is somewhat simple. I actually ended up just commenting out logging for a couple minutes while I let the Hibernate reveng tool do its thing. Per this post forum.hibernate.org/viewtopic.php?p=2441023 I then readded them after and all is well. Try removing the default logging that Eclipse attaches to most projects. Good luck! Would love to hear if you found another solution - or a real solution :P – Dguti Jul 22 '13 at 15:24
  • Thank you Dguti, finally i could resolve this issue. – Mohit Oct 02 '14 at 08:01