You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Carl Fyffe <st...@sixty4bit.com> on 2003/04/30 04:06:56 UTC

RE: Config Frozen

The exception that I am getting:

Configuration is frozen
 at
org.apache.struts.config.ForwardConfig.setRedirect(ForwardConfig.java:22
5)
 ....

My understanding was that the configuration was only frozen at startup.
So, why am I getting this at runtime when I call
actionForward.setRedirect(true)?

Carl


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


RE: Config Frozen

Posted by "Craig R. McClanahan" <cr...@apache.org>.

On Tue, 29 Apr 2003, Carl Fyffe wrote:

> Date: Tue, 29 Apr 2003 22:06:56 -0400
> From: Carl Fyffe <st...@sixty4bit.com>
> Reply-To: Struts Users Mailing List <st...@jakarta.apache.org>
> To: 'Struts Users Mailing List' <st...@jakarta.apache.org>
> Subject: RE: Config Frozen
>
>
> The exception that I am getting:
>
> Configuration is frozen
>  at
> org.apache.struts.config.ForwardConfig.setRedirect(ForwardConfig.java:22
> 5)
>  ....
>
> My understanding was that the configuration was only frozen at startup.
> So, why am I getting this at runtime when I call
> actionForward.setRedirect(true)?
>

Because you are trying to modify a property of one of the frozen
configuration objects (the ActionFormward instance).  That is what
"frozen configuration" means -- once Struts has loaded the configuration
file (and processed all your plugin startups), it freezes the
configuration information, which disallows any subsequent changes.

You configure whether redirect is true or not in the <forward> element in
your struts-config.xml file.  If you need to redirect or forward to the
same URL conditionally, you should create two different forwards and pick
the right one programmatically.

> Carl

Craig

---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


RE: Config Frozen

Posted by Carl Fyffe <st...@sixty4bit.com>.
Yes, I was just beating the dead horse....  Your suggestion about
setting it in struts-config.xml is what I was looking for :)  Thanks.

-----Original Message-----
From: James Mitchell [mailto:jmitchell@apache.org] 
Sent: Tuesday, April 29, 2003 10:30 PM
To: Struts Users Mailing List
Subject: Re: Config Frozen


On Tuesday 29 April 2003 10:27 pm, Carl Fyffe wrote:
> Just for confirmation...  If I try to set redirect when I do 
> mapping.findForward("view"), Struts will throw a 
> IllegalStateException. But,  forward = new 
> ActionForward("/SomeLink.do").setRedirect(true) is "legal"?

Have you tried that?

>
> -----Original Message-----
> From: James Mitchell [mailto:jmitchell@apache.org]
> Sent: Tuesday, April 29, 2003 10:18 PM
> To: Struts Users Mailing List
> Subject: Re: Config Frozen
>
> On Tuesday 29 April 2003 10:06 pm, Carl Fyffe wrote:
> > The exception that I am getting:
> >
> > Configuration is frozen
> >  at
> > org.apache.struts.config.ForwardConfig.setRedirect(ForwardConfig.jav
> > a:
> > 22
> > 5)
> >  ....
> >
> > My understanding was that the configuration was only frozen at 
> > startup. So, why am I getting this at runtime when I call 
> > actionForward.setRedirect(true)?
>
> That behaviour is correct.  You are trying to modify configuration 
> fields after it was (loaded and) frozen.
>
> If you want a specific forward to be a redirect, set it that way in 
> the struts-config.xml.
>
> You won't be able to dynamically change a forward vs. a redirect, but 
> that won't stop you from using it as you like in your action.
>
> > Carl

-- 
James Mitchell
Software Developer/Struts Evangelist
http://www.open-tools.org




---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


RE: Config Frozen

Posted by Andrew Hill <an...@gridnode.com>.
ActionForward foward = mapping.findForward("view");
if(forward == null) throw new NullPointerException("missing view forward");
forward = new ActionForward( forward.getPath(), true );

is how I would do it...

-----Original Message-----
From: James Mitchell [mailto:jmitchell@apache.org]
Sent: Wednesday, 30 April 2003 10:30
To: Struts Users Mailing List
Subject: Re: Config Frozen


On Tuesday 29 April 2003 10:27 pm, Carl Fyffe wrote:
> Just for confirmation...  If I try to set redirect when I do
> mapping.findForward("view"), Struts will throw a IllegalStateException.
> But,  forward = new ActionForward("/SomeLink.do").setRedirect(true) is
> "legal"?

Have you tried that?

>
> -----Original Message-----
> From: James Mitchell [mailto:jmitchell@apache.org]
> Sent: Tuesday, April 29, 2003 10:18 PM
> To: Struts Users Mailing List
> Subject: Re: Config Frozen
>
> On Tuesday 29 April 2003 10:06 pm, Carl Fyffe wrote:
> > The exception that I am getting:
> >
> > Configuration is frozen
> >  at
> > org.apache.struts.config.ForwardConfig.setRedirect(ForwardConfig.java:
> > 22
> > 5)
> >  ....
> >
> > My understanding was that the configuration was only frozen at
> > startup. So, why am I getting this at runtime when I call
> > actionForward.setRedirect(true)?
>
> That behaviour is correct.  You are trying to modify configuration
> fields
> after it was (loaded and) frozen.
>
> If you want a specific forward to be a redirect, set it that way in the
> struts-config.xml.
>
> You won't be able to dynamically change a forward vs. a redirect, but
> that
> won't stop you from using it as you like in your action.
>
> > Carl

