You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by "Zeti (JIRA)" <ji...@apache.org> on 2010/11/28 17:45:38 UTC

[jira] Created: (WICKET-3204) Singleton bean is reinstantiated by wicket

Singleton bean is reinstantiated by wicket
------------------------------------------

                 Key: WICKET-3204
                 URL: https://issues.apache.org/jira/browse/WICKET-3204
             Project: Wicket
          Issue Type: Bug
          Components: wicket-spring
    Affects Versions: 1.4.13
            Reporter: Zeti


My bean declared as @Scope(value = "singleton") is reinstantiated before injection. This includes the symptom, that its session factory was null.
After a two hour debugging session with pertl (Thanks!) we found the following workaround:
Use
new SpringComponentInjector(this, WebApplicationContextUtils.getRequiredWebApplicationContext(this.getServletContext()), false)
instead of
new SpringComponentInjector(this)
as recommended in the [Wiki|https://cwiki.apache.org/WICKET/spring.html].

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (WICKET-3204) Singleton bean is reinstantiated by wicket

Posted by "Zeti (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/WICKET-3204?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Zeti updated WICKET-3204:
-------------------------

    Description: 
My bean declared as @Scope(value = "singleton") is reinstantiated before injection. This includes the symptom, that its session factory was null.
After a two hour debugging session with pertl (Thanks!) we found the following workaround:
Use
new SpringComponentInjector(this, WebApplicationContextUtils.getRequiredWebApplicationContext(this.getServletContext()), false)
instead of
new SpringComponentInjector(this)
as recommended in the Wiki: https://cwiki.apache.org/WICKET/spring.html

  was:
My bean declared as @Scope(value = "singleton") is reinstantiated before injection. This includes the symptom, that its session factory was null.
After a two hour debugging session with pertl (Thanks!) we found the following workaround:
Use
new SpringComponentInjector(this, WebApplicationContextUtils.getRequiredWebApplicationContext(this.getServletContext()), false)
instead of
new SpringComponentInjector(this)
as recommended in the [Wiki|https://cwiki.apache.org/WICKET/spring.html].


> Singleton bean is reinstantiated by wicket
> ------------------------------------------
>
>                 Key: WICKET-3204
>                 URL: https://issues.apache.org/jira/browse/WICKET-3204
>             Project: Wicket
>          Issue Type: Bug
>          Components: wicket-spring
>    Affects Versions: 1.4.13
>            Reporter: Zeti
>
> My bean declared as @Scope(value = "singleton") is reinstantiated before injection. This includes the symptom, that its session factory was null.
> After a two hour debugging session with pertl (Thanks!) we found the following workaround:
> Use
> new SpringComponentInjector(this, WebApplicationContextUtils.getRequiredWebApplicationContext(this.getServletContext()), false)
> instead of
> new SpringComponentInjector(this)
> as recommended in the Wiki: https://cwiki.apache.org/WICKET/spring.html

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (WICKET-3204) Singleton bean is reinstantiated by wicket

Posted by "Zeti (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WICKET-3204?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12964937#action_12964937 ] 

Zeti commented on WICKET-3204:
------------------------------

Ok I found the proper solution!
You have to use Interface backed beans, what I didn't do. Before also @Transactional was not detected as well. Not it functions as well as @Scope with the approach recommended in the wiki. 
It's still strange that using the implementations directly (as in the quickstart) results in these strange symptoms.

> Singleton bean is reinstantiated by wicket
> ------------------------------------------
>
>                 Key: WICKET-3204
>                 URL: https://issues.apache.org/jira/browse/WICKET-3204
>             Project: Wicket
>          Issue Type: Bug
>          Components: wicket-spring
>    Affects Versions: 1.4.13
>            Reporter: Zeti
>            Assignee: Igor Vaynberg
>         Attachments: wicket3204.zip
>
>
> My bean declared as @Scope(value = "singleton") is reinstantiated before injection. This includes the symptom, that its session factory was null.
> After a two hour debugging session with pertl (Thanks!) we found the following workaround:
> Use
> new SpringComponentInjector(this, WebApplicationContextUtils.getRequiredWebApplicationContext(this.getServletContext()), false)
> instead of
> new SpringComponentInjector(this)
> as recommended in the Wiki: https://cwiki.apache.org/WICKET/spring.html

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (WICKET-3204) Singleton bean is reinstantiated by wicket

Posted by "Zeti (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/WICKET-3204?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Zeti updated WICKET-3204:
-------------------------

    Attachment: wicket3204.zip

> Singleton bean is reinstantiated by wicket
> ------------------------------------------
>
>                 Key: WICKET-3204
>                 URL: https://issues.apache.org/jira/browse/WICKET-3204
>             Project: Wicket
>          Issue Type: Bug
>          Components: wicket-spring
>    Affects Versions: 1.4.13
>            Reporter: Zeti
>         Attachments: wicket3204.zip
>
>
> My bean declared as @Scope(value = "singleton") is reinstantiated before injection. This includes the symptom, that its session factory was null.
> After a two hour debugging session with pertl (Thanks!) we found the following workaround:
> Use
> new SpringComponentInjector(this, WebApplicationContextUtils.getRequiredWebApplicationContext(this.getServletContext()), false)
> instead of
> new SpringComponentInjector(this)
> as recommended in the Wiki: https://cwiki.apache.org/WICKET/spring.html

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (WICKET-3204) Singleton bean is reinstantiated by wicket

Posted by "Igor Vaynberg (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/WICKET-3204?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Igor Vaynberg resolved WICKET-3204.
-----------------------------------

    Resolution: Invalid
      Assignee: Igor Vaynberg

the second instance is created because wicket asks cglib to create a proxy for the bean. cglib generates a subclass for the bean, but this subclass is bound by the same rules as any java class and calls the default constructor - which increments the count. the count will be incremented any time a cglib proxy is generated for the bean, whether it is done by wicket, spring, or anything else.

this is the expected behavior and method calls on the proxy will always go back to the correct singleton's instance. constructor invocations are not a good place to measure instance counts when using proxies.

> Singleton bean is reinstantiated by wicket
> ------------------------------------------
>
>                 Key: WICKET-3204
>                 URL: https://issues.apache.org/jira/browse/WICKET-3204
>             Project: Wicket
>          Issue Type: Bug
>          Components: wicket-spring
>    Affects Versions: 1.4.13
>            Reporter: Zeti
>            Assignee: Igor Vaynberg
>         Attachments: wicket3204.zip
>
>
> My bean declared as @Scope(value = "singleton") is reinstantiated before injection. This includes the symptom, that its session factory was null.
> After a two hour debugging session with pertl (Thanks!) we found the following workaround:
> Use
> new SpringComponentInjector(this, WebApplicationContextUtils.getRequiredWebApplicationContext(this.getServletContext()), false)
> instead of
> new SpringComponentInjector(this)
> as recommended in the Wiki: https://cwiki.apache.org/WICKET/spring.html

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.