<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Grails and Google AppEngine</title>
	<atom:link href="http://www.fiveclouds.com/2009/07/13/grails-and-google-appengine/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.fiveclouds.com/2009/07/13/grails-and-google-appengine/</link>
	<description>collaboration, creativity and the next big thing</description>
	<lastBuildDate>Sat, 10 Oct 2009 23:06:06 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Philip</title>
		<link>http://www.fiveclouds.com/2009/07/13/grails-and-google-appengine/comment-page-1/#comment-220</link>
		<dc:creator>Philip</dc:creator>
		<pubDate>Sat, 10 Oct 2009 23:06:06 +0000</pubDate>
		<guid isPermaLink="false">http://www.fiveclouds.com/?p=158#comment-220</guid>
		<description>Just sent over an e-mail with some more details - happy to keep trying to help :)</description>
		<content:encoded><![CDATA[<p>Just sent over an e-mail with some more details &#8211; happy to keep trying to help :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chad</title>
		<link>http://www.fiveclouds.com/2009/07/13/grails-and-google-appengine/comment-page-1/#comment-219</link>
		<dc:creator>Chad</dc:creator>
		<pubDate>Sat, 10 Oct 2009 23:00:58 +0000</pubDate>
		<guid isPermaLink="false">http://www.fiveclouds.com/?p=158#comment-219</guid>
		<description>Thanks for the response Philip.  Yeah, I&#039;m using GORM-JPA (grails plugin) for only the User class, just like you were doing (and not the Role class) - copied your User &amp; Role code verbatim.  Just to get around the error in my previous comment, I hard coded the User.getAuthorities() like this and got by the error - but long term, I can&#039;t hard code every user to ADMIN :)

GrantedAuthority[] getAuthorities() {
//return roles.collect { new Role(authority:it) } as GrantedAuthority[] //this doesn&#039;t work - get javax.jdo.JDODetachedFieldAccessException
return [new Role(authority:&#039;ROLE_ADMIN_USER&#039;)] as GrantedAuthority[]
}

Were you able to get the 
  roles.collect { new Role(authority:it) } as GrantedAuthority[] 
to work?  You still have code around for your UserLookupService.groovy &amp; BootStrap.groovy?

thanks,
@chadsmall</description>
		<content:encoded><![CDATA[<p>Thanks for the response Philip.  Yeah, I&#8217;m using GORM-JPA (grails plugin) for only the User class, just like you were doing (and not the Role class) &#8211; copied your User &amp; Role code verbatim.  Just to get around the error in my previous comment, I hard coded the User.getAuthorities() like this and got by the error &#8211; but long term, I can&#8217;t hard code every user to ADMIN :)</p>
<p>GrantedAuthority[] getAuthorities() {<br />
//return roles.collect { new Role(authority:it) } as GrantedAuthority[] //this doesn&#8217;t work &#8211; get javax.jdo.JDODetachedFieldAccessException<br />
return [new Role(authority:'ROLE_ADMIN_USER')] as GrantedAuthority[]<br />
}</p>
<p>Were you able to get the<br />
  roles.collect { new Role(authority:it) } as GrantedAuthority[]<br />
to work?  You still have code around for your UserLookupService.groovy &amp; BootStrap.groovy?</p>
<p>thanks,<br />
@chadsmall</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Philip</title>
		<link>http://www.fiveclouds.com/2009/07/13/grails-and-google-appengine/comment-page-1/#comment-218</link>
		<dc:creator>Philip</dc:creator>
		<pubDate>Sat, 10 Oct 2009 19:27:06 +0000</pubDate>
		<guid isPermaLink="false">http://www.fiveclouds.com/?p=158#comment-218</guid>
		<description>Hey Chad

It sounds like you are having a problem the session,  the actual code I put up there shouldn&#039;t really have this problem since the Role object is never actually persisted in the datastore, it is simply a list of strings held in the user entity.

Looks like you are using GORM-JPA?

Cheers

P</description>
		<content:encoded><![CDATA[<p>Hey Chad</p>
<p>It sounds like you are having a problem the session,  the actual code I put up there shouldn&#8217;t really have this problem since the Role object is never actually persisted in the datastore, it is simply a list of strings held in the user entity.</p>
<p>Looks like you are using GORM-JPA?</p>
<p>Cheers</p>
<p>P</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chad</title>
		<link>http://www.fiveclouds.com/2009/07/13/grails-and-google-appengine/comment-page-1/#comment-217</link>
		<dc:creator>Chad</dc:creator>
		<pubDate>Sat, 10 Oct 2009 19:11:47 +0000</pubDate>
		<guid isPermaLink="false">http://www.fiveclouds.com/?p=158#comment-217</guid>
		<description>Hey Philip,

Back with an update.  Further, but spinning on this one a bit.  Maybe you can shed some light?  I think you got past this somehow?

I changed this line in UserLookupService.groovy:

         //User user = User.findByUsername(userName)  //this doesn&#039;t work?
         User user = User.findWhere(username: userName)

and this is my BootStrap.groovy to seed a user:

     def adminUser = new User(username: &#039;admin&#039;, password: PasswordEncoder.encode(&#039;password&#039;, &#039;SHA-256&#039;, true), roles: [&#039;ROLE_ADMIN_USER&#039;]) 
     adminUser.save()

I startup the app with no errors (not sure how to verify my save user happened on bootstrap).  App directs me to the login page and when I attempt admin/password login, I get this exception:
    
javax.jdo.JDODetachedFieldAccessException: You have just attempted to access field &quot;roles&quot; yet this field was not detached when you detached the object. Either dont access this field, or detach it when detaching the object.
	at com.thesmallcompany.triangleadmin.User.jdoGetroles(User.groovy)
	at com.thesmallcompany.triangleadmin.User.getAuthorities(User.groovy:34)

Seems like a pretty good error message and I&#039;ve looked around, but being a JPA newbie, not sure how to &#039;detach&#039; the object :)  Assume the bootstrap save() is somehow not &#039;detaching&#039;??

Here is the code (same as you have in your post above) that it doesn&#039;t like:

GrantedAuthority[] getAuthorities() {
  return roles.collect { new Role(authority:it) } as GrantedAuthority[]  //line 34
}

thanks bunches for anything,
@chadsmall</description>
		<content:encoded><![CDATA[<p>Hey Philip,</p>
<p>Back with an update.  Further, but spinning on this one a bit.  Maybe you can shed some light?  I think you got past this somehow?</p>
<p>I changed this line in UserLookupService.groovy:</p>
<p>         //User user = User.findByUsername(userName)  //this doesn&#8217;t work?<br />
         User user = User.findWhere(username: userName)</p>
<p>and this is my BootStrap.groovy to seed a user:</p>
<p>     def adminUser = new User(username: &#8216;admin&#8217;, password: PasswordEncoder.encode(&#8216;password&#8217;, &#8216;SHA-256&#8242;, true), roles: ['ROLE_ADMIN_USER'])<br />
     adminUser.save()</p>
<p>I startup the app with no errors (not sure how to verify my save user happened on bootstrap).  App directs me to the login page and when I attempt admin/password login, I get this exception:</p>
<p>javax.jdo.JDODetachedFieldAccessException: You have just attempted to access field &#8220;roles&#8221; yet this field was not detached when you detached the object. Either dont access this field, or detach it when detaching the object.<br />
	at com.thesmallcompany.triangleadmin.User.jdoGetroles(User.groovy)<br />
	at com.thesmallcompany.triangleadmin.User.getAuthorities(User.groovy:34)</p>
<p>Seems like a pretty good error message and I&#8217;ve looked around, but being a JPA newbie, not sure how to &#8216;detach&#8217; the object :)  Assume the bootstrap save() is somehow not &#8216;detaching&#8217;??</p>
<p>Here is the code (same as you have in your post above) that it doesn&#8217;t like:</p>
<p>GrantedAuthority[] getAuthorities() {<br />
  return roles.collect { new Role(authority:it) } as GrantedAuthority[]  //line 34<br />
}</p>
<p>thanks bunches for anything,<br />
@chadsmall</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chad</title>
		<link>http://www.fiveclouds.com/2009/07/13/grails-and-google-appengine/comment-page-1/#comment-216</link>
		<dc:creator>Chad</dc:creator>
		<pubDate>Sat, 10 Oct 2009 04:47:19 +0000</pubDate>
		<guid isPermaLink="false">http://www.fiveclouds.com/?p=158#comment-216</guid>
		<description>Great post Philip,

Helping me move forward on a similar simple GAE Grails app and need a very simple security solution and trying to get Stark Security going.  Would you mind posting what you did with the Stark Security UserLookupService.groovy service?  I&#039;m currently getting this error when logging in:

Error 500: Class User for query has not been resolved. Check the query and any imports specification

And the one other thing, if you could please post what you did within your BootStrap.groovy to get your initial user/role established.

Again, thanks a bunch for posting what you have to this point.  Very helpful.

@chadsmall</description>
		<content:encoded><![CDATA[<p>Great post Philip,</p>
<p>Helping me move forward on a similar simple GAE Grails app and need a very simple security solution and trying to get Stark Security going.  Would you mind posting what you did with the Stark Security UserLookupService.groovy service?  I&#8217;m currently getting this error when logging in:</p>
<p>Error 500: Class User for query has not been resolved. Check the query and any imports specification</p>
<p>And the one other thing, if you could please post what you did within your BootStrap.groovy to get your initial user/role established.</p>
<p>Again, thanks a bunch for posting what you have to this point.  Very helpful.</p>
<p>@chadsmall</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chee Kin</title>
		<link>http://www.fiveclouds.com/2009/07/13/grails-and-google-appengine/comment-page-1/#comment-215</link>
		<dc:creator>Chee Kin</dc:creator>
		<pubDate>Fri, 04 Sep 2009 03:56:27 +0000</pubDate>
		<guid isPermaLink="false">http://www.fiveclouds.com/?p=158#comment-215</guid>
		<description>Hi Philip,

Thanks for fast response.

Yes. I am awared that GORM mapping (like hasMany) is not supported by gorm-jpa plugin, so all the mapping I did is using JPA annotations. Thanks for information and reminder. But still no luck, I am unable to make it works.

I sent a post to StackOverflow for detail description about problem I faced:
http://stackoverflow.com/questions/1377091/how-to-setup-one-to-many-unidirectional-mapping-for-grails-application-on-gae

It will be great if you can have a look there and advise further.

Thanks.</description>
		<content:encoded><![CDATA[<p>Hi Philip,</p>
<p>Thanks for fast response.</p>
<p>Yes. I am awared that GORM mapping (like hasMany) is not supported by gorm-jpa plugin, so all the mapping I did is using JPA annotations. Thanks for information and reminder. But still no luck, I am unable to make it works.</p>
<p>I sent a post to StackOverflow for detail description about problem I faced:<br />
<a href="http://stackoverflow.com/questions/1377091/how-to-setup-one-to-many-unidirectional-mapping-for-grails-application-on-gae" rel="nofollow">http://stackoverflow.com/questions/1377091/how-to-setup-one-to-many-unidirectional-mapping-for-grails-application-on-gae</a></p>
<p>It will be great if you can have a look there and advise further.</p>
<p>Thanks.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Philip</title>
		<link>http://www.fiveclouds.com/2009/07/13/grails-and-google-appengine/comment-page-1/#comment-214</link>
		<dc:creator>Philip</dc:creator>
		<pubDate>Thu, 03 Sep 2009 13:24:24 +0000</pubDate>
		<guid isPermaLink="false">http://www.fiveclouds.com/?p=158#comment-214</guid>
		<description>Hey Chee

Actually I cheated on that bit since I just store a list of roles

List&lt;String&gt; roles = new ArrayList&lt;String&gt;();

On the user and the role actually doesn&#039;t persist therefore I don&#039;t need to worry about the relationship.  Though you should be able to get a one to many relationship working - you need to remember that it is all done through the annotations and the normal GORM notation (like hasMany) is not used by GORM-JPA.

Hope that helps - if not comment again and I can e-mail you and take a look :)

Cheers

P</description>
		<content:encoded><![CDATA[<p>Hey Chee</p>
<p>Actually I cheated on that bit since I just store a list of roles</p>
<p>List<string> roles = new ArrayList</string><string>();</p>
<p>On the user and the role actually doesn&#8217;t persist therefore I don&#8217;t need to worry about the relationship.  Though you should be able to get a one to many relationship working &#8211; you need to remember that it is all done through the annotations and the normal GORM notation (like hasMany) is not used by GORM-JPA.</p>
<p>Hope that helps &#8211; if not comment again and I can e-mail you and take a look :)</p>
<p>Cheers</p>
<p>P</string></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chee Kin</title>
		<link>http://www.fiveclouds.com/2009/07/13/grails-and-google-appengine/comment-page-1/#comment-213</link>
		<dc:creator>Chee Kin</dc:creator>
		<pubDate>Thu, 03 Sep 2009 12:56:28 +0000</pubDate>
		<guid isPermaLink="false">http://www.fiveclouds.com/?p=158#comment-213</guid>
		<description>Dear Philip,

Thanks for the written suck a great post regarding Grails on GAE.

I tried to make stark security works in my grails application on GAE.

But I stuck in setting up OneToMany relationship of User and Role class.

FYI, I am using app-engine, gorm-jpa and stark-security plugin in my grails application.

Did you published your source code of this post, so that I can access it via an URL?

Any pointer will be appreciated.

Thanks</description>
		<content:encoded><![CDATA[<p>Dear Philip,</p>
<p>Thanks for the written suck a great post regarding Grails on GAE.</p>
<p>I tried to make stark security works in my grails application on GAE.</p>
<p>But I stuck in setting up OneToMany relationship of User and Role class.</p>
<p>FYI, I am using app-engine, gorm-jpa and stark-security plugin in my grails application.</p>
<p>Did you published your source code of this post, so that I can access it via an URL?</p>
<p>Any pointer will be appreciated.</p>
<p>Thanks</p>
]]></content:encoded>
	</item>
</channel>
</rss>
