Monday, October 29, 2007

Chapter 9 broken

Couldn't get the getSuggestions stuff to work. Moving on.

Also find that the delete function from the list view is broken. When you click on delete of some bookmark in the list view you get the confirmation message and the a 403 message. "Internal Error". Chased it for awhile but didn't figure it out. Moving on.

DGTG chap 9

suggestTag throwing exceptions
bookmark is null

Thursday, October 25, 2007

Definitive guide to Grails

Chapter 7.
Confusing because the example code doesn't match the text. The example code downloaded has no domain classes!! At all!! WTF?


I also created the Secure controller. No domain class.

The UserController needs only login and handleLogin actions according to the book.

Chap 7 p 167 says we set up constraints in the user class. See chap 4 page 82.

Review constraints chapter 4.

Need to review the file upload stuff at the end of ch 7.

Friday, October 19, 2007

working through DGTG (Grails book)

Just finished chapter 5 scaffolding. page 110. Generated controllers and views for Tag and Bookmark domain classes.

Start chapter 6. Testing
had to search because grails create-test-suite is deprecated. Search of grails liste yeilded that I should use:
grails create-unit-test
and
grails create-integration-test

Had to delete all files in integration dir because the collided with new test.

Cut and pasted the code from GINA pages 126, 127, 128 into BookmarksTests.groovy and the tests ran but all failed.

Base Directory: d:\src\workspace-Grails\bookmarks
Environment set to test
Note: No plugin scripts found
Running script d:\install\groovy\grails-0.6\scripts\TestApp.groovy
Compiling 1 source files to D:\src\workspace-Grails\bookmarks\test\classes
-------------------------------------------------------
Running 6 Unit Tests...
Running test BookmarkTests...
testBadUrl...FAILURE
testListAction...FAILURE
testListActionPaginate...FAILURE
testUpdateNotFound...FAILURE
testUpdateSuccess...FAILURE
testUpdateFailure...FAILURE
Unit Tests Completed in 750ms ...
-------------------------------------------------------
No tests found in test/integration to execute ...
[junitreport] Transform time: 1156ms
Tests failed: 6 errors, 0 failures, 0 compilation errors. View reports in d:\src\workspace-Grails\bookmarks/test/reports

Note: the code from the downloaded source did not compile I think because it ref's a User object that doesn't yet exist.

Trying to get tests to work, I upgraded to grails-1.0-RC1. Did an grails upgrade:
Running script d:\install\groovy\grails-1.0-RC1\scripts\TestApp.groovy
Application expects grails version [0.6], but GRAILS_HOME is version [1.0-RC1] - use the correct Grails version or run 'grails upgrade' if this Grails version is newer than the version your application expects.
d:\src\workspace-Grails\bookmarks>grails upgrade
grails upgrade

Welcome to Grails 1.0-RC1 - http://grails.org/
Licensed under Apache Standard License 2.0
Grails home is set to: d:\install\groovy\grails-1.0-RC1

Base Directory: d:\src\workspace-Grails\bookmarks
Environment set to development
Note: No plugin scripts found
Running script d:\install\groovy\grails-1.0-RC1\scripts\Upgrade.groovy
Overriding previous definition of reference to groovyJarSet
NOTE: Your application currently expects grails version [0.6], this target will upgrade it to Grails 1.0-RC1 ...

WARNING: This target will upgrade an older Grails application to 1.0-RC1.
However, tag libraries provided by earlier versions of Grails found in grails-app/taglib will be removed.
The target will not, however, delete tag libraries developed by yourself.
Are you sure you want to continue?
(y,n)
y
[copy] Copying 2 files to D:\src\workspace-Grails\bookmarks
[copy] Copying 1 file to D:\src\workspace-Grails\bookmarks
[copy] Copying 1 file to D:\src\workspace-Grails\bookmarks
[copy] Copying 1 file to D:\src\workspace-Grails\bookmarks
[copy] Copying 1 file to D:\src\workspace-Grails\bookmarks\web-app\WEB-INF
[copy] Copying 1 file to D:\src\workspace-Grails\bookmarks\web-app\WEB-INF
[copy] Copying 5 files to D:\src\workspace-Grails\bookmarks\web-app\WEB-INF\tld
[propertyfile] Updating property file: D:\src\workspace-Grails\bookmarks\application.properties
Please make sure you view the README for important information about changes to your source code. ...
Project upgraded

