groovygrails

Grails: Is there a debug flag I can check?

I have a few log.debugs() that I don't want to process (since they are heavy) unless the app is currently in debug mode (not production). Is there a way to check if the grails app is currently in debug mode/development mode? ...

log4j with grails: How to get appender file name at run time?

I am working on a grails app where in development mode, I log some calculations to a log file through log4j. I want to provide a service which will read the log file and make its contents available to a developer so they can see what is being logged in the log file. Is there a way I can get the log4j appender file name at run time? ...

Using java code in a grails application causes compilation never ending loop

I have an application that I am working on modifying and I am having a problem and not sure where to look. When I first started trying to compile the problem, some of the groovy files had imports that were not resolving correctly. After some tracking down, I see that the package was not defined the way the groovy files were expecting. S...

How can I change column name convention in Grails?

For now I have field "String firstName" it converted to "first_name" and i want "firstname" as default in Hibernate. Is it posible? ...

How to debug grails runtime exception?

I have a grails project and a java project. The java project was a standalone set of POJO classes, and I just dumped them into src/java under my grails project. In the controller, I added an import statement for this package. Now when I do a grails run-app and try to run the program, I get a grails runtime exception. It is saying NoCla...

groovy static blocks for relationship definition

I have a couple of domain classes defined, Employee and EmployeeDesiredSkill, Employee has static hasMany = [employeeSkill:EmployeeDesiredSkill] and EmployeeDesiredSkill has static belongsTo = [employee:Employee] Yet groovyc is giving me a bunch of errors like the following: [groovyc] Compiling 15 source files to C:\dev\JavaTes...

Is a variable declaration in grails the same as a belongsTo relationship?

Hello all, I am trying to set up a few domain classes. I will explain it in english, and I am wondering how the domain would be set up in grails. Capitalized words are my domains An Employee has an Education. An Employee has many Employer (past and present). An Employee had one or many Project for each Employer. Project have a Role, Cl...

Grails actions getting called twice. Help!

Hello community! I'm writing a grails app and running into a strange problem. When clicking the submit button on a page, the associated action gets called twice in rapid succession. This causes everything to break horribly. Has anyone else seen this issue before? Below is my code: From the GSP page: <g:form method="post" action="show"...

Get Gmail addressbook in my site

Hello, My application is fetching all the contacts of my gmail account. i try this using GoogleAPI. i got success. but when i am trying to access gmail it will redirect to gmail login page. i do not want to gmail login page instead i want my login page. so how to override gmail login page . please help me out. ...

@XmlSeeAlso with more than one parameter

http://download.oracle.com/javase/6/docs/api/javax/xml/bind/annotation/XmlSeeAlso.html According to this, I should be able to make my root element have more than one class reference. However, when I try that, I get this exception: [groovyc] Compiling 72 source files to C:\Users\dcole\.grails\1.3.4\projects\trunk\classes [groovyc] org.c...

org.hibernate.MappingException for domain classes in grails

I have a grails project and everything has been running fine. I started adding JAXB XML annotations to my groovy domain classes and all of a sudden I start getting this stack dump. What do I need to do to fix this, and why is it showing up after I started added the XML annotations? 2010-09-21 09:46:43,006 [main] ERROR context.ContextLoa...

JAXB annotations for groovy attribute classes

have a project set up like the following: import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlSeeAlso; @XmlRootEle...

ERROR errors.GrailsExceptionResolver - Cannot reference implicit element

I am getting the below error when I try to use Xstream to marshal one of my groovy domain classes Employee. Employee hasmany employeDesiredSkills, which belongsTo Skill and Employee Here is the relevant Xstream code employeeInstance = new Employee(); XStream xstream = new XStream(); Xstream.alias("employee", Employee.class); String x...

How to create valid Domain objects at runtime in Grails

I have a few domain classes, and I want to be able to populate a new Domain class and persist it to the database via one of my controllers. Here are my classes class Employee implements Comparable { static hasMany = [education:Education] static mapping = { education cascade:"all,delete-orphan", lazy:false } List<...

Cannot access first() element from an empty list when using Grails SortedSet

I am working on creating some grails domain objects dynamically and then adding them a SortedSet declared in another grails domain object. I have created a Project class, filled in its values, and checked to make sure it is valid. It is valid, so I want to add this Project to an Employee. My code essentially goes like this Employee emp...

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...

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...

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...

how to get an arbitrary file from an HTTP request in grails

I am trying to set up a web service in grails that can accept a file. How do I get the file from the request? I am testing this with something like curl -d somefile.tar http://localhost:8080/MyWebS/fileWS and my method looks like the following: def index = { switch(request.method){ case "POST": render "Ingesting file\n...

Grails - How to - Unit test Service that uses params from controller

Hi, I'm trying to unit test a service method that takes as parameters a date and the params LinkedHashMap from the controller. The setup is as follows: def save = {CustomCommandObject erc -> ... if (erc.conditionProperty != null) { def result = myService.ServiceMethod(someDate, params) ... } .... redirect(co...