Trouble Shooting on Grails

Trouble Shooting on Grails

Last week, I am trying to trouble shooting a grails problem.

When I use the JMETER to put pressure on my local tomcat instance of grails war package.

1. No Signature of method issue
I got this kind of error, Error Message
2013-03-05 16:52:07,017 [http-bio-8080-exec-3] ERROR com.sillycat.xxx.ErrorController  - No signature of method: static com.sillycat.xxx.events.GeoFenceExitEvent.save() is applicable for argument types: (java.util.LinkedHashMap) values: [[flush:true]]
Possible solutions: save(), save(java.util.Map), save(java.lang.Boolean), wait(), any(), wait(long)
org.codehaus.groovy.grails.web.errors.GrailsWrappedRuntimeException: No signature of method: static com.sillycat.xxx.events.GeoFenceExitEvent.save() is applicable for argument types: (java.util.LinkedHashMap) values: [[flush:true]]
Possible solutions: save(), save(java.util.Map), save(java.lang.Boolean), wait(), any(), wait(long)
at Skipped non-sillycat elements.(:86)
Caused by: groovy.lang.MissingMethodException: No signature of method: static com.sillycat.xxx.events.GeoFenceExitEvent.save() is applicable for argument types: (java.util.LinkedHashMap) values: [[flush:true]]
Possible solutions: save(), save(java.util.Map), save(java.lang.Boolean), wait(), any(), wait(long)

Solution:
In the groovy class which belongs to the grails framework
grails-app/conf/BootStrap.groovy

Add these statements to the class

// Eager initialize GORM Domain Mixin Methods.
grailsApplication.domainClasses.each { dc ->
     //dc.clazz.count()               initial the GORM
     //dc.clazz.metaClass.mapping = null   get rid of all the GROM method mapping
     dc.clazz.count()
}

2. Stale Object State Exception
Error Message
2013-03-05 16:26:06,140 [http-bio-8080-exec-35] ERROR com.sillycat.xxx.ErrorController  - Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect): [com.sillycat.xxx.Device#3015]
org.codehaus.groovy.grails.web.errors.GrailsWrappedRuntimeException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect): [com.sillycat.xxx.Device#3015]
at Skipped non-Sillycat elements.(:86)
Caused by: org.hibernate.StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect): [com.sillycat.xxx.Device#3015]
at Skipped non-sillycat elements.(:1)
at com.sillycat.xxx.events.EventService.saveEvent(EventService.groovy:93)
at com.sillycat.xxx.events.GeoFenceEntryEventService.super$2$saveEvent(GeoFenceEntryEventService.groovy)
at Skipped non-sillycat elements.(:1)

Solution:
I found the Object which is managed by GROM. I close the version, it is working then.
class Student{
     …snip…
     static mapping = {
          table 'students'
          version false
     }
}

3. Change the HTTP and HTTPS Configuration
I can change the http server port and https server port easily, but I got errors.

grails.server.port.http/server.port     -   default 8080
grails.server.port.https                    -   default 8443
https                                             - start an HTTPS Server

I can change the server port as I like
>-Dserver.port.https=443 run-app -https
>-Dserver.port=80 run-app -https
>-Dserver.port=80 -Dserver.port.https=443 run-app -https

Error Messages:
java.net.BindException: Permission denied<null>:443
java.net.BindException: Permission denied<null>:80


Solution:
One option- make tomcat running on the 1-1024 port
https://github.com/Castaglia/MacOSX-authbind

http://java-notes.com/index.php/installing-tomcat-with-http-port-80-on-linux

When I start the run-app, I got these application information:
>ps -ef | grep grails
503 12216 11278   0 11:15AM ??         1:03.72 /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/bin/java -server -Xmx768M -XX:MaxPermSize=256m -Djline.terminal=jline.UnsupportedTerminal -Dbase.dir=/Users/carl/company/code/localpoint/Localpoint -Dgrails.home=/Users/carl/tool/grails-1.3.7/ -Dfile.encoding=MacRoman -classpath /Users/carl/tool/grails-1.3.7/lib/groovy-all-1.7.8.jar:/Users/carl/tool/grails-1.3.7/dist/grails-bootstrap-1.3.7.jar org.codehaus.groovy.grails.cli.support.GrailsStarter --conf /Users/carl/tool/grails-1.3.7/conf/groovy-starter.conf --main org.codehaus.groovy.grails.cli.GrailsScriptRunner run-app -https

Download the zip file from https://github.com/Castaglia/MacOSX-authbind
I got the file MacOSX-authbind-master.zip and unzip it.
>cd /Users/carl/Downloads/MacOSX-authbind-master
Move this tool to the working directory
>mv MacOSX-authbind-master /Users/carl/tool/authbind

Build that on my MAC
>make
>sudo make install

That is done for the tool authbind.

And then open the monitor 'Activity Monitor', check the User 'carl' is running the Process Name 'Groovy/Grails Tool Suite'.

Authbind is configured with some special files, for which we can assign our arbitrary permissions for the users we want to give access to.
>sudo touch /etc/authbind/byport/80
>sudo chmod 500 /etc/authbind/byport/80
>sudo chown carl /etc/authbind/byport/80

>sudo touch /etc/authbind/byport/443
>sudo chmod 500 /etc/authbind/byport/443
>sudo chown carl /etc/authbind/byport/443

Stop my apache which already take the port 80.
>sudo apachectl stop

>authbind --deep grails -Dserver.port.https=443 -Dserver.port=80 run-app -https

It seems not working. Or a easy way
>su root
>grails -Dserver.port=80 -Dserver.port.https=443 run-app -https

Or maybe download the software named 'LauchAsRoot' and use it.
http://www.macupdate.com/app/mac/38617/launchasroot

References:
http://sillycat.iteye.com/blog/772289
http://sillycat.iteye.com/blog/736723
http://markmail.org/message/o5i3o4f7v3dizhq6

http://grails.org/doc/1.3.7/guide/single.html#5.5.2.7%20Optimistic%20Locking%20and%20Versioning

http://grails.org/doc/2.2.0/ref/Command%20Line/run-app.html

你可能感兴趣的:(grails)