I dida diff from the previous version in svn and the only difference was the application.properties file specified the newer version of grails despite the copy messages above...?

grails test app went ok. Lot's more messsages:
d:\src\workspace-Grails\bookmarks>grails test-app
grails test-app

Welcome to Grails 1.0-RC1 - http://grails.org/
Licensed under Apache Standard License 2.0
Grails home is set to: d:\install\groovy\grails-1.0-RC1

Base Directory: d:\src\workspace-Grails\bookmarks
Environment set to test
Note: No plugin scripts found
Running script d:\install\groovy\grails-1.0-RC1\scripts\TestApp.groovy
[mkdir] Created dir: C:\Documents and Settings\Ed Young\.grails\1.0-RC1\projects\bookmarks\classes
Compiling 10 source files to C:\Documents and Settings\Ed Young\.grails\1.0-RC1\projects\bookmarks\classes
[copy] Copying 1 file to D:\src\workspace-Grails\bookmarks\web-app\WEB-INF\grails-app\i18n
[copy] Copying 1 file to C:\Documents and Settings\Ed Young\.grails\1.0-RC1\projects\bookmarks\classes
[copy] Copying 1 file to C:\Documents and Settings\Ed Young\.grails\1.0-RC1\projects\bookmarks\classes
[0] plugins.DefaultGrailsPluginManager Attempting to load [0] user defined plugins
[0] plugins.DefaultGrailsPluginManager Grails plug-in [core] with version [1.0-RC1] loaded successfully
[0] plugins.DefaultGrailsPluginManager Grails plug-in [servlets] with version [1.0-RC1] loaded successfully
[0] plugins.DefaultGrailsPluginManager Grails plug-in [filters] with version [0.1] loaded successfully
[0] plugins.DefaultGrailsPluginManager Grails plug-in [codecs] with version [1.0-RC1] loaded successfully
[0] plugins.DefaultGrailsPluginManager Grails plug-in [dataSource] with version [1.0-RC1] loaded successfully
[0] plugins.DefaultGrailsPluginManager Grails plug-in [i18n] with version [1.0-RC1] loaded successfully
[0] plugins.DefaultGrailsPluginManager Grails plug-in [urlMappings] with version [1.0-RC1] loaded successfully
[0] plugins.DefaultGrailsPluginManager Grails plug-in [controllers] with version [1.0-RC1] loaded successfully
[0] plugins.DefaultGrailsPluginManager Grails plug-in [logging] with version [1.0-RC1] loaded successfully
[0] plugins.DefaultGrailsPluginManager Grails plug-in [hibernate] with version [1.0-RC1] loaded successfully
[0] plugins.DefaultGrailsPluginManager Grails plug-in [domainClass] with version [1.0-RC1] loaded successfully
[0] plugins.DefaultGrailsPluginManager Grails plug-in [converters] with version [1.0-RC1] loaded successfully
[0] plugins.DefaultGrailsPluginManager Grails plug-in [scaffolding] with version [1.0-RC1] loaded successfully
[0] plugins.DefaultGrailsPluginManager Grails plug-in [webFlow] with version [1.0-RC1] loaded successfully
[0] plugins.DefaultGrailsPluginManager Grails plug-in [services] with version [1.0-RC1] loaded successfully
[copy] Copying 1 file to C:\Documents and Settings\Ed Young\.grails\1.0-RC1\projects\bookmarks
[1953] plugins.DefaultGrailsPluginManager Attempting to load [0] user defined plugins
[1953] plugins.DefaultGrailsPluginManager Grails plug-in [core] with version [1.0-RC1] loaded successfully
[1953] plugins.DefaultGrailsPluginManager Grails plug-in [servlets] with version [1.0-RC1] loaded successfully
[1953] plugins.DefaultGrailsPluginManager Grails plug-in [filters] with version [0.1] loaded successfully
[1953] plugins.DefaultGrailsPluginManager Grails plug-in [codecs] with version [1.0-RC1] loaded successfully
[1953] plugins.DefaultGrailsPluginManager Grails plug-in [dataSource] with version [1.0-RC1] loaded successfully
[1953] plugins.DefaultGrailsPluginManager Grails plug-in [i18n] with version [1.0-RC1] loaded successfully
[1953] plugins.DefaultGrailsPluginManager Grails plug-in [urlMappings] with version [1.0-RC1] loaded successfully
[1953] plugins.DefaultGrailsPluginManager Grails plug-in [controllers] with version [1.0-RC1] loaded successfully
[1953] plugins.DefaultGrailsPluginManager Grails plug-in [logging] with version [1.0-RC1] loaded successfully
[1953] plugins.DefaultGrailsPluginManager Grails plug-in [hibernate] with version [1.0-RC1] loaded successfully
[1953] plugins.DefaultGrailsPluginManager Grails plug-in [domainClass] with version [1.0-RC1] loaded successfully
[1953] plugins.DefaultGrailsPluginManager Grails plug-in [converters] with version [1.0-RC1] loaded successfully
[1953] plugins.DefaultGrailsPluginManager Grails plug-in [scaffolding] with version [1.0-RC1] loaded successfully
[1953] plugins.DefaultGrailsPluginManager Grails plug-in [webFlow] with version [1.0-RC1] loaded successfully
[1953] plugins.DefaultGrailsPluginManager Grails plug-in [services] with version [1.0-RC1] loaded successfully
[2125] util.GrailsUtil [WARNING] Property [url] of domain class Bookmark has type [java.net.URL] and doesn't support constraint [url]. This constraint will not be checked during validation.
-------------------------------------------------------
Running 1 Unit Test...
Running test BookmarkTests...
testSortBookmarks...SUCCESS
Unit Tests Completed in 203ms ...
-------------------------------------------------------
No tests found in test/integration to execute ...
[junitreport] Transform time: 1297ms
Tests passed. View reports in d:\src\workspace-Grails\bookmarks/test/reports

