You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Hermod Opstvedt <he...@opstvedt.com> on 2006/03/30 23:55:53 UTC

[Shale] Backingbean beeing created twice

Hi

I am seeing some odd behaviour in my Shale/Clay application. My backingbean
(ie ViewController) is being created twice, meaning I have 2 instances of
it. I was wondering if this is expected behaviour or if this is a bug. From
the stacktrace:

ResultatPage.<init>() line: 71
NativeConstructorAccessorImpl.newInstance0(Constructor, Object[]) line: not
available [native method]
NativeConstructorAccessorImpl.newInstance(Object[]) line: 39
DelegatingConstructorAccessorImpl.newInstance(Object[]) line: 27
Constructor<T>.newInstance(Object...) line: 494
Class<T>.newInstance0() line: 350
Class<T>.newInstance() line: 303
ClassUtils.newInstance(Class) line: 274
ClassUtils.newInstance(String) line: 265
ManagedBeanBuilder.buildManagedBean(FacesContext, ManagedBean) line: 49
VariableResolverImpl.resolveVariable(FacesContext, String) line: 311
ShaleVariableResolver.resolveVariable(FacesContext, String) line: 152
DelegatingVariableResolver.resolveVariable(FacesContext, String) line: 110
WebApplicationContextVariableResolver.resolveVariable(FacesContext, String)
line: 87
ViewViewHandler.setupViewController(FacesContext, UIViewRoot, String,
boolean) line: 233
ViewViewHandler.restoreView(FacesContext, String) line: 160
...


Hermod


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


Re: [Shale] Backingbean beeing created twice

Posted by Craig McClanahan <cr...@apache.org>.
On 3/30/06, Hermod Opstvedt <he...@opstvedt.com> wrote:
>
> Hi
>
> I am seeing some odd behaviour in my Shale/Clay application. My
> backingbean
> (ie ViewController) is being created twice, meaning I have 2 instances of
> it. I was wondering if this is expected behaviour or if this is a bug.
> From
> the stacktrace:


How are you locating these two instances?  Printing stuff in the
constructor?  I don't see how you could ever end up with two request scope
instances under one name.

ResultatPage.<init>() line: 71
> NativeConstructorAccessorImpl.newInstance0(Constructor, Object[]) line:
> not
> available [native method]


This exception implies that the constructor threw an exception, which would
cause the managed bean creation to fail, so no instance would ever get
installed in scope.  Every time an expression containing this managed bean
name is evaluated, it will see "aha, there's no bean yet, so try to create
one" -- and, I would assume, every attempt will fail.  But its not
surprising to see multiple attempts if your constructor is throwing
exceptions.

If the bean is a view controller, try moving the setup logic to the init()
method instead of the constructor.  Even if an exception is still thrown,
the initial attempt to create the bean will succeed, so you won't get
multiple failed instantiation attempts.

Craig

NativeConstructorAccessorImpl.newInstance(Object[]) line: 39
> DelegatingConstructorAccessorImpl.newInstance(Object[]) line: 27
> Constructor<T>.newInstance(Object...) line: 494
> Class<T>.newInstance0() line: 350
> Class<T>.newInstance() line: 303
> ClassUtils.newInstance(Class) line: 274
> ClassUtils.newInstance(String) line: 265
> ManagedBeanBuilder.buildManagedBean(FacesContext, ManagedBean) line: 49
> VariableResolverImpl.resolveVariable(FacesContext, String) line: 311
> ShaleVariableResolver.resolveVariable(FacesContext, String) line: 152
> DelegatingVariableResolver.resolveVariable(FacesContext, String) line: 110
> WebApplicationContextVariableResolver.resolveVariable(FacesContext,
> String)
> line: 87
> ViewViewHandler.setupViewController(FacesContext, UIViewRoot, String,
> boolean) line: 233
> ViewViewHandler.restoreView(FacesContext, String) line: 160
> ...
>
>
> Hermod
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

SV: [Shale] Backingbean beeing created twice

Posted by Hermod Opstvedt <he...@opstvedt.com>.
Hi

To further augment that, I also noticed that my QueryObject (as taken from
the rolodex example) is fully populated the for the first object, but not
for the second.

Med vennlig hilsen
Hermod Opstvedt
Webmaster
Seiling.org/Norlys.org


-----Opprinnelig melding-----
Fra: Hermod Opstvedt [mailto:hermod@opstvedt.com] 
Sendt: 30. mars 2006 23:56
Til: 'Struts Users Mailing List'
Emne: [Shale] Backingbean beeing created twice

Hi

I am seeing some odd behaviour in my Shale/Clay application. My backingbean
(ie ViewController) is being created twice, meaning I have 2 instances of
it. I was wondering if this is expected behaviour or if this is a bug. From
the stacktrace:

ResultatPage.<init>() line: 71
NativeConstructorAccessorImpl.newInstance0(Constructor, Object[]) line: not
available [native method]
NativeConstructorAccessorImpl.newInstance(Object[]) line: 39
DelegatingConstructorAccessorImpl.newInstance(Object[]) line: 27
Constructor<T>.newInstance(Object...) line: 494
Class<T>.newInstance0() line: 350
Class<T>.newInstance() line: 303
ClassUtils.newInstance(Class) line: 274
ClassUtils.newInstance(String) line: 265
ManagedBeanBuilder.buildManagedBean(FacesContext, ManagedBean) line: 49
VariableResolverImpl.resolveVariable(FacesContext, String) line: 311
ShaleVariableResolver.resolveVariable(FacesContext, String) line: 152
DelegatingVariableResolver.resolveVariable(FacesContext, String) line: 110
WebApplicationContextVariableResolver.resolveVariable(FacesContext, String)
line: 87
ViewViewHandler.setupViewController(FacesContext, UIViewRoot, String,
boolean) line: 233
ViewViewHandler.restoreView(FacesContext, String) line: 160
...


Hermod


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


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