2

I am trying to following Graeme Rocher's example from Github:

https://gist.github.com/graemerocher/c25ec929d9bcd1adcbea

@Grab("org.grails:grails-datastore-gorm-hibernate4:3.0.0.RELEASE")
@Grab("org.grails:grails-spring:2.3.6")
@Grab("com.h2database:h2:1.3.164")
import grails.orm.bootstrap.*
import grails.persistence.*
import org.springframework.jdbc.datasource.DriverManagerDataSource
import org.h2.Driver

init = new HibernateDatastoreSpringInitializer(Person)
def dataSource = new DriverManagerDataSource(Driver.name, "jdbc:h2:prodDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE", 'sa', '')
init.configureForDataSource(dataSource) 

new Person(name: "Fred Flintstone").save(flush: true, failOnError: true)

println "Total people = ${Person.count()}"

@Entity
class Person {
    String name
    static constraints = {
        name blank:false
    }
}

I am getting

java.lang.RuntimeException: Error grabbing Grapes -- [download failed: >com.googlecode.concurrentlinkedhashmap#concurrentlinkedhashmap->lru;1.3.1!concurrentlinkedhashmap-lru.jar, download failed: >javax.transaction#jta;1.1!jta.jar, download failed: org.jboss.logging#jboss->logging;3.1.3.GA!jboss-logging.jar, download failed: org.javassist#javassist;3.18.1->GA!javassist.jar(bundle)]

I presume that this means that some set of dependencies has changed/gone away.

Is there a current working version of this code?

M. Justin
  • 14,487
  • 7
  • 91
  • 130
Bob Brown
  • 930
  • 2
  • 7
  • 14

2 Answers2

2

I had already tried using @GrabResolver() with various URLs (should have said, apologies).

I tried Jeff Beck's answer but to no avail.

I went through a bit of a debugging cycle by setting a few debug flags to see what was going on (-Dgroovy.grape.report.downloads=true -Divy.message.logger.level=4).

Eventually I had to create a custom ~/.groovy/grapeConfig.xml (as per http://groovy.codehaus.org/Grape#Grape-CustomizeIvysettings) and added the mavencentral URL Jeff gave as a further 'ibiblio' entry.

THEN all was fine.

Don't know why @GrabResolver() isn't resolving but this is a workaround.

Bob Brown
  • 930
  • 2
  • 7
  • 14
1

I got the following to work fine:

@GrabResolver(name='mvncentral', root='http://central.maven.org/maven2/')
@Grab("org.grails:grails-datastore-gorm-hibernate4:3.1.1.RELEASE")
@Grab("org.grails:grails-spring:2.4.3")
@Grab("com.h2database:h2:1.3.164")
import grails.orm.bootstrap.*
import grails.persistence.*
import org.springframework.jdbc.datasource.DriverManagerDataSource
import org.h2.Driver


init = new HibernateDatastoreSpringInitializer(Person)
def dataSource = new DriverManagerDataSource(Driver.name, "jdbc:h2:prodDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE", 'sa', '')
init.configureForDataSource(dataSource)


println "Total people = " + Person.count()


@Entity
class Person {
    String name
    static constraints = {
        name blank:false
    }
}

I added a different resolver from the default jcenter that is in the latest version of groovy. Also you may need to clear cached versions of what was tried to download. Here is a blog post about that.

Jeff Beck
  • 3,944
  • 3
  • 28
  • 45