rohitjoins February 2016

Gradle - hibernate tool not working

I'm trying to create a task to convert cfg to sql and I'm using hibernate 3.

My ant task for same looks like this -

ant {
    taskdef(name: 'hibernateTool',
    classname: 'org.hibernate.tool.ant.HibernateToolTask',
    classpath: configurations.hibernatetool.asPath
    )
    hibernateTool(destdir: 'resources/b2c/hibernate/schema') {
    annotationconfiguration(configurationfile:      'resources/b2c/hibernate/hibernate.b2c.cfg.xml')
    hbm2ddl(export: true, outputfilename: 'db-b2c-update-ddl.sql')
    classpath {
        pathelement(path: 'classes')
        fileset(dir: '../intl_lib') {
        include(name: '*/.jar')
    }
    }
}
}

I have added the following dependencies for the same -

dependencies {
    hibernatetool group: 'org.hibernate', name: 'hibernate-tools', version: '3.2.4.GA'
    hibernatetool group: 'org.hibernate', name: 'hibernate-entitymanager', version: '3.6.10.Final'
}

Applied plugin -

plugin: id "org.hibernate.gradle.tools" version "1.2.3"

Set configuration as -

configurations {
    hibernatetool
}

I'm getting the following error while running the task -

[ant:hibernateTool] SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
[ant:hibernateTool] SLF4J: Defaulting to no-operation (NOP) logger implementation
[ant:hibernateTool] SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.

Here is the stack trace for the same -

Caused by: java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory
at org.apache.tools.ant.AntClassLoader.findClassInComponents(AntClassLoader.java:1366)
at org.apache.tools.ant.AntClassLoader.findClass(AntClassLoader.java:1315)
at org.apache.tools.ant.AntClassLoader.loadClass(AntClassLoader.java:1068)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 165 more

Answers


Nathan February 2016

I am wondering if you have not pointed to the correct repository. If you check the Gradle Plugin Portal page for Hibernate the following build information is provided. I am not sure which Gradle version you are using so I will provide the "all" version build.

In gradle.build:

buildscript {
  repositories {
    maven {
      url "https://plugins.gradle.org/m2/"
    }
  }
  dependencies {
    classpath "gradle.plugin.org.hibernate.gradle.tools:hibernatetools-gradle-plugin:1.2.3"
  }
}

apply plugin: "org.hibernate.gradle.tools"

This build will explicitly define not only the plugin but the repository to download the plugin from. Please try this method of applying the Hibernate plugin and see if your issue is resolved.

Post Status

Asked in February 2016
Viewed 3,223 times
Voted 6
Answered 1 times

Search




Leave an answer