Singleton TopComponents are called twice

View: New views
8 Messages — Rating Filter:   Alert me  

Singleton TopComponents are called twice

by Dan Dubois-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi All,

I have a NetBeans 6.7 RC3 platform application. I registered some
listeners on an object in my TopComponent's constructor and realised
they were being registered twice.

I discovered this was because all my singleton TopComponents are
called twice during my platform application start up. Once via
reflection, and the second via the getDefault() boilerplate code that
NetBeans generates.

Is this normal behavior? I can't find anything about it on the web...

Best wishes,
Dan

Re: Singleton TopComponents are called twice

by Dan Dubois-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I should clarify; when I say my singleton TopComponents are being
called twice I mean two instances of each TopComponent are being
created through their public no argument constructors.

2009/6/19 Dan Dubois <uvicoxpz@...>:

> Hi All,
>
> I have a NetBeans 6.7 RC3 platform application. I registered some
> listeners on an object in my TopComponent's constructor and realised
> they were being registered twice.
>
> I discovered this was because all my singleton TopComponents are
> called twice during my platform application start up. Once via
> reflection, and the second via the getDefault() boilerplate code that
> NetBeans generates.
>
> Is this normal behavior? I can't find anything about it on the web...
>
> Best wishes,
> Dan
>

Re: Re: Singleton TopComponents are called twice

by tomwheel :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

If this is true, it is almost certainly a bug.  I tried, but failed,
to reproduce this in 6.7 RC3 based on what you said.  It's possible
that I overlooked some detail of what you did or that there is a bug
which only affects certain configurations.

As the very definition of Singleton implies, there should only be one
instance created.  If you've observed this on what is basically an
unmodified TopComponent as generated by the wizard, then please file a
bug report on it.

On Fri, Jun 19, 2009 at 12:34 PM, Dan Dubois<uvicoxpz@...> wrote:

> I should clarify; when I say my singleton TopComponents are being
> called twice I mean two instances of each TopComponent are being
> created through their public no argument constructors.
>
> 2009/6/19 Dan Dubois <uvicoxpz@...>:
>> Hi All,
>>
>> I have a NetBeans 6.7 RC3 platform application. I registered some
>> listeners on an object in my TopComponent's constructor and realised
>> they were being registered twice.
>>
>> I discovered this was because all my singleton TopComponents are
>> called twice during my platform application start up. Once via
>> reflection, and the second via the getDefault() boilerplate code that
>> NetBeans generates.
>>
>> Is this normal behavior? I can't find anything about it on the web...
>>
>> Best wishes,
>> Dan
>>
>



--
Tom Wheeler
http://www.tomwheeler.com/

Re: Re: Singleton TopComponents are called twice

by Dan Dubois-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thanks for the input.

I tried to use the TopComponent wizard for the first time in RC3 to
see if I get the same problems with a fresh TopComponent.
Unfortunately the wizard does not work and produces the following IDE
error after entering my new TopComponent's name and clicking next:

SEVERE [org.openide.util.RequestProcessor]: Error in RequestProcessor
org.openide.WizardDescriptor$Listener$2$1
java.lang.NoClassDefFoundError: javax/script/ScriptEngineFactory
        at java.lang.ClassLoader.defineClass1(Native Method)
       ...

I tried deleting the NB home directory ~/.netbeans/6.7rc3 but still
get the error. My application TopComponents were originally created
using the Beta version of NB 6.7.

Any ideas? Otherwise I suppose I will have to wait for a new NB
release before I can test.

Best wishes,
Dan


2009/6/19 Tom Wheeler <tomwheel@...>:

> If this is true, it is almost certainly a bug.  I tried, but failed,
> to reproduce this in 6.7 RC3 based on what you said.  It's possible
> that I overlooked some detail of what you did or that there is a bug
> which only affects certain configurations.
>
> As the very definition of Singleton implies, there should only be one
> instance created.  If you've observed this on what is basically an
> unmodified TopComponent as generated by the wizard, then please file a
> bug report on it.
>
> On Fri, Jun 19, 2009 at 12:34 PM, Dan Dubois<uvicoxpz@...> wrote:
>> I should clarify; when I say my singleton TopComponents are being
>> called twice I mean two instances of each TopComponent are being
>> created through their public no argument constructors.
>>
>> 2009/6/19 Dan Dubois <uvicoxpz@...>:
>>> Hi All,
>>>
>>> I have a NetBeans 6.7 RC3 platform application. I registered some
>>> listeners on an object in my TopComponent's constructor and realised
>>> they were being registered twice.
>>>
>>> I discovered this was because all my singleton TopComponents are
>>> called twice during my platform application start up. Once via
>>> reflection, and the second via the getDefault() boilerplate code that
>>> NetBeans generates.
>>>
>>> Is this normal behavior? I can't find anything about it on the web...
>>>
>>> Best wishes,
>>> Dan
>>>
>>
>
>
>
> --
> Tom Wheeler
> http://www.tomwheeler.com/
>