Now going to do run-app:

d:\src\workspace-Grails\bookmarks>grails run-app -Dserver.port=9090
grails run-app -Dserver.port=9090

Welcome to Grails 1.0-RC1 - http://grails.org/
Licensed under Apache Standard License 2.0
Grails home is set to: d:\install\groovy\grails-1.0-RC1

Base Directory: d:\src\workspace-Grails\bookmarks
Environment set to development
Note: No plugin scripts found
Running script d:\install\groovy\grails-1.0-RC1\scripts\RunApp.groovy
[0] plugins.DefaultGrailsPluginManager Attempting to load [0] user defined plugins
[0] plugins.DefaultGrailsPluginManager Grails plug-in [core] with version [1.0-RC1] loaded successfully
[0] plugins.DefaultGrailsPluginManager Grails plug-in [servlets] with version [1.0-RC1] loaded successfully
[0] plugins.DefaultGrailsPluginManager Grails plug-in [filters] with version [0.1] loaded successfully
[0] plugins.DefaultGrailsPluginManager Grails plug-in [dataSource] with version [1.0-RC1] loaded successfully
[0] plugins.DefaultGrailsPluginManager Grails plug-in [logging] with version [1.0-RC1] loaded successfully
[0] plugins.DefaultGrailsPluginManager Grails plug-in [i18n] with version [1.0-RC1] loaded successfully
[0] plugins.DefaultGrailsPluginManager Grails plug-in [codecs] with version [1.0-RC1] loaded successfully
[0] plugins.DefaultGrailsPluginManager Grails plug-in [urlMappings] with version [1.0-RC1] loaded successfully
[0] plugins.DefaultGrailsPluginManager Grails plug-in [controllers] with version [1.0-RC1] loaded successfully
[0] plugins.DefaultGrailsPluginManager Grails plug-in [hibernate] with version [1.0-RC1] loaded successfully
[0] plugins.DefaultGrailsPluginManager Grails plug-in [services] with version [1.0-RC1] loaded successfully
[0] plugins.DefaultGrailsPluginManager Grails plug-in [domainClass] with version [1.0-RC1] loaded successfully
[0] plugins.DefaultGrailsPluginManager Grails plug-in [scaffolding] with version [1.0-RC1] loaded successfully
[0] plugins.DefaultGrailsPluginManager Grails plug-in [webFlow] with version [1.0-RC1] loaded successfully
[0] plugins.DefaultGrailsPluginManager Grails plug-in [converters] with version [1.0-RC1] loaded successfully
Running Grails application..
2007-10-20 08:07:31.583::INFO: Logging to STDERR via org.mortbay.log.StdErrLog
2007-10-20 08:07:31.661::INFO: jetty-6.1.4
2007-10-20 08:07:32.395:/bookmarks:INFO: Set web app root system property: 'bookmarks' = [D:\src\workspace-Grails\bookmarks\web-app\]
2007-10-20 08:07:32.395:/bookmarks:INFO: Initializing Log4J from [D:\src\workspace-Grails\bookmarks\web-app\WEB-INF\classes\log4j.properties]
2007-10-20 08:07:32.395:/bookmarks:INFO: Initializing Spring root WebApplicationContext
[3265] util.GrailsUtil [WARNING] Property [url] of domain class Bookmark has type [java.net.URL] and doesn't support constraint [url]. This constraint will not be checked during validation.
[6594] hibernate.ConfigurableLocalSessionFactoryBean Building new Hibernate SessionFactory
[7515] mvc.GrailsUrlHandlerMapping Neither 'urlMap' nor 'mappings' set on SimpleUrlHandlerMapping
[9062] filters.FiltersGrailsPlugin reloadFilters
[9094] util.GrailsUtil [WARNING] Property [url] of domain class Bookmark has type [java.net.URL] and doesn't support constraint [url]. This constraint will not be checked during validation.
[9094] commons.GrailsConfigUtils [GrailsContextLoader] Grails application loaded.
2007-10-20 08:07:39.422:/bookmarks:INFO: Initializing Spring FrameworkServlet 'grails'
[9250] servlet.GrailsDispatcherServlet FrameworkServlet 'grails': initialization started
[9328] servlet.GrailsDispatcherServlet Using MultipartResolver [org.springframework.web.multipart.commons.CommonsMultipartResolver@52f9b2]
[9328] servlet.GrailsDispatcherServlet FrameworkServlet 'grails': initialization completed in 78 ms
2007-10-20 08:07:39.531::INFO: Started SelectChannelConnector@0.0.0.0:9090
Server running. Browse to http://localhost:9090/bookmarks
2007-10-20 08:08:06.000:/bookmarks:INFO: GSP servlet initialized
[41578] view.GrailsViewResolver View caching is SWITCHED OFF -- DEVELOPMENT SETTING ONLY: This can severely impair performance
[47156] view.GrailsViewResolver View caching is SWITCHED OFF -- DEVELOPMENT SETTING ONLY: This can severely impair performance
[60890] view.GrailsViewResolver View caching is SWITCHED OFF -- DEVELOPMENT SETTING ONLY: This can severely impair performance
[62984] view.GrailsViewResolver View caching is SWITCHED OFF -- DEVELOPMENT SETTING ONLY: This can severely impair performance


Ran it and it seemed to work.

tests fail because of the error that it can't cast String to URL.

Moving on to Ch 7.