Quantcast

config.serverURL and redirects

classic Classic list List threaded Threaded
16 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

config.serverURL and redirects

Joe Greenawalt
Hi, I was wondering if anyone had anymore insight into this issue?


I'm running grails 2.0.4 on tomcat 7 behind the latest apache on the latest CentOS.

I need a different url for staging our production until the switch over, so i have aliases set up in the meantime.  But i'm getting 404s on redirects, because its sending it to the absolute instead of the relative.

Is there an override to always send relative redirects or some other way of getting around this?

Is it fixed in 2.1?

Thanks,
Joe
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: config.serverURL and redirects

pledbrook
> I need a different url for staging our production until the switch over, so
> i have aliases set up in the meantime.  But i'm getting 404s on redirects,
> because its sending it to the absolute instead of the relative.
>
> Is there an override to always send relative redirects or some other way of
> getting around this?

I think your best option here is to use response.sendRedirect(). That
will build the redirect URL from the request. If you want to use
controller/action syntax, inject the grailsLinkGenerator bean and use
it to generate the URI for sendRedirect().

> Is it fixed in 2.1?

Is there an issue in JIRA? A good explanation of why the redirect URI
would be different from grails.serverURL would be helpful in
determining what the most appropriate solution is.

Cheers,

Peter

--
Peter Ledbrook
Grails Advocate
SpringSource - A Division of VMware

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: config.serverURL and redirects

rlovtangen
In reply to this post by Joe Greenawalt
Do you need grails.serverURL at all? We're doing fine by simply removing he property, then URLs are generated based on the request.

Ronny

On Aug 3, 2012, at 6:17 AM, Joe Greenawalt wrote:

Hi, I was wondering if anyone had anymore insight into this issue?


I'm running grails 2.0.4 on tomcat 7 behind the latest apache on the latest CentOS.

I need a different url for staging our production until the switch over, so i have aliases set up in the meantime.  But i'm getting 404s on redirects, because its sending it to the absolute instead of the relative.

Is there an override to always send relative redirects or some other way of getting around this?

Is it fixed in 2.1?

Thanks,
Joe

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Pluginreposity down?

JanSchumacher2
Hi all,

is the grails plugin repository down? When i'm doing the grails
list-plugins command, i'm getting only a few plugins.

Resolving dependencies...
Dependencies resolved in 2501ms.
Running script /development/grails-1.3.7/scripts/ListPlugins_.groovy
Environment set to development

Plugins available in the grailsCentral repository are listed below:
-------------------------------------------------------------

cas-client          <1.2>            --  This plugin provides client
integration for JA-SIG CAS
grails-melody       <1.16>           --  Grails Java Melody Plugin
rally-feature-toggle<0.3>            --  Plugin summary/headline


Plugins available in the grailsCore repository are listed below:
-------------------------------------------------------------

dummy               <>               --
hibernate           <1.3.8>          --  Hibernate for Grails
tomcat              <1.3.8>          --  Apache Tomcat plugin for Grails
webflow             <1.3.8.BUILD-SNAPSHOT> --  Spring Web Flow Plugin


The version of grails is 1.3.7.

Is there something wrong with the configuration?

repositories {
         def libResolver = new org.apache.ivy.plugins.resolver.URLResolver()
libResolver.addArtifactPattern("http://cloud.github.com/downloads/pedjak/grails-mockutils-fix/grails-[artifact]-[revision].[ext]")
         libResolver.name = "mockutils-fix-repo"
         libResolver.settings = ivySettings

         resolver libResolver

         grailsPlugins()
         grailsHome()
         grailsCentral()

         // uncomment the below to enable remote dependency resolution
         // from public Maven repositories
         mavenLocal()
         mavenCentral()
         //mavenRepo "http://snapshots.repository.codehaus.org"
         mavenRepo "http://repository.codehaus.org"
         //mavenRepo "http://download.java.net/maven/2/"
         //mavenRepo "http://repository.jboss.com/maven2/"
     }

Best regards
Jan Schumacher

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Pluginreposity down?

pledbrook
> The version of grails is 1.3.7.

Are you able to upgrade to 1.3.9? That is the preferred solution,
otherwise you won't see new plugin releases. In the meantime, I'll try
to fix the master plugin list.

