Showing posts with label grails. Show all posts
Showing posts with label grails. Show all posts

Friday, February 1, 2008

grails-1.0-RC3 is broken with gwt-plugin: Use RC4

Watch the snapshot and hopefully the next version will have fixes for both gwt -plugin and the RC4 war file bug.

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.

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

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...

Friday, December 7, 2007

service initialization gui application

/usr/bin/system-config-services (may not work) or
usr/sbin/serviceconf

Thursday, December 6, 2007

To use the maven grails plugin
First create a project (or see how to generate a pom for an existing grails project)
mvn -DgrailsHome=d:\install\groovy\grails-1.0-RC1\ grails:create-app
Then cd to the directory containing the new project and create a pom
mvn -DgroupId=com.summitbid grails:create-pom
There's no longer a run-app target for the mvn plugin but you can test it with:
mvn grails:test-app

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.

Sunday, September 30, 2007

getting started with grails comments take 2

It's sunday and I'm working on chap 7 section "Adding Interceptors" THis is the section to get the user authorization part working. I just added the
def beforeInterceptor = [action:this.&auth,
except:['search']]

to the RaceController class, so things are kinda broken, but I've been saving state to svn as I go.

Going to go play with aidan.

Saturday, September 29, 2007

getting started with grails comments

in chapter 6 getting dynamic the
findAllByCityLikeAndStateLike.


Does not seem to work. Will try using the next section method which uses hibernate.

Hibernate method works well.
section Introduction the Hibernate Criteria Builder

Got the search working completely and tagged the end of ch 6/start of ch7 start-CHAP-7

Started working on registration stuff in ch 7 start but it doesn't work yet. Am taking the kids mini golfing!