grails

Grails ignores hibernate.cfg.xml

Actually I deployed my grails application on two tomcat instances. Now I ran into a problem. My Quartz Job needs to be clustered. I read the plugin documentation and found a possibility to cluster the Quartz jobs in combination with the database. Therefore I have to create a hibernate mapping ('grails-app/conf/hibernate/hibernate.cfg.x...

Removing null records from a set in Grails Controller

Hello again, so, Grails is making me feel quite stupid again, I'm new to this. I have A grails domain that maps a table thats in production on a postgresql database. I am trying to track progress on the project by a date field 'migratedDate'. Everytime a process takes place the field is timestamped. I can't seem to make a controller ...

does it make sense to cascade "up" to owners in belongsTo relationship?

I have a Skill class, which hasMany RoleSkills. I have a RoleSkills class which belongsTo Role and Skill I have a Role class which hasMany RoleSkills For Role, I have a mapping that cascades operations to RoleSkills. The question is, does it make sense for RoleSkills to "cascade" back to Skill? I basically want to have a RoleSkill cr...

gorm and cloning objects

I have an object foo, foo has a collection bars and each bar has a collection of baz class foo { static hasMany = [ bars : Bar ] } class bar { static belongsTo = [ foo : Foo ] static hasMany = [ bazs : Baz ] } class baz { static belongsTo = [ bar : Bar ] } I was trying to create and save the foo structure this wa...

return domain objects from grails constraint validation

Is it possible to write your own validator in grails that will return a valid object? Something like: static constraints = { name(validator: {val, obj -> if (Drink.findByName(val)) return [Drink.findByName(val)] }) } In other words - if the Drink already exists in the DB, just return the existing one when someone does...

How to access User object in grails controller

I'm using spring security, and I need to get the User domain object in a controller. If I call SpringSecurityService.getPrincipal(), I get back an object of type org.codehaus.groovy.grails.plugins.springsecurity.GrailsUser. However, what I'm looking for is the User domain object I've defined in my Config.groovy like so: grails.plugins...

Shiro Plugin conflicting with Quartz framework in Grails

Hi All.. I have been working Quartz framework in my grails project with lib called quartz-all-1.7.3. Now I need to install the shiro plugin to my project. So, whenever I am installing shiro plugin to my project its getting installed successfully.. But again whenever I am running my project again it's giving compilation error as follow...

Grails: Add value of two g:select to a HTML multiple select list

I have two g:select comboboxes that I want to add to the multiple select list when clicking an image. Here is the function in javascript: function addToList(list,firstOpt, secOpt) { var y = document.createElement('option'); y.text = firstOpt + ' - ' + secOpt; y.value = firstOpt+'-'+secOpt...

Making .war smaller!

There are several tutorials and even some posts here about shrinking .war files. However, the most common technique (to include grails.war.resources = {} in Config.groovy) does not seem to work for me. No matter what, grails dumps everything into the war file making a 25meg .war. Has this functionality changed? Grails 1.3.4 ...

grails deleted object would be re-saved by cascade error

I have the project as set-up below. I am trying to delete a project, and I get the following: 2010-09-29 11:45:22,902 [http-8080-1] ERROR errors.GrailsExceptionResolver - deleted object would be re-saved by cascade (remove deleted object from associatio ns): [Project#204] org.hibernate.ObjectDeletedException: deleted object would be re...

Can I inject a service into a filter in Grails?

I have a service to get and set the user in the session. I would like to pass in some user information to each view if there is a logged in user and thought a filter would be the best way so I don't have to duplicate that in every controller/action. When I run the app, it get this error: Error creating bean with name 'userService': Scop...

How to log in HibernateCriteriaBuilder

I try log some details in a namedQuery for a grails domain class but logging errors. static namedQueries = { firstThree { if (booleanValue) { log.trace "booleanValue = true" eq ('bar', foo) } maxResults(3) } } Error No such property: log for class: grails.orm.HibernateCriteriaBuilder How do I log in a ...

grails: maintain transactional context from Service to Controller

Hi Have a transaction in a grails Service class on which a rollback flag is set: TransactionAspectSupport .currentTransactionInfo() .transactionStatus .setRollbackOnly() what happens is that when we return to the Controller an exception: org.springframework.transaction.UnexpectedRollbackE...

How do I resolve the grails bootstrap execution error "postProcessBeanDefinitionRegistry already called for this post-processor"?

I'm building a Grails (1.3.4) app configured with the grails plugin tomcat-1.3.4 and using Spring (3.0.3RELEASE) but reusing an existing Spring applicationContext.xml file. I copied the relevant portions of the old file into the one generated by Grails (just below the characterEncodingFilter bean). After making sure that all the requir...

How to debug ContextLoader - Context initialization failed and BeanCreationException

I see a number of posts on the various problems folks have with troubleshooting this problem: ERROR context.ContextLoader - Context initialization failed org.springframework.beans.factory.BeanCreationException: Is there a way to turn on debugging to isolate the problem? Its complaining about "No such property: getOrg for class: groovy...

Grails iterating through database tables

As I'm a bit new to grails, I'm wondering how I can iterate through the current data i have saved in the database to check if the information already exists. For instance, lets say I have a domain class for Books and I create an action that automatically adds more books but I want to check if the book.title already exists so I don't add...

Grails find / findAll operation won't work?

Hello all, I'm trying to build a Grails application which can do LDAP lookups. I've been following a few guides (link text and some others) but to no end I'm afraid. Relevant source code: From config.groovy: ldap { directories { dir1 { url = "ldap://dc01" base = "ou=someou,dc=check,dc=nl" userDn = "cn=A...

Languages and Frameworks for creating High Load Web Service ?

Maybe, i'm duplicating some existing theme (close this one if it's true) but i'm planning to work with high load web services and curios about best practices. I have projects on Java and Grails. I'm doubt if Grails is right solution for high load service but Java (without any Hibernate or similar tools) can be used very well. Anyway, w...

testing securityConfig mapping in grails + acegi

Hi, I'm kinda lost. I'm writing test cases for a project which still uses the Acegi plugin (not the newer Spring Core Security plugin) and as of now, I've managed to do what this site (http://www.zorched.net/2008/09/01/grails-testing-acegi-security/) has suggested regarding the detection of which user is currently logged in. However, i...

Grails: Using SQL Server 2005 with Grails

Hi, We have a requirement where a Grails application is required to connect to an external SQL Server 2005 (i.e. client's database server via a linked server). Our grails application will have its own SQL Server database instance for user authentication (so will mostly have only one domain class) and then it needs to connect to the exte...