Peter

--
Peter Ledbrook
Grails Advocate
SpringSource - A Division of VMware

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

EqualsAndHashCode does not compare id

Nicholas Wittstruck
Hi everyone,

I wanted to add the @EqualsAndHashCode to my domain classes, since I have seen the suggestions a few times. Afterwards some of our unit tests were failing, because the generated equals method ignores the id of grails domain classes. How are you handling this situation? In most of our domain classes the id is the only property that is unique.

Nicholas
---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Pluginreposity down?

JanSchumacher2
In reply to this post by pledbrook
No i don't.
But it would be great if you do this. :)
In the meantime, i'll install the plugin, that i need, by adding the zip
to the lib directory of my application.
Thank you for your help!

Am 03.08.12 11:14, schrieb Peter Ledbrook:
>> The version of grails is 1.3.7.
> Are you able to upgrade to 1.3.9? That is the preferred solution,
> otherwise you won't see new plugin releases. In the meantime, I'll try
> to fix the master plugin list.
>
> Peter
>


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: EqualsAndHashCode does not compare id

seeker136
In reply to this post by Nicholas Wittstruck
Nicholas,

I solved this problem by explicitly adding the id field to the domain
class, like so:

@EqualsAndHashCode(includes = ["id"])
class Foo {
 Long id
 String name
}

Regards,
Jay

On Fri, Aug 3, 2012 at 5:35 AM, Nicholas Wittstruck
<[hidden email]> wrote:

> Hi everyone,
>
> I wanted to add the @EqualsAndHashCode to my domain classes, since I have seen the suggestions a few times. Afterwards some of our unit tests were failing, because the generated equals method ignores the id of grails domain classes. How are you handling this situation? In most of our domain classes the id is the only property that is unique.
>
> Nicholas
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>     http://xircles.codehaus.org/manage_email
>
>



--
==============================
Converting caffeine into code since 1998.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: config.serverURL and redirects

ideasculptor
In reply to this post by rlovtangen
On Fri, Aug 3, 2012 at 1:28 AM, Ronny Løvtangen <[hidden email]> wrote:
Do you need grails.serverURL at all? We're doing fine by simply removing he property, then URLs are generated based on the request.

This.  I had exactly the problem you are having when I switched from 1.3.x to 2.0.x. Simply removing serverURL entirely fixed it (after much time wasted trying to debug just what the heck it was doing since response.sendRedirect() was being turned into an absolute url with the wrong hostname, which made no sense). Without a serverURL, it behaves as you'd expect it to in all cases, so far as I can tell.

--sam

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: EqualsAndHashCode does not compare id

Ian Roberts
In reply to this post by seeker136
On 03/08/2012 11:06, Jay Hogan wrote:
> Nicholas,
>
> I solved this problem by explicitly adding the id field to the domain
> class, like so:

Fair enough, but make sure you understand the implications.  The
Hibernate documentation specifically recommends *not* using the database
ID as part of the equals/hashCode computation because IDs are only
generated when domain objects are saved (and so you wouldn't be able to
compare a transient object with a persistent one).  In particular, if
you want to use a domain object in a Set-valued hasMany then you need to
implement equals and hashCode in terms of a "business key", i.e.
something stable that isn't the database identity.

http://docs.jboss.org/hibernate/core/4.0/manual/en-US/html/persistent-classes.html#persistent-classes-equalshashcode

Of course, if you're using manually-assigned rather than
database-generated identifiers then it's fine to use the id in equals
because the value is under your control.

Ian

--
Ian Roberts               | Department of Computer Science
[hidden email]  | University of Sheffield, UK

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Pluginreposity down?

pledbrook
In reply to this post by JanSchumacher2
> No i don't.
> But it would be great if you do this. :)

I have regenerated the list, but as I said it won't have the latest
versions of plugins and will become more and more out of date.

Peter

--
Peter Ledbrook
Grails Advocate
SpringSource - A Division of VMware

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Pluginreposity down?

JanSchumacher2
Thank you Peter :)

