Just another site

Tag Archives: autogenerate code

Hibernate Tools refuses to auto generate code in Eclipse

After debugging the plugin and observing the logs it seems there is some classloader issue for the tools plugin due to which the logger libs are creating an issue with code generation.

You would get the follwoing stacktrace in the eclipse logs

!MESSAGE An internal error occurred during: "Fetching children of Database".
java.lang.NoSuchMethodError: org.slf4j.spi.LocationAwareLogger.log(Lorg/slf4j/Marker;Ljava/lang/String;ILjava/lang/String;[Ljava/lang/Object;Ljava/lang/Throwable;)
	at org.apache.commons.logging.impl.SLF4JLocationAwareLog.debug(
	at org.hibernate.cfg.reveng.JDBCReader.processTables(
	at org.hibernate.cfg.reveng.JDBCReader.readDatabaseSchema(

To workaround this issue there are 2 ways.

For maven based projects comment out the logger libs reference or if its a well organised maven project remove reference to the parent

Trigger the generation it would generate the code.

If its a normal java project remove the references tot the loggers temporarily and triger generation.