Re: Re: Singleton TopComponents are called twice

by Dan Dubois-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I have done some more investigating and found that the culprit is
possibly the @ConvertAsProperties annotation added to the top of each
TopComponent. It appears to be deserializing the component after it
has already been deserialized the normal way thus calling the
singleton TopComponent constructor twice.

I can reproduce the problem by cleaning my platform application build.
If I run the application the first time, my singleton TopComponents
only get their constructors called once which is what I would expect.
However, when I close and then rerun the application my singleton
TopComponents will each get their constructors called twice.

I can remedy this problem by removing the @ConvertAsProperties
annotation from my TopComponents, cleaning and rebuilding my
application.

Is this a bug? I have created
http://www.netbeans.org/issues/show_bug.cgi?id=167395 just in case.

Best wishes,
Dan

2009/6/19 Dan Dubois <uvicoxpz@...>:

> Thanks for the input.
>
> I tried to use the TopComponent wizard for the first time in RC3 to
> see if I get the same problems with a fresh TopComponent.
> Unfortunately the wizard does not work and produces the following IDE
> error after entering my new TopComponent's name and clicking next:
>
> SEVERE [org.openide.util.RequestProcessor]: Error in RequestProcessor
> org.openide.WizardDescriptor$Listener$2$1
> java.lang.NoClassDefFoundError: javax/script/ScriptEngineFactory
>        at java.lang.ClassLoader.defineClass1(Native Method)
>       ...
>
> I tried deleting the NB home directory ~/.netbeans/6.7rc3 but still
> get the error. My application TopComponents were originally created
> using the Beta version of NB 6.7.
>
> Any ideas? Otherwise I suppose I will have to wait for a new NB
> release before I can test.
>
> Best wishes,
> Dan
>
>
> 2009/6/19 Tom Wheeler <tomwheel@...>:
>> If this is true, it is almost certainly a bug.  I tried, but failed,
>> to reproduce this in 6.7 RC3 based on what you said.  It's possible
>> that I overlooked some detail of what you did or that there is a bug
>> which only affects certain configurations.
>>
>> As the very definition of Singleton implies, there should only be one
>> instance created.  If you've observed this on what is basically an
>> unmodified TopComponent as generated by the wizard, then please file a
>> bug report on it.
>>
>> On Fri, Jun 19, 2009 at 12:34 PM, Dan Dubois<uvicoxpz@...> wrote:
>>> I should clarify; when I say my singleton TopComponents are being
>>> called twice I mean two instances of each TopComponent are being
>>> created through their public no argument constructors.
>>>
>>> 2009/6/19 Dan Dubois <uvicoxpz@...>:
>>>> Hi All,
>>>>
>>>> I have a NetBeans 6.7 RC3 platform application. I registered some
>>>> listeners on an object in my TopComponent's constructor and realised
>>>> they were being registered twice.
>>>>
>>>> I discovered this was because all my singleton TopComponents are
>>>> called twice during my platform application start up. Once via
>>>> reflection, and the second via the getDefault() boilerplate code that
>>>> NetBeans generates.
>>>>
>>>> Is this normal behavior? I can't find anything about it on the web...
>>>>
>>>> Best wishes,
>>>> Dan
>>>>
>>>
>>
>>
>>
>> --
>> Tom Wheeler
>> http://www.tomwheeler.com/
>>
>

Re: Re: Singleton TopComponents are called twice

by Dan Dubois-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Dear All,