Am 03.08.12 16:12, schrieb Peter Ledbrook:
>> No i don't.
>> But it would be great if you do this. :)
> I have regenerated the list, but as I said it won't have the latest
> versions of plugins and will become more and more out of date.
>
> Peter
>


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: config.serverURL and redirects

Joe Greenawalt
In reply to this post by ideasculptor
well, the only reason i have it set is that the site will generate emails that will have links to back to the site of the official URL when its switched on.  I thought i was doing the right thing by setting that info there, but I guess, i can put that in a constants class.

Thanks for the help

Joe

On Fri, Aug 3, 2012 at 6:24 AM, Samuel Gendler <[hidden email]> wrote:
On Fri, Aug 3, 2012 at 1:28 AM, Ronny Løvtangen <[hidden email]> wrote:
Do you need grails.serverURL at all? We're doing fine by simply removing he property, then URLs are generated based on the request.

This.  I had exactly the problem you are having when I switched from 1.3.x to 2.0.x. Simply removing serverURL entirely fixed it (after much time wasted trying to debug just what the heck it was doing since response.sendRedirect() was being turned into an absolute url with the wrong hostname, which made no sense). Without a serverURL, it behaves as you'd expect it to in all cases, so far as I can tell.

--sam


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: config.serverURL and redirects

Joe Greenawalt
To answer Peter's question specifically.  

We have a site www.mysite.companyname.com that is being used by old site that is being replaced by by the grails app i'm talking about now.  I have several aliases being accepted at that site.  one being: www.mysite.companyname.com and another being prd.mysite.companyname.com.  I have grails.serverURL being set to www.mysite.companyname.com so that when we change DNS and point it to the new IP it willl just work.  But in the meantime i have the end users going to prd.mysite.companyname.com doing data cleanup and other migration work before we do the switch, and the customers can still go to old site.

On Fri, Aug 3, 2012 at 12:57 PM, Joe Greenawalt <[hidden email]> wrote:
well, the only reason i have it set is that the site will generate emails that will have links to back to the site of the official URL when its switched on.  I thought i was doing the right thing by setting that info there, but I guess, i can put that in a constants class.

Thanks for the help

Joe


On Fri, Aug 3, 2012 at 6:24 AM, Samuel Gendler <[hidden email]> wrote:
On Fri, Aug 3, 2012 at 1:28 AM, Ronny Løvtangen <[hidden email]> wrote:
Do you need grails.serverURL at all? We're doing fine by simply removing he property, then URLs are generated based on the request.

This.  I had exactly the problem you are having when I switched from 1.3.x to 2.0.x. Simply removing serverURL entirely fixed it (after much time wasted trying to debug just what the heck it was doing since response.sendRedirect() was being turned into an absolute url with the wrong hostname, which made no sense). Without a serverURL, it behaves as you'd expect it to in all cases, so far as I can tell.

--sam



Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: config.serverURL and redirects

Joe Greenawalt
For those that find or follow this if found the following here  http://pledbrook.github.com/grails-howtos/en/upgradeToGrails2.html :

Redirects

In order to allow code to modify the response after issuing a redirect, Grails had to bypass the standard Servlet sendRedirect() method. As a side-effect, the redirect() is now dependent on the grails.serverURL configuration setting. If this doesn't match the URL of your application, redirects will stop working.

The simplest way to avoid this problem is to remove the setting unless you need it. If you need it (usually for production deployments) then the value should already match the URL of your application. This mostly impacts development where old projects often have a legacy value that doesn't work.

Another side-effect is that you can no longer use the response.isCommitted() method to determine whether a redirect has taken place. Instead, there is a new request.isRedirected() method that you should use - note that the new method is on request rather thanresponse!


On Fri, Aug 3, 2012 at 1:04 PM, Joe Greenawalt <[hidden email]> wrote:
To answer Peter's question specifically.  

We have a site www.mysite.companyname.com that is being used by old site that is being replaced by by the grails app i'm talking about now.  I have several aliases being accepted at that site.  one being: www.mysite.companyname.com and another being prd.mysite.companyname.com.  I have grails.serverURL being set to www.mysite.companyname.com so that when we change DNS and point it to the new IP it willl just work.  But in the meantime i have the end users going to prd.mysite.companyname.com doing data cleanup and other migration work before we do the switch, and the customers can still go to old site.


