Thursday, January 31, 2008

Got step debugging within eclipse working!!!

http://docs.codehaus.org/display/GRAILS/Eclipse+IDE+Integration

I got it working in the bookmarks app!!!

Still need to get the testing code working right though!

bookmarks app notes

At the time of this writing all my grails apps have been reverted to grails-RC3 due to the war file bug in RC4.

On the HP laptop there are several versions of the bookmarks app. The one that seems to work at the moment is bookmarks-ch11-MappingWHibernateXML. This version is on a branch in SVN (falcon) and the branch name is chapter-11-MappingWithHibernateXML.

I fixed the app so it can be run from eclipse, (fixed the groovy build properties with bin-groovy) and fixed the classpath error so I can see the grails-app jobs dir. (so it's in the classpath).

I also added the jar files in the lib directory so they are included in the build environment. (properties->Java Build Path)

Now there are no "problems" in the problems view and it can be run from the eclipse run menu.

The app starts and the user controller displays users so it's working with GORM (hibernate and MySQL)

The bookmarks controller also seems to work and I can see my bookmarks including latest from del.icio.us.

Still most of the unit/integration tests fail. Need to fix that.

The version named bookmarks-ch11-TRUNK is broken. I can start it but it throws exceptions when I'm accessing the controllers.

Wednesday, January 30, 2008

Today going to the gym, finishing the UML, working Selenium

There's a good article by Neal Ford on selenium in the NFJS anthology I got. Just found it the other day and since we're looking at Selenium, it's apropos.

Other stuff...I need to finish the UML training and start the OO best practices training. Due the middle of Feb.

Need to move the RNG docs to the team space from my personnal space.

Work on the WebTestApp unit/integration tests.

Tuesday, January 29, 2008

grails 1.0-RC4 issues/bugs

It turns out that the RC4 war file described below is a known bug in grails 1.0-RC4 (wish I'd have known about it) and so I've reverted to RC3 for now. What a pain.

I couldn't deploy the WebTestApp as a war to tomcat (RH Linux, jdk 1.5.0_06) because it failed upon app invocation. The app deployed and appeared to be started in the tomcat administrator, but would not run. I did an experiment and this problem is apparently because of a bug in grails-1.0-RC4.

I therefore did an experiment: I created 4 identical grails apps with 1 domain class and used "generate-all" to generate the controller and views. The only difference between each one, was I created each one in a different version of grails from RC1..RC4.

Basically...

for each grails version X from RC1..RC4
grails create-app testRCX
cd testRCX
grails create-domain-class User
grails generate-all User
grails -Dserver.port=9090 run-app
test
grails war
copy the war file to the tomcat instance and test.

The only one that didn't deploy to tomcat and work was the app for RC4. Tomcat indicated it was started, but when I tried to invoke it, catalina.out reported
java.lang.NoSuchMethodError: javax.servlet.ServletContext.getContextPath()Ljava/lang/String

Here's the top of the error:
[4894343] [/testRC4].[gsp] Servlet.service() for servlet gsp threw exception
java.lang.NoSuchMethodError: javax.servlet.ServletContext.getContextPath()Ljava/lang/String;
at org.codehaus.groovy.grails.web.mapping.RegexUrlMapping.createURLInternal(RegexUrlMapping.java:179)
at org.codehaus.groovy.grails.web.mapping.RegexUrlMapping.createURLInternal(RegexUrlMapping.java:241)
at org.codehaus.groovy.grails.web.mapping.RegexUrlMapping.createURL(RegexUrlMapping.java:225)
at org.codehaus.groovy.grails.web.mapping.RegexUrlMapping.createURL(RegexUrlMapping.java:256)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)


The rest of the apps ran fine on tomcat.

Thursday, January 24, 2008

emailing from grails

The sendMail Method on page 270 of DGG (Definitive Guide to Grails) has a method used in the subscription controller that is run from a job. The method (sendMail) takes a user a subject and a bodyContent Closure and sends it using the org.apache.commons.mail.HtmlEmail package.

Should work for the WebTest app with some tweaks. Better then the Spring thing that I tried from the tutorial on the grails site. That one seems to be very old since Grails has progressed alot...Thought the book is old too and has problems.

It works! Except I can't email from windows, only linux WTF... Hard to only work in linux, but I can do some stuff.

Wednesday, January 23, 2008

Found Grails Eclipse resource!

http://docs.codehaus.org/display/GRAILS/Eclipse+IDE+Integration

Shows how to start grails app from eclipse.

Also has info on how to single step, but so far I can't get that to work.

Tuesday, January 22, 2008

eclipse bug: Compute launch button tooltip

Is happening when I try to run grails apps. Not sure if it's related to testNG, but it started when I installed it

grails upgrade and app debugging issues

I upgraded to rc4 and groovy 1.5.1 and had some problems developing on my HP laptop. New apps did not run and the class files were all scattered in the top level of the project.

Comcast laptop had racetrack at version from grails rc1 to rc3. I did the grails upgrade. The app still ran np. The Problems view showed the same Unbound claspath variable : GRAILS_HOME problem. I imported the groovy-all-1.0.jar file by "import groovy libs into project". No change.

I added the GRAILS_HOME variable in the project properties Java Build Path dialog (libraries) and it errored out with the same "Variable points to a folder: Use 'Extend...'to select an archive inside the folder." WTF? I can hit cancel, the variable is set, and the app no longer has the "Problems" view issues. I can then do an eclipse clean and the app builds, and all the class files are deposited in the project top level. again WTF?

I played with turning off the java builder and it works and makes changes to the .project file. I changed it back.

When running grails test-app in RC-3 all the tests fail.

I reverted the environ to rc1 and reverted the project to what's in trunk. I ran grails test-app and all but 4 of the tests passed. Not sure what it was before (all passed or what)

Did an experiment: Upgraded the project to rc3 and ran test-app in an rc-1 environment: Won't run because the app and environ grails version's don't match!! Did another grails upgrade from rc1 (app was rc3) and it downgraded the app! Tests (except 4) ran successfully.

Upgraded back to rc3 (app) and ran it in rc3 (environ) and the tests (cept 4) passed. Wtf.

Will experiment with TestGrails app.

Monday, January 21, 2008

trying to fix grails groovy tests in grails apps

Most of the grails test-app test fail with some odd problems about not being able to find some of the domain classes. The problems view in eclipse says stuff like

Unbound classpath variable: 'GRAILS_HOME/ant/lib/ant.jar' in project 'racetrack-TRUNK' racetrack-TRUNK Build path 1200916693560 24138
...
Unbound classpath variable: 'GRAILS_HOME/dist/grails-core-1.0-RC1.jar' in project 'racetrack-TRUNK' racetrack-TRUNK Build path 1200916693576 24197

When upgrading the groovy plugin I found that I needed testNG so I have added the testNG to my eclipse installation and I could then upgrade the groovy plugin. There's a maven plugin too, and I'll have a look at that too.

So next to fix the Unbound classpath variable problems...

Need to create a variable for GRAILS_HOME and point it to the latest grails version.

Setting the GRAILS_HOME only worked if I had also upgraded he project to RC-4. Have to test this with another app to be sure.

One weird thing is that dozens of .class files get build and put into the root folder. Messy. These are definately created by the eclipse build. If you delete them and then do a clean you get them regenerated.

Also seem to need to configure the .classpath so that all the class files go somewhere other than the root folder...