开发者

Two instantiations of the managed-bean

开发者 https://www.devze.com 2023-03-29 15:45 出处:网络
When I access 开发者_StackOverflow中文版to my page for the fist time, the managed bean used by the page is instantiate two times (I pass two times in the contructor, with the same stack trace) :

When I access 开发者_StackOverflow中文版to my page for the fist time, the managed bean used by the page is instantiate two times (I pass two times in the contructor, with the same stack trace) :

Daemon Thread [http-127.0.0.1-8080-1] (Suspended (breakpoint at line 76 in MyController))   
    MyController.<init>() line: 76  
    NativeConstructorAccessorImpl.newInstance0(Constructor, Object[]) line: not available [native method]   
    NativeConstructorAccessorImpl.newInstance(Object[]) line: 39    
    DelegatingConstructorAccessorImpl.newInstance(Object[]) line: 27    
    Constructor<T>.newInstance(Object...) line: 513 
    Class<T>.newInstance0() line: 355   
    Class<T>.newInstance() line: 308    
    ManagedBeanBuilder(BeanBuilder).newBeanInstance() line: 186 
    ...
    pass throught two Filters (one of the filter uses Waffle and the other calls a web service...)  
    ...     
    Http11Protocol$Http11ConnectionHandler.process(Socket) line: 601    
    JIoEndpoint$Worker.run() line: 447  
    Thread.run() line: 662  

In the xhtml :

<a4j:keepAlive beanName="myController"></a4j:keepAlive>
<h:form>
...
</h:form>

In the faces-config.xml :

<managed-bean>
        <managed-bean-name>myController</managed-bean-name>
        <managed-bean-class>com.xx.MyController</managed-bean-class>
        <managed-bean-scope>request</managed-bean-scope>
</managed-bean>

Why does the managed bean is instanciate two times ?

Thank you for your ideas...

Using

  • jsf 1.2
  • richfaces 3.3.2.SR1

Edit: Thanks to Joeri Hendrickx, I found out that I have two differents request. So the new question is "why have I two requests when I access to my page?"


If you get two instances of a request-scoped bean, that should mean you have two requests.

Check if your browser is sending out two requests (use firebug or fiddler). If it's sending out only one, that means your request is duplicated somewhere in the stack (porbably in a filter, or maybe even in a custom servlet).

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号