-- 
James Mitchell
Software Developer/Struts Evangelist
http://www.open-tools.org




---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: Config Frozen

Posted by James Mitchell <jm...@apache.org>.
On Tuesday 29 April 2003 10:27 pm, Carl Fyffe wrote:
> Just for confirmation...  If I try to set redirect when I do
> mapping.findForward("view"), Struts will throw a IllegalStateException.
> But,  forward = new ActionForward("/SomeLink.do").setRedirect(true) is
> "legal"?

Have you tried that?

>
> -----Original Message-----
> From: James Mitchell [mailto:jmitchell@apache.org]
> Sent: Tuesday, April 29, 2003 10:18 PM
> To: Struts Users Mailing List
> Subject: Re: Config Frozen
>
> On Tuesday 29 April 2003 10:06 pm, Carl Fyffe wrote:
> > The exception that I am getting:
> >
> > Configuration is frozen
> >  at
> > org.apache.struts.config.ForwardConfig.setRedirect(ForwardConfig.java:
> > 22
> > 5)
> >  ....
> >
> > My understanding was that the configuration was only frozen at
> > startup. So, why am I getting this at runtime when I call
> > actionForward.setRedirect(true)?
>
> That behaviour is correct.  You are trying to modify configuration
> fields
> after it was (loaded and) frozen.
>
> If you want a specific forward to be a redirect, set it that way in the
> struts-config.xml.
>
> You won't be able to dynamically change a forward vs. a redirect, but
> that
> won't stop you from using it as you like in your action.
>
> > Carl

-- 
James Mitchell
Software Developer/Struts Evangelist
http://www.open-tools.org




---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


RE: Config Frozen

Posted by "Craig R. McClanahan" <cr...@apache.org>.

On Tue, 29 Apr 2003, Carl Fyffe wrote:

> Date: Tue, 29 Apr 2003 22:27:52 -0400
> From: Carl Fyffe <st...@sixty4bit.com>
> Reply-To: Struts Users Mailing List <st...@jakarta.apache.org>
> To: 'Struts Users Mailing List' <st...@jakarta.apache.org>
> Subject: RE: Config Frozen
>
> Just for confirmation...  If I try to set redirect when I do
> mapping.findForward("view"), Struts will throw a IllegalStateException.
> But,  forward = new ActionForward("/SomeLink.do").setRedirect(true) is
> "legal"?
>

Yes it is legal, because your newly constructed ActionForward instance is
not part of the tree of configuration beans.  It will be thrown away
after the controller uses it.

Your code would be clearer, however, if you used the two-args constructor:

  forward = new ActionForward("/SomeLink.do", true);

Craig

---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


RE: Config Frozen

Posted by Carl Fyffe <st...@sixty4bit.com>.
Just for confirmation...  If I try to set redirect when I do
mapping.findForward("view"), Struts will throw a IllegalStateException.
But,  forward = new ActionForward("/SomeLink.do").setRedirect(true) is
"legal"?

-----Original Message-----
From: James Mitchell [mailto:jmitchell@apache.org] 
Sent: Tuesday, April 29, 2003 10:18 PM
To: Struts Users Mailing List
Subject: Re: Config Frozen


On Tuesday 29 April 2003 10:06 pm, Carl Fyffe wrote:
> The exception that I am getting:
>
> Configuration is frozen
>  at 
> org.apache.struts.config.ForwardConfig.setRedirect(ForwardConfig.java:
> 22
> 5)
>  ....
>
> My understanding was that the configuration was only frozen at 
> startup. So, why am I getting this at runtime when I call 
> actionForward.setRedirect(true)?

That behaviour is correct.  You are trying to modify configuration
fields 
after it was (loaded and) frozen.

If you want a specific forward to be a redirect, set it that way in the 
struts-config.xml.

You won't be able to dynamically change a forward vs. a redirect, but
that 
won't stop you from using it as you like in your action.


>
> Carl
>


-- 
James Mitchell
Software Developer/Struts Evangelist
http://www.open-tools.org




---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: Config Frozen

Posted by James Mitchell <jm...@apache.org>.
On Tuesday 29 April 2003 10:06 pm, Carl Fyffe wrote:
> The exception that I am getting:
>
> Configuration is frozen
>  at
> org.apache.struts.config.ForwardConfig.setRedirect(ForwardConfig.java:22
> 5)
>  ....
>
> My understanding was that the configuration was only frozen at startup.
> So, why am I getting this at runtime when I call
> actionForward.setRedirect(true)?

That behaviour is correct.  You are trying to modify configuration fields 
after it was (loaded and) frozen.

If you want a specific forward to be a redirect, set it that way in the 
struts-config.xml.

You won't be able to dynamically change a forward vs. a redirect, but that 
won't stop you from using it as you like in your action.


>
> Carl
>


-- 
James Mitchell
Software Developer/Struts Evangelist
http://www.open-tools.org




---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org