On Fri, Aug 3, 2012 at 12:57 PM, Joe Greenawalt <[hidden email]> wrote:
well, the only reason i have it set is that the site will generate emails that will have links to back to the site of the official URL when its switched on.  I thought i was doing the right thing by setting that info there, but I guess, i can put that in a constants class.

Thanks for the help

Joe


On Fri, Aug 3, 2012 at 6:24 AM, Samuel Gendler <[hidden email]> wrote:
On Fri, Aug 3, 2012 at 1:28 AM, Ronny Løvtangen <[hidden email]> wrote:
Do you need grails.serverURL at all? We're doing fine by simply removing he property, then URLs are generated based on the request.

This.  I had exactly the problem you are having when I switched from 1.3.x to 2.0.x. Simply removing serverURL entirely fixed it (after much time wasted trying to debug just what the heck it was doing since response.sendRedirect() was being turned into an absolute url with the wrong hostname, which made no sense). Without a serverURL, it behaves as you'd expect it to in all cases, so far as I can tell.

--sam




Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: config.serverURL and redirects

Luis Muniz-2
Hi,

We use the scaffolded grails views as an administration interface, and we don't expose them on the apache web server, but we access them on the tomcat server via VPN. After upgrading to grails 2, whenever we try to use the administration interface, we are redirected to our public apache server.

This new redirection behaviour just breaks this.

If I remove the serverURL setting in Config.groovy aren't there other aspects of grails that may be affected? If yes, then this is not an acceptable workaround and we can't upgrade to grails 2.


On Wed, Aug 8, 2012 at 3:31 AM, Joe Greenawalt <[hidden email]> wrote:
For those that find or follow this if found the following here  http://pledbrook.github.com/grails-howtos/en/upgradeToGrails2.html :

Redirects

In order to allow code to modify the response after issuing a redirect, Grails had to bypass the standard Servlet sendRedirect() method. As a side-effect, the redirect() is now dependent on the grails.serverURL configuration setting. If this doesn't match the URL of your application, redirects will stop working.

The simplest way to avoid this problem is to remove the setting unless you need it. If you need it (usually for production deployments) then the value should already match the URL of your application. This mostly impacts development where old projects often have a legacy value that doesn't work.

Another side-effect is that you can no longer use the response.isCommitted() method to determine whether a redirect has taken place. Instead, there is a new request.isRedirected() method that you should use - note that the new method is on request rather thanresponse!


On Fri, Aug 3, 2012 at 1:04 PM, Joe Greenawalt <[hidden email]> wrote:
To answer Peter's question specifically.  

We have a site www.mysite.companyname.com that is being used by old site that is being replaced by by the grails app i'm talking about now.  I have several aliases being accepted at that site.  one being: www.mysite.companyname.com and another being prd.mysite.companyname.com.  I have grails.serverURL being set to www.mysite.companyname.com so that when we change DNS and point it to the new IP it willl just work.  But in the meantime i have the end users going to prd.mysite.companyname.com doing data cleanup and other migration work before we do the switch, and the customers can still go to old site.


On Fri, Aug 3, 2012 at 12:57 PM, Joe Greenawalt <[hidden email]> wrote:
well, the only reason i have it set is that the site will generate emails that will have links to back to the site of the official URL when its switched on.  I thought i was doing the right thing by setting that info there, but I guess, i can put that in a constants class.

Thanks for the help

Joe


On Fri, Aug 3, 2012 at 6:24 AM, Samuel Gendler <[hidden email]> wrote:
On Fri, Aug 3, 2012 at 1:28 AM, Ronny Løvtangen <[hidden email]> wrote:
Do you need grails.serverURL at all? We're doing fine by simply removing he property, then URLs are generated based on the request.

This.  I had exactly the problem you are having when I switched from 1.3.x to 2.0.x. Simply removing serverURL entirely fixed it (after much time wasted trying to debug just what the heck it was doing since response.sendRedirect() was being turned into an absolute url with the wrong hostname, which made no sense). Without a serverURL, it behaves as you'd expect it to in all cases, so far as I can tell.

--sam





Loading...