Initializing data in a gorm data model - grails

I have the following domain layer:
Product:
#Resource(uri='/product')
class BasicProduct {
String title
String description
Double price
Date dateCreated
Date lastUpdated
static hasMany = [tag : Tag]
static constraints = {
title(blank: false, unique: true)
description(blank: false)
price(blank: false)//, inList: [5.0,15.0,25.0,50.0,100.0])
}
static mapping = {
autoTimestamp true
}
}
Tags:
#Resource(uri='/tag')
class Tag {
String title
static belongsTo = [basicProduct: BasicProduct]
Date dateCreated
Date lastUpdated
static constraints = {
title(blank: false, unique: true)
}
static mapping = {
autoTimestamp true
}
}
In my Bootstrap.groovy I have the following :
class BootStrap {
def init = { servletContext ->
new BasicProduct(title: "Product1", description:"blblblblbalablablalbalbablablablablblabalalbllba", price:5.0).save(failOnError: true)
new BasicProduct(title: "Product2", description:"blblblblbalablablalbalbablablablablblabalalbllba", price:75.0).save(failOnError: true)
new BasicProduct(title: "Product3", description:"blblblblbalablablalbalbablablablablblabalalbllba", price:50.0).save(failOnError: true)
new Tag(basic_product_id: 1 ,title: "analysis").save(failOnError: true)
println "initializing data..."
}
However I get an exception:
|Running Grails application
context.GrailsContextLoader Error initializing the application: Validation Error(s) occurred during save():
- Field error in object 'com.testapp.Product.Tag' on field 'basicProduct': rejected value [null]; codes [com.testapp.Product.Tag.basicProduct.nullable.error.com.testapp.Product.Tag.basicProduct,com.testapp.Product.Tag.basicProduct.nullable.error.basicProduct,com.testapp.Product.Tag.basicProduct.nullable.error.com.testapp.Product.BasicProduct,com.testapp.Product.Tag.basicProduct.nullable.error,tag.basicProduct.nullable.error.com.testapp.Product.Tag.basicProduct,tag.basicProduct.nullable.error.basicProduct,tag.basicProduct.nullable.error.com.testapp.Product.BasicProduct,tag.basicProduct.nullable.error,com.testapp.Product.Tag.basicProduct.nullable.com.testapp.Product.Tag.basicProduct,com.testapp.Product.Tag.basicProduct.nullable.basicProduct,com.testapp.Product.Tag.basicProduct.nullable.com.testapp.Product.BasicProduct,com.testapp.Product.Tag.basicProduct.nullable,tag.basicProduct.nullable.com.testapp.Product.Tag.basicProduct,tag.basicProduct.nullable.basicProduct,tag.basicProduct.nullable.com.testapp.Product.BasicProduct,tag.basicProduct.nullable,nullable.com.testapp.Product.Tag.basicProduct,nullable.basicProduct,nullable.com.testapp.Product.BasicProduct,nullable]; arguments [basicProduct,class com.testapp.Product.Tag]; default message [Die Eigenschaft [{0}] des Typs [{1}] darf nicht null sein]
grails.validation.ValidationException: Validation Error(s) occurred during save():
- Field error in object 'com.testapp.Product.Tag' on field 'basicProduct': rejected value [null]; codes [com.testapp.Product.Tag.basicProduct.nullable.error.com.testapp.Product.Tag.basicProduct,com.testapp.Product.Tag.basicProduct.nullable.error.basicProduct,com.testapp.Product.Tag.basicProduct.nullable.error.com.testapp.Product.BasicProduct,com.testapp.Product.Tag.basicProduct.nullable.error,tag.basicProduct.nullable.error.com.testapp.Product.Tag.basicProduct,tag.basicProduct.nullable.error.basicProduct,tag.basicProduct.nullable.error.com.testapp.Product.BasicProduct,tag.basicProduct.nullable.error,com.testapp.Product.Tag.basicProduct.nullable.com.testapp.Product.Tag.basicProduct,com.testapp.Product.Tag.basicProduct.nullable.basicProduct,com.testapp.Product.Tag.basicProduct.nullable.com.testapp.Product.BasicProduct,com.testapp.Product.Tag.basicProduct.nullable,tag.basicProduct.nullable.com.testapp.Product.Tag.basicProduct,tag.basicProduct.nullable.basicProduct,tag.basicProduct.nullable.com.testapp.Product.BasicProduct,tag.basicProduct.nullable,nullable.com.testapp.Product.Tag.basicProduct,nullable.basicProduct,nullable.com.testapp.Product.BasicProduct,nullable]; arguments [basicProduct,class com.testapp.Product.Tag]; default message [Die Eigenschaft [{0}] des Typs [{1}] darf nicht null sein]
at BootStrap$_closure1.doCall(BootStrap.groovy:20)
at grails.util.Environment.evaluateEnvironmentSpecificBlock(Environment.java:308)
at grails.util.Environment.executeForEnvironment(Environment.java:301)
at grails.util.Environment.executeForCurrentEnvironment(Environment.java:277)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)
Error |
Forked Grails VM exited with error
Any recommendation how to add a Tag for every product into my table?
I appreciate your answer!

