Here's how to setup scheduled (periodic or timed) tasks with Spring3
in Grails using the concurrency executors introduced in Java5.
This replaces the use of a Spring2 TimerTask
which was deprecated in
Spring3 and removed from Spring4. Grails2 uses Spring3 so
the TimerTask
should still work, but this method should work
in Grails2 and Grails3. Note that in Grails3 and
possibly 2.4/2.5,
you might be able to use the much simpler Spring
@Scheduled
annotation on a service method.
Grails 2.3.11 (or any 2.3.x) does not work with Java8 (jdk1.8.0_40
or
later). Following are some notes on how to get things working.
It's really surprising and annoying that the default structured editor for
dates and times in Grails is so limited. It only allows one to edit (or enter)
time information down to the minute. Seconds and smaller are ignored, even
though the editor specifically returns an epoch time in milliseconds with the
getTime()
method! The default editor also only works for java.util.Date
and java.sql.Date
-- not the also common java.sql.Timestamp
.
We've been banging our heads over some quirks and inconsistencies that we eventually traced to plugin dependency naming in Grails 2.3.x. My main Grails app gets its domain classes from a local plugin. That plugin needs the Hibernate and JodaTime plugins. Spelling the plugin names can be confusing and caused problems with run-app and run-script.
(read more)Here's an info dump of some things I did to get Linux aspell-based spell checking working with the Grails CKEditor plugin.
(read more)Here's how to get CGI working in a Grails app.
(read more)I was reminded again today that standalone classes in Grails must belong to a
package. That is, a class in src/groovy
or src/java
needs to be in a
package. For example:
I have nullable one-to-many relations in Grails/GORM and started getting
"object references an unsaved transient instance" exceptions from Hibernate.
In the Grails forms, selecting a blank/no-selection value for the field sent
params.myOtherObject.id==''
. GORM then tries to create a new empty object
and during the save(flush:true)
, it complains with the exception:
I was trying to use the Groovy XML MarkupBuilder to have Grails output an HTML fragment for an AJAX call and just couldn't get it to work. I wanted to generate an HTML select/option menu from a list of lists:
(read more)Here are the permissions I've used for Grails apps deployed to Tomcat running the Java security manager.
(read more)