I have not heard anything since filing the singleton TopComponent
called twice because of @ConvertAsProperties bug report
(http://www.netbeans.org/issues/show_bug.cgi?id=167395). Just to
recap, the NetBeans 6.7 TopComponent wizard annotates new singleton
TopComponents with @ConvertAsProperties. Unfortunately it appears that
these singleton TopComponent constructors are now called twice: once
by the getDefault() method as you would expect and then by the no
argument constructor because @ConvertAsProperties needs to deserialze
it too. Has anyone else noticed this problem?

I also noticed that since removing the @ConvertAsProperties
annotations from my TopComponents to prevent this bug my TopComponents
are no longer displayed when I run my application after building it as
a ZIP. When I run it from within the NetBeans IDE it all works fine
though! Any ideas why?

Best wishes,
Dan

2009/6/19 Dan Dubois <uvicoxpz@...>:

> I have done some more investigating and found that the culprit is
> possibly the @ConvertAsProperties annotation added to the top of each
> TopComponent. It appears to be deserializing the component after it
> has already been deserialized the normal way thus calling the
> singleton TopComponent constructor twice.
>
> I can reproduce the problem by cleaning my platform application build.
> If I run the application the first time, my singleton TopComponents
> only get their constructors called once which is what I would expect.
> However, when I close and then rerun the application my singleton
> TopComponents will each get their constructors called twice.
>
> I can remedy this problem by removing the @ConvertAsProperties
> annotation from my TopComponents, cleaning and rebuilding my
> application.
>
> Is this a bug? I have created
> http://www.netbeans.org/issues/show_bug.cgi?id=167395 just in case.
>
> Best wishes,
> Dan
>
> 2009/6/19 Dan Dubois <uvicoxpz@...>:
>> Thanks for the input.
>>
>> I tried to use the TopComponent wizard for the first time in RC3 to
>> see if I get the same problems with a fresh TopComponent.
>> Unfortunately the wizard does not work and produces the following IDE
>> error after entering my new TopComponent's name and clicking next:
>>
>> SEVERE [org.openide.util.RequestProcessor]: Error in RequestProcessor
>> org.openide.WizardDescriptor$Listener$2$1
>> java.lang.NoClassDefFoundError: javax/script/ScriptEngineFactory
>>        at java.lang.ClassLoader.defineClass1(Native Method)
>>       ...
>>
>> I tried deleting the NB home directory ~/.netbeans/6.7rc3 but still
>> get the error. My application TopComponents were originally created
>> using the Beta version of NB 6.7.
>>
>> Any ideas? Otherwise I suppose I will have to wait for a new NB
>> release before I can test.
>>
>> Best wishes,
>> Dan
>>
>>
>> 2009/6/19 Tom Wheeler <tomwheel@...>:
>>> If this is true, it is almost certainly a bug.  I tried, but failed,
>>> to reproduce this in 6.7 RC3 based on what you said.  It's possible
>>> that I overlooked some detail of what you did or that there is a bug
>>> which only affects certain configurations.
>>>
>>> As the very definition of Singleton implies, there should only be one
>>> instance created.  If you've observed this on what is basically an
>>> unmodified TopComponent as generated by the wizard, then please file a
>>> bug report on it.
>>>
>>> On Fri, Jun 19, 2009 at 12:34 PM, Dan Dubois<uvicoxpz@...> wrote:
>>>> I should clarify; when I say my singleton TopComponents are being
>>>> called twice I mean two instances of each TopComponent are being
>>>> created through their public no argument constructors.
>>>>
>>>> 2009/6/19 Dan Dubois <uvicoxpz@...>:
>>>>> Hi All,
>>>>>
>>>>> I have a NetBeans 6.7 RC3 platform application. I registered some
>>>>> listeners on an object in my TopComponent's constructor and realised
>>>>> they were being registered twice.
>>>>>
>>>>> I discovered this was because all my singleton TopComponents are
>>>>> called twice during my platform application start up. Once via
>>>>> reflection, and the second via the getDefault() boilerplate code that
>>>>> NetBeans generates.
>>>>>
>>>>> Is this normal behavior? I can't find anything about it on the web...
>>>>>
>>>>> Best wishes,
>>>>> Dan
>>>>>
>>>>
>>>
>>>
>>>
>>> --
>>> Tom Wheeler
>>> http://www.tomwheeler.com/
>>>
>>
>

Re: Re: Singleton TopComponents are called twice

by bruehlicke :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I am listening with high interest to this thread - have not migrated
yet but it is planned mid July.

B-)

On Wed, Jul 1, 2009 at 10:44 AM, Dan Dubois<uvicoxpz@...> wrote:

> Dear All,
>
> I have not heard anything since filing the singleton TopComponent
> called twice because of @ConvertAsProperties bug report
> (http://www.netbeans.org/issues/show_bug.cgi?id=167395). Just to
> recap, the NetBeans 6.7 TopComponent wizard annotates new singleton
> TopComponents with @ConvertAsProperties. Unfortunately it appears that
> these singleton TopComponent constructors are now called twice: once
> by the getDefault() method as you would expect and then by the no
> argument constructor because @ConvertAsProperties needs to deserialze
> it too. Has anyone else noticed this problem?
>
> I also noticed that since removing the @ConvertAsProperties
> annotations from my TopComponents to prevent this bug my TopComponents
> are no longer displayed when I run my application after building it as
> a ZIP. When I run it from within the NetBeans IDE it all works fine
> though! Any ideas why?
>
> Best wishes,
> Dan
>
> 2009/6/19 Dan Dubois <uvicoxpz@...>:
>> I have done some more investigating and found that the culprit is
>> possibly the @ConvertAsProperties annotation added to the top of each
>> TopComponent. It appears to be deserializing the component after it
>> has already been deserialized the normal way thus calling the
>> singleton TopComponent constructor twice.
>>
>> I can reproduce the problem by cleaning my platform application build.
>> If I run the application the first time, my singleton TopComponents
>> only get their constructors called once which is what I would expect.
>> However, when I close and then rerun the application my singleton
>> TopComponents will each get their constructors called twice.
>>
>> I can remedy this problem by removing the @ConvertAsProperties
>> annotation from my TopComponents, cleaning and rebuilding my
>> application.
>>
>> Is this a bug? I have created
>> http://www.netbeans.org/issues/show_bug.cgi?id=167395 just in case.
>>
>> Best wishes,
>> Dan
>>
>> 2009/6/19 Dan Dubois <uvicoxpz@...>:
>>> Thanks for the input.
>>>
>>> I tried to use the TopComponent wizard for the first time in RC3 to
>>> see if I get the same problems with a fresh TopComponent.
>>> Unfortunately the wizard does not work and produces the following IDE
>>> error after entering my new TopComponent's name and clicking next:
>>>
>>> SEVERE [org.openide.util.RequestProcessor]: Error in RequestProcessor
>>> org.openide.WizardDescriptor$Listener$2$1
>>> java.lang.NoClassDefFoundError: javax/script/ScriptEngineFactory
>>>        at java.lang.ClassLoader.defineClass1(Native Method)
>>>       ...
>>>
>>> I tried deleting the NB home directory ~/.netbeans/6.7rc3 but still
>>> get the error. My application TopComponents were originally created
>>> using the Beta version of NB 6.7.
>>>
>>> Any ideas? Otherwise I suppose I will have to wait for a new NB
>>> release before I can test.
>>>
>>> Best wishes,
>>> Dan
>>>
>>>
>>> 2009/6/19 Tom Wheeler <tomwheel@...>:
>>>> If this is true, it is almost certainly a bug.  I tried, but failed,
>>>> to reproduce this in 6.7 RC3 based on what you said.  It's possible
>>>> that I overlooked some detail of what you did or that there is a bug
>>>> which only affects certain configurations.
>>>>
>>>> As the very definition of Singleton implies, there should only be one
>>>> instance created.  If you've observed this on what is basically an
>>>> unmodified TopComponent as generated by the wizard, then please file a
>>>> bug report on it.
>>>>
>>>> On Fri, Jun 19, 2009 at 12:34 PM, Dan Dubois<uvicoxpz@...> wrote:
>>>>> I should clarify; when I say my singleton TopComponents are being
>>>>> called twice I mean two instances of each TopComponent are being
>>>>> created through their public no argument constructors.
>>>>>
>>>>> 2009/6/19 Dan Dubois <uvicoxpz@...>:
>>>>>> Hi All,
>>>>>>
>>>>>> I have a NetBeans 6.7 RC3 platform application. I registered some
>>>>>> listeners on an object in my TopComponent's constructor and realised
>>>>>> they were being registered twice.
>>>>>>
>>>>>> I discovered this was because all my singleton TopComponents are
>>>>>> called twice during my platform application start up. Once via
>>>>>> reflection, and the second via the getDefault() boilerplate code that
>>>>>> NetBeans generates.
>>>>>>
>>>>>> Is this normal behavior? I can't find anything about it on the web...
>>>>>>
>>>>>> Best wishes,
>>>>>> Dan
>>>>>>
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> Tom Wheeler
>>>> http://www.tomwheeler.com/
>>>>
>>>
>>
>

Re: Re: Singleton TopComponents are called twice

by Dan Dubois-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi All,

I still haven't heard anything on this bug which in my opinion is a
big oversight with @ConvertAsProperties usage on TopComponents and it
has been a month since I first posted.

I hope all the NetBeans team haven't been made redundant pending the
Oracle merger. It is a fabulous product!

Best wishes,

Dan

2009/7/1 bruehlicke <bruehlicke@...>:

> I am listening with high interest to this thread - have not migrated
> yet but it is planned mid July.
>
> B-)
>
> On Wed, Jul 1, 2009 at 10:44 AM, Dan Dubois<uvicoxpz@...> wrote:
>> Dear All,
>>
>> I have not heard anything since filing the singleton TopComponent
>> called twice because of @ConvertAsProperties bug report
>> (http://www.netbeans.org/issues/show_bug.cgi?id=167395). Just to
>> recap, the NetBeans 6.7 TopComponent wizard annotates new singleton
>> TopComponents with @ConvertAsProperties. Unfortunately it appears that
>> these singleton TopComponent constructors are now called twice: once
>> by the getDefault() method as you would expect and then by the no
>> argument constructor because @ConvertAsProperties needs to deserialze
>> it too. Has anyone else noticed this problem?
>>
>> I also noticed that since removing the @ConvertAsProperties
>> annotations from my TopComponents to prevent this bug my TopComponents
>> are no longer displayed when I run my application after building it as
>> a ZIP. When I run it from within the NetBeans IDE it all works fine
>> though! Any ideas why?
>>
>> Best wishes,
>> Dan
>>
>> 2009/6/19 Dan Dubois <uvicoxpz@...>:
>>> I have done some more investigating and found that the culprit is
>>> possibly the @ConvertAsProperties annotation added to the top of each
>>> TopComponent. It appears to be deserializing the component after it
>>> has already been deserialized the normal way thus calling the
>>> singleton TopComponent constructor twice.
>>>
>>> I can reproduce the problem by cleaning my platform application build.
>>> If I run the application the first time, my singleton TopComponents
>>> only get their constructors called once which is what I would expect.
>>> However, when I close and then rerun the application my singleton
>>> TopComponents will each get their constructors called twice.
>>>
>>> I can remedy this problem by removing the @ConvertAsProperties
>>> annotation from my TopComponents, cleaning and rebuilding my
>>> application.
>>>
>>> Is this a bug? I have created
>>> http://www.netbeans.org/issues/show_bug.cgi?id=167395 just in case.
>>>
>>> Best wishes,
>>> Dan
>>>
>>> 2009/6/19 Dan Dubois <uvicoxpz@...>:
>>>> Thanks for the input.
>>>>
>>>> I tried to use the TopComponent wizard for the first time in RC3 to
>>>> see if I get the same problems with a fresh TopComponent.
>>>> Unfortunately the wizard does not work and produces the following IDE
>>>> error after entering my new TopComponent's name and clicking next:
>>>>
>>>> SEVERE [org.openide.util.RequestProcessor]: Error in RequestProcessor
>>>> org.openide.WizardDescriptor$Listener$2$1
>>>> java.lang.NoClassDefFoundError: javax/script/ScriptEngineFactory
>>>>        at java.lang.ClassLoader.defineClass1(Native Method)
>>>>       ...
>>>>
>>>> I tried deleting the NB home directory ~/.netbeans/6.7rc3 but still
>>>> get the error. My application TopComponents were originally created
>>>> using the Beta version of NB 6.7.
>>>>
>>>> Any ideas? Otherwise I suppose I will have to wait for a new NB
>>>> release before I can test.
>>>>
>>>> Best wishes,
>>>> Dan
>>>>
>>>>
>>>> 2009/6/19 Tom Wheeler <tomwheel@...>:
>>>>> If this is true, it is almost certainly a bug.  I tried, but failed,
>>>>> to reproduce this in 6.7 RC3 based on what you said.  It's possible
>>>>> that I overlooked some detail of what you did or that there is a bug
>>>>> which only affects certain configurations.
>>>>>
>>>>> As the very definition of Singleton implies, there should only be one
>>>>> instance created.  If you've observed this on what is basically an
>>>>> unmodified TopComponent as generated by the wizard, then please file a
>>>>> bug report on it.
>>>>>
>>>>> On Fri, Jun 19, 2009 at 12:34 PM, Dan Dubois<uvicoxpz@...> wrote:
>>>>>> I should clarify; when I say my singleton TopComponents are being
>>>>>> called twice I mean two instances of each TopComponent are being
>>>>>> created through their public no argument constructors.
>>>>>>
>>>>>> 2009/6/19 Dan Dubois <uvicoxpz@...>:
>>>>>>> Hi All,
>>>>>>>
>>>>>>> I have a NetBeans 6.7 RC3 platform application. I registered some
>>>>>>> listeners on an object in my TopComponent's constructor and realised
>>>>>>> they were being registered twice.
>>>>>>>
>>>>>>> I discovered this was because all my singleton TopComponents are
>>>>>>> called twice during my platform application start up. Once via
>>>>>>> reflection, and the second via the getDefault() boilerplate code that
>>>>>>> NetBeans generates.
>>>>>>>
>>>>>>> Is this normal behavior? I can't find anything about it on the web...
>>>>>>>
>>>>>>> Best wishes,
>>>>>>> Dan
>>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> Tom Wheeler
>>>>> http://www.tomwheeler.com/
>>>>>
>>>>
>>>
>>
>