Instead of using
new Tag(basic_product_id: 1...
Try doing something along the lines of
BasicProduct basicProduct1 = new BasicProduct(title: "Product1", ...
...
new Tag(basicProduct: basicProduct1...

Related

InvalidDataAccessResourceUsageException when testing a service

I am using Grails 3.1.9 and I'm trying to understand how to test services. Here is my entity:
class Flight {
String number
Plane plane
Airport origin
Airport destination
LocalDate departureDate
LocalTime departureTime
LocalDate arrivalDate
LocalTime arrivalTime
BigDecimal ticketPrice
boolean cancelled
static hasMany = [
bookings: Booking
]
static constraints = {
}
}
And here is my service:
#Transactional
class FlightService {
List<Flight> search(Airport from, Airport to, LocalDate on) {
return Flight.findAllByOriginAndDestinationAndDepartureDate(from, to, on)
}
}
And here is my test:
#TestFor(FlightService)
#Mock([Flight])
class FlightServiceSpec extends Specification {
def setup() {
}
def cleanup() {
}
void "test search"() {
when:
def sfo = new Airport(code: 'SFO', city: 'San Francisco', countryCode: 'US', timeZone: ZoneId.of("America/Los_Angeles"))
def bru = new Airport(code: 'BRU', city: 'Brussels', countryCode: 'BE', timeZone: ZoneId.of("Europe/Brussels"))
service.search(bru, sfo, LocalDate.of(2016, 8, 31))
then:
1 * Flight.findAllByOriginAndDestinationAndDepartureDate(*_)
}
}
But when I run grails test-app, I get the following exception in the report:
org.springframework.dao.InvalidDataAccessResourceUsageException: Cannot query [com.epseelon.atr.Flight] on non-existent property: departureDate
at org.grails.datastore.mapping.simple.query.SimpleMapQuery.getValidProperty(SimpleMapQuery.groovy:751)
at org.grails.datastore.mapping.simple.query.SimpleMapQuery.executeSubQueryInternal(SimpleMapQuery.groovy:690)
at org.grails.datastore.mapping.simple.query.SimpleMapQuery.executeSubQuery(SimpleMapQuery.groovy:676)
at org.grails.datastore.mapping.simple.query.SimpleMapQuery.executeQuery(SimpleMapQuery.groovy:63)
at org.grails.datastore.mapping.query.Query.list(Query.java:567)
at org.grails.datastore.gorm.finders.FindAllByFinder.invokeQuery(FindAllByFinder.java:49)
at org.grails.datastore.gorm.finders.FindAllByFinder$1.doInSession(FindAllByFinder.java:43)
at org.grails.datastore.mapping.core.DatastoreUtils.execute(DatastoreUtils.java:310)
at org.grails.datastore.gorm.finders.AbstractFinder.execute(AbstractFinder.java:41)
at org.grails.datastore.gorm.finders.FindAllByFinder.doInvokeInternal(FindAllByFinder.java:40)
at org.grails.datastore.gorm.finders.DynamicFinder.invoke(DynamicFinder.java:157)
at org.grails.datastore.gorm.finders.DynamicFinder.invoke(DynamicFinder.java:357)
at org.grails.datastore.gorm.GormStaticApi.methodMissing(GormStaticApi.groovy:141)
at org.grails.datastore.gorm.GormEntity$Trait$Helper.staticMethodMissing(GormEntity.groovy:745)
at com.epseelon.atr.FlightService.$tt__search(FlightService.groovy:11)
at com.epseelon.atr.FlightService.search_closure1(FlightService.groovy)
at groovy.lang.Closure.call(Closure.java:414)
at groovy.lang.Closure.call(Closure.java:430)
at grails.transaction.GrailsTransactionTemplate$2.doInTransaction(GrailsTransactionTemplate.groovy:96)
at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:133)
at grails.transaction.GrailsTransactionTemplate.execute(GrailsTransactionTemplate.groovy:93)
at com.epseelon.atr.FlightServiceSpec.test search(FlightServiceSpec.groovy:27)
Which I don't understand since there IS a departureDate property on the Flight entity.
Add this to your specifications to enable the joda time unit test support
def setupSpec() {
SimpleMapJodaTimeMarshaller.initialize();
}
See https://github.com/gpc/joda-time/issues/14

Grails - save the transient instance before flushing

I'm writing an application on Grails. I'm trying to add child database record to parent table using addTo-method. I follow this documentation about addTo-method. And for example, documentation says create parent-class:
class Author { String name
static hasMany = [fiction: Book, nonFiction: Book]
}
Follow this I created my parent-class:
class Cafee {
String cafeeName = ""
int totalReservationPlaces = 0
double placeCost = 0
String currencyType = ""
boolean isReservationAvailable = false
boolean reservationTimeLimit = false
boolean reservationDateLimit = false
int totalPlaces = 0
long startTimeLimit = 0
long endTimeLimit = 0
Date startDateLimit = new Date()
Date endDateLimit = new Date()
static constraints = {
cafeeName blank: false, unique: true
}
String getCafeeName(){
return cafeeName
}
static hasMany = [admin: Person]
}
Documentation says create child-class:
class Book { String title
static belongsTo = [author: Author]
}
Follow this I've created my child-class:
class Person {
transient springSecurityService
String username
String password
boolean enabled = true
boolean accountExpired
boolean accountLocked
boolean passwordExpired
String firstName
String lastName
String email
String inn = ""
boolean isAdminCafee = false
static transients = ['springSecurityService']
static belongsTo = [cafee:Cafee]
static constraints = {
username blank: false, unique: true
firstName blank: false
lastName blank: false
password blank: false
email blank: false, unique: true
}
static mapping = {
password column: '`password`'
}
Set<Authority> getAuthorities() {
PersonAuthority.findAllByPerson(this).collect { it.authority }
}
def beforeInsert() {
encodePassword()
}
def beforeUpdate() {
if (isDirty('password')) {
encodePassword()
}
}
protected void encodePassword() {
password = springSecurityService?.passwordEncoder ? springSecurityService.encodePassword(password) : password
}
}
And documentation says to add child record to parent I must do something this:
def fictBook = new Book(title: "IT")
def nonFictBook = new Book(title: "On Writing: A Memoir of the Craft")
def a = new Author(name: "Stephen King")
.addToFiction(fictBook)
.addToNonFiction(nonFictBook)
.save()
Follow it in Bootstrap I've done this:
def user = Person.findOrSaveWhere(username: 'testerAndrewRes', password:'password', firstName:'Andrew', lastName:'Bobkov', email:'pragm#gmail.com', isAdminCafee: true,
inn: '1234567890')
println user
if(!user.authorities.contains(adminRole))
{
PersonAuthority.create(user, adminRole, true)
}
def newCafe = new Cafee(cafeeName: "Tarelka").addToAdmin(user).save()
But I get an error:
ERROR context.GrailsContextLoaderListener - Error initializing the application: object references an unsaved transient instance - save the transient instance before flushing: restorator.auth.Person; nested exception is org.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing: restorator.auth.Person
Message: object references an unsaved transient instance - save the transient instance before flushing: restorator.auth.Person; nested exception is org.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing: restorator.auth.Person
What I do wrong?
The error message is clear I think.
Try adding:
user.save(flush:true)
before:
def newCafe = new Cafee(cafeeName: "Tarelka").addToAdmin(user).save()

Adding init data via Bootstrap.groovy to application

My domain layer looks like that:
#Resource(uri='/product')
class BasicProduct {
String title
String description
Double price
Date creationDate
Date changedDate
static constraints = {
//everything is by default NotNull
title(blank: false, unique: true)
description(blank: false)
price(blank: false, inList: [5,15,25,50,100])
creationDate(min: new Date())
}
}
My Bootstrap.groovy contains that code:
class BootStrap {
def init = { servletContext ->
new BasicProduct(title: "Product1", description:"blblblblbalablablalbalbablablablablblabalalbllba", price:5).save()
new BasicProduct(title: "Product2", description:"blblblblbalablablalbalbablablablablblabalalbllba", price:75).save()
new BasicProduct(title: "Product3", description:"blblblblbalablablalbalbablablablablblabalalbllba", price:50).save()
new BasicProduct(title: "Product4", description:"blblblblbalablablalbalbablablablablblabalalbllba", price:25).save()
new BasicProduct(title: "Product5", description:"blblblblbalablablalbalbablablablablblabalalbllba", price:15).save()
println "initializing data..."
}
However when I open the \product url I do not see any data.
Any ideas why?
I appreciate your answer!
For your dates you can do:
Date dateCreated
Date lastUpdated
static mapping = {
autoTimestamp true
}

Grails one to many with composite key

(Grails 2.2.4)
When I execute this:
def AuditLog auditLog=new AuditLog(appUserId: 1488902, auditDate: new Date(), action: "Update Questionnaire", username: "USER1" )
auditLog.addToAuditTargets(new AuditTarget(targetId: 100, type: "what's the type"))
auditLog.save(failOnError:true)
I get this error:
| Error 2014-01-04 00:39:38,904 [localhost-startStop-1] ERROR context.GrailsContextLoader - Error initializing the application: Validation Error(s) occurred during save():
- Field error in object 'com.company.kyn.model.AuditLog' on field 'auditTargets[0].auditId': rejected value [null]; codes [com.company.kyn.model.AuditTarget.auditId.nullable.error.com.company.kyn.model.AuditLog.auditTargets[0].auditId...]; arguments [auditId,class com.company.kyn.model.AuditTarget]; default message [Property [{0}] of class [{1}] cannot be null]
The generated auditId is not set on AuditTarget. How do I fix this?
Thank you.
package com.company.kyn.model
class AuditLog {
Date auditDate
String action
String username
Long appUserId
static hasMany = [auditTargets: AuditTarget]
static mapping = {
id column: "AUDIT_ID", generator: "hilo"
auditTargets joinTable:false
version false
}
static constraints = {
action maxSize: 100
username maxSize: 100
}
}
package com.company.kyn.model
import org.apache.commons.lang.builder.EqualsBuilder
import org.apache.commons.lang.builder.HashCodeBuilder
class AuditTarget implements Serializable {
Long auditId
String type
Long targetId
static belongsTo = [auditLog:AuditLog]
static mapping = {
id composite: ["auditId", "type", "targetId"]
auditLog column: "AUDIT_ID"
version false
}
static constraints = {
type maxSize: 100
}
int hashCode() {
def builder = new HashCodeBuilder()
builder.append auditId
builder.append type
builder.append targetId
builder.toHashCode()
}
boolean equals(other) {
if (other == null) return false
def builder = new EqualsBuilder()
builder.append auditId, other.auditId
builder.append type, other.type
builder.append targetId, other.targetId
builder.isEquals()
}
}
Update: (Solution)
First of all you need to remove
Long auditId
from AuditTarget, because apparently you are maintaining two mappings.
Then rewrite you AuditTarge domain as:
class AuditTarget implements Serializable{
String type
Long targetId
static belongsTo = [auditLog:AuditLog]
static mapping = {
id composite: ["auditLog","type", "targetId"]
auditLog column: "AUDIT_ID"
version false
}
static constraints = {
type maxSize: 100
}
int hashCode() {
def builder = new HashCodeBuilder()
builder.append auditLog
builder.append type
builder.append targetId
builder.toHashCode()
}
boolean equals(other) {
if (other == null) return false
def builder = new EqualsBuilder()
builder.append auditLog, other.auditLog
builder.append type, other.type
builder.append targetId, other.targetId
builder.isEquals()
}
}
This will solve your issue

Grails : Error initializing spring security on server restart

I have a very strange behaviour on a production server.
When I start for the first time my server, there is no problem, but when I want to stop and restart it, I get the following error :
Configuring Spring Security Core ...
... finished configuring Spring Security Core
2013-10-31 12:03:08,156 [localhost-startStop-1] ERROR context.GrailsContextLoader - Error initializing the application: null
java.lang.NullPointerException
at com.aftmevent.security.UserRole.create(UserRole.groovy:32)
at BootStrap$_closure1.doCall(BootStrap.groovy:16)
at grails.util.Environment.evaluateEnvironmentSpecificBlock(Environment.java:308)
at grails.util.Environment.executeForEnvironment(Environment.java:301)
at grails.util.Environment.executeForCurrentEnvironment(Environment.java:277)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:724)
2013-10-31 12:03:08,156 [localhost-startStop-1] ERROR context.GrailsContextLoader - Error initializing Grails: null
java.lang.NullPointerException
at com.aftmevent.security.UserRole.create(UserRole.groovy:32)
at BootStrap$_closure1.doCall(BootStrap.groovy:16)
at grails.util.Environment.evaluateEnvironmentSpecificBlock(Environment.java:308)
at grails.util.Environment.executeForEnvironment(Environment.java:301)
at grails.util.Environment.executeForCurrentEnvironment(Environment.java:277)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:724)
oct. 31, 2013 12:03:08 PM org.apache.catalina.core.StandardContext startInternal
Here is my BootStrap.groovy :
class BootStrap {
def springSecurityService
def init = { servletContext ->
def existingAdminRole = Role.findByAuthority('ROLE_ADMIN')
def existingUserRole = null
def existingAdminUser = null
if (existingAdminRole) {
existingUserRole = UserRole.findByRole(existingAdminRole)
}
if (existingUserRole) {
existingAdminUser = existingUserRole.user
}
if (!existingAdminUser) {
def adminRole = new Role(authority: 'ROLE_ADMIN')
def adminUser = new User(username: 'admin', password: 'admin', enabled: true)
if (adminRole.validate()) {
adminRole.save(flush: true, failOnError: true)
}
if (adminUser.validate()) {
adminUser.save(flush: true, failOnError: true)
}
UserRole userRole = UserRole.create(adminUser, adminRole, true)
if (userRole.validate()) {
userRole.save(flush: true, failOnError: true)
}
}
}
def destroy = {
}
}
Here is my User.groovy (adding the nullable constraint did not solve the problem) :
User.groovy :
class User {
transient springSecurityService
String username
String password
boolean enabled
boolean accountExpired
boolean accountLocked
boolean passwordExpired
static constraints = {
username nullable: true, blank: false, unique: true
password nullable: true, blank: false
}
static mapping = {
password column: '`password`'
}
Set<Role> getAuthorities() {
UserRole.findAllByUser(this).collect { it.role } as Set
}
def beforeInsert() {
encodePassword()
}
def beforeUpdate() {
if (isDirty('password')) {
encodePassword()
}
}
protected void encodePassword() {
password = springSecurityService.encodePassword(password)
}
}
Here are my classe Role.groovy and UserRole.groovy :
Role.groovy :
class Role {
String authority
static mapping = {
cache true
}
static constraints = {
authority nullable: true, blank: false, unique: true
}
}
UserRole.groovy :
class UserRole implements Serializable {
User user
Role role
boolean equals(other) {
if (!(other instanceof UserRole)) {
return false
}
other.user?.id == user?.id &&
other.role?.id == role?.id
}
int hashCode() {
def builder = new HashCodeBuilder()
if (user) builder.append(user.id)
if (role) builder.append(role.id)
builder.toHashCode()
}
static UserRole get(long userId, long roleId) {
find 'from UserRole where user.id=:userId and role.id=:roleId',
[userId: userId, roleId: roleId]
}
static UserRole create(User user, Role role, boolean flush = false) {
new UserRole(user: user, role: role).save(flush: flush, insert: true)
}
static boolean remove(User user, Role role, boolean flush = false) {
UserRole instance = UserRole.findByUserAndRole(user, role)
if (!instance) {
return false
}
instance.delete(flush: flush)
true
}
static void removeAll(User user) {
executeUpdate 'DELETE FROM UserRole WHERE user=:user', [user: user]
}
static void removeAll(Role role) {
executeUpdate 'DELETE FROM UserRole WHERE role=:role', [role: role]
}
static mapping = {
id composite: ['role', 'user']
version false
}
}
Here is my DataSource.groovy file with the database settings :
environments {
development {
dataSource {
dbCreate = "create-drop" // one of 'create', 'create-drop', 'update', 'validate', ''
driverClassName = 'com.mysql.jdbc.Driver'
username = 'root'
password = 'root'
url = 'jdbc:mysql://localhost:3306/database?autoreconnect=true&useUnicode=true&characterEncoding=utf-8'
}
}
test {
dataSource {
dbCreate = "update"
url = "jdbc:h2:mem:testDb;MVCC=TRUE;LOCK_TIMEOUT=10000"
}
}
production {
dataSource {
dbCreate = 'create-drop'
driverClassName = 'com.mysql.jdbc.Driver'
username = 'root'
password = 'root'
url = 'jdbc:mysql://localhost:3306/database?autoreconnect=true&useUnicode=true&characterEncoding=utf-8'
}
}
}
I really don't have any idea about what occured.
I have added the nullable constrainst, trying to put the databe into 'create-drop' / 'update'.
Funny thing : When I drop the databse then create it again, the first server start is good, but crash after a restart.
I try to put println logs into my BootStrap.groovy, I can see them into development environment, but not into production server.
So I'm not sure if my BootStrap is updated creating war.
I create the war using :
grails prod war target/my-new-war-0.0.x.war
Thanks for reading,
Snite
I'm not really sure what's wrong with your code, however your giant block of code was making my head hurt so I had to post this.
Role role = Role.findByAuthority("ROLE_ADMIN") ?: new Role(authority: "ROLE_ADMIN").save(flush: true, failOnError: true)
if (UserRole.countByRole(role) == 0) {
User user = new User(username: 'admin', password: 'admin', enabled: true).save(flush: true, failOnError: true)
UserRole.create(user, role, true)
}
hmmm well its a null point exception:
ERROR context.GrailsContextLoader - Error initializing the application: null
java.lang.NullPointerException
at com.aftmevent.security.UserRole.create(UserRole.groovy:32)
at BootStrap$_closure1.doCall(BootStrap.groovy:16)
Unsure if the pasted content matches up exactly to your own line numbers, something you could try for now is by going around and adding the question mark :
def existingAdminRole = Role.findByAuthority('ROLE_ADMIN')
def existingUserRole = null
def existingAdminUser = null
if (existingAdminRole) {
existingUserRole = UserRole.findByRole(existingAdminRole)
}
if (existingUserRole) {
existingAdminUser = existingUserRole.user
}
change to:
def existingAdminRole = Role?.findByAuthority('ROLE_ADMIN')
def existingUserRole = null
def existingAdminUser = null
if (existingAdminRole) {
existingUserRole = UserRole?.findByRole(existingAdminRole)
}
if (existingUserRole) {
existingAdminUser = existingUserRole?.user
}
Also you could try findorsavewhere rather than an attempt to generate a new record:
https://github.com/vahidhedayati/ajaxdependancyselectexample/blob/master/grails-app/conf/BootStrap.groovy
def n1=MyContinent.findOrSaveWhere(continentName: 'Asia')
def n2=MyContinent.findOrSaveWhere(continentName: 'Europe')
// Create countries and provde continent map value as above defs
def c1 = MyCountry.findOrSaveWhere(mycontinent: n2, countryName:'United Kingdom',ccode:'GB',language:'')
def c2 = MyCountry.findOrSaveWhere(mycontinent: n2, countryName:'France',ccode:'FR',language:'')
def c3 = MyCountry.findOrSaveWhere(mycontinent: n1, countryName:'China',ccode:'CN',language:'')
def c4 = MyCountry.findOrSaveWhere(mycontinent: n1, countryName:'India',ccode:'IN',language:'')
you will need to figure out what is going on in line 32 of UserRole which will be the start of your issue followed by BootStrap on line 16..
Thanks for all of your answer which help me to solve my issue.
It was stupid but in my rundeck script to deploy the war on the production server, it was an out of date version of the war which was used -_-
So doint it manually with the correct war version solve my problem.
Thanks because your advices help me to read adequat documentation on grails's framework and help me thinking looking here.
Cheers,
Snite

Resources