Wednesday, August 27, 2008

Acegi and Groovy Class Packages

With all of the tutorials and examples for Grails there is often no reference to packaging your Groovy classes.

So, I decided to convert all of my project into packages including Acegi.

Using IntelliJ 7.04 & JetGroovy plugin v1.6.18593, I was able to refactor most of my classes without issue. Service classes required me to add the imports manually... no problem there. Of course its odd that I had to manually add imports to java.util.*

Acegi classes required to add the package to the class declaration within grails-app/conf/SecurityConfig.groovy

loginUserDomainClass = "com.mycorp.projname.security.User"
authorityDomainClass = "com.mycorp.projname.security.Role"
requestMapClass = "com.mycorp.projname.security.Requestmap"

(thanks to Burt Beckwith)

Friday, August 22, 2008

Grails on WebLogic - Validation Errors

If you are deploying Grails on WebLogic 9/10 you must ensure that all of your domain classes MUST implement Serializable. If not, you won't see validation feedback on your form.

Also, as part of the standard Java Serializable interface, ensure that all members of the domain class must also be Serializable.

You will see a WebLogic log message:

<[weblogic.servlet.internal.WebAppServletContext@f7ca6d - appName: '_appsdir_MyApp_dir',

name: 'MyApp', context-path: '/MyApp'] could not deserialize the request scoped attribute with name: "org.codehaus.groovy.grails.ERRORS_MyDomainObj_19315431"
java.io.NotSerializableException: org.springframework.beans.factory.support.DefaultListableBeanFactory
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1081)
at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1375)
at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1347)
at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1290)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1079)
Truncated. see log file for complete stacktrace