Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » Questions concerning @PreDestroy and @PreSave(annotated methods are called at unexpected moments)
Questions concerning @PreDestroy and @PreSave [message #870112] Sun, 06 May 2012 16:09 Go to next message
Heike Winkelvoß is currently offline Heike Winkelvoß
Messages: 11
Registered: April 2012
Junior Member
Hi,

I've got some questions concerning the part an application lifecycles:

Setting:

as described in several e4-tutorials in one of my parts I wrote a method which I expected to be called on application shutdown:

@Inject
@PreDestroy
public void dispose(ISpielSessionService pSpielSessionService){
pSpielSessionService.shutDown(null);
if (LOG.isDebugEnabled()){
LOG.debug("after calling shutDown");
}
}

I've got an ApplicationLifeCycleHandler:

plugin.xml:

<property
name="lifeCycleURI"
value="bundleclass://de.egladil.mcmatheraetsel.e4.app/de.egladil.mcmatheraetsel.e4.app.handlers.ApplicationLifeCycleHandler">
</property>

In the ApplicationLifeCycleHandler I annotated a method with @PreSave which I also expected to be called on application shutdown.

Here are my questions:

1) both methods are only called, when I add an additional @Inject annotation, i.e. without something to be injected the methods are not called at all. That seems strange.

2) the @PreDestroy- method in the part is called twice: first at application startup (=strange), a second time at application shutdown (what is the expected moment)

3) the @PreSave method in the ApplicationLifeCycleHandler is only called on application start (=strange) but not when I close the application wit a QuitHandler or by merely closing the application window.


Maybe that this behaviour is caused by the following framework exceptions that I ignored up to now because they address the PreferenceStore that I do not use up to now.

Maybe somebody knows how to get rid of these exceptions?


Heike



!ENTRY org.eclipse.e4.ui.workbench 2 0 2012-05-06 17:55:57.043
!MESSAGE Could not run processor
!STACK 0
org.eclipse.e4.core.di.InjectionException: org.eclipse.core.runtime.AssertionFailedException: null argument:
at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:63)
at org.eclipse.e4.core.internal.di.InjectorImpl.invokeUsingClass(InjectorImpl.java:229)
at org.eclipse.e4.core.internal.di.InjectorImpl.invoke(InjectorImpl.java:206)
at org.eclipse.e4.core.contexts.ContextInjectionFactory.invoke(ContextInjectionFactory.java:106)
at org.eclipse.e4.ui.internal.workbench.ModelAssembler.runProcessor(ModelAssembler.java:226)
at org.eclipse.e4.ui.internal.workbench.ModelAssembler.processModel(ModelAssembler.java:88)
at org.eclipse.e4.ui.internal.workbench.ResourceHandler.loadMostRecentModel(ResourceHandler.java:246)
at org.eclipse.e4.ui.internal.workbench.swt.E4Application.loadApplicationModel(E4Application.java:359)
at org.eclipse.e4.ui.internal.workbench.swt.E4Application.createE4Workbench(E4Application.java:217)
at org.eclipse.e4.ui.internal.workbench.swt.E4Application.start(E4Application.java:129)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:353)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:180)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:559)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:514)
at org.eclipse.equinox.launcher.Main.run(Main.java:1311)
at org.eclipse.equinox.launcher.Main.main(Main.java:1287)
Caused by: org.eclipse.core.runtime.AssertionFailedException: null argument:
at org.eclipse.core.runtime.Assert.isNotNull(Assert.java:85)
at org.eclipse.core.runtime.Assert.isNotNull(Assert.java:73)
at org.eclipse.ui.internal.util.PrefUtil.getAPIPreferenceStore(PrefUtil.java:70)
at org.eclipse.ui.PlatformUI.getPreferenceStore(PlatformUI.java:187)
at org.eclipse.ui.internal.keys.BindingPersistence.readActiveScheme(BindingPersistence.java:378)
at org.eclipse.ui.internal.keys.BindingPersistence.reRead(BindingPersistence.java:1380)
at org.eclipse.ui.internal.keys.BindingPersistence.read(BindingPersistence.java:1284)
at org.eclipse.ui.internal.BindingToModelProcessor.process(BindingToModelProcessor.java:61)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:56)
... 22 more



edit: links removed

[Updated on: Sun, 06 May 2012 20:06]

Report message to a moderator

Re: Questions concerning @PreDestroy and @PreSave [message #870128 is a reply to message #870112] Sun, 06 May 2012 20:12 Go to previous messageGo to next message
Heike Winkelvoß is currently offline Heike Winkelvoß
Messages: 11
Registered: April 2012
Junior Member
Hi,

the problem with the "AssertionFailedException: null argument" I solved in the meantime: the org.eclipse.ui-bundle was missing in my product configuration but that did not cause validation errors in the run configuration. After I added org.eclipse.ui, there is no exception during startup any more.

So that leaves only the 3 questions concerning the double lifecycle method calls.

I would be glad if somebody could help.

Heike.

[Updated on: Sun, 06 May 2012 20:15]

Report message to a moderator

Re: Questions concerning @PreDestroy and @PreSave [message #870167 is a reply to message #870112] Mon, 07 May 2012 06:50 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas Schindl
Messages: 5422
Registered: July 2009
Senior Member
Am 06.05.12 18:09, schrieb Heike Winkelvoß:
> Hi,
>
> I've got some questions concerning the part an application lifecycles:
>
> Setting:
>
> as described in several e4-tutorials in one of my parts I wrote a method
> which I expected to be called on application shutdown:
>
> @Inject @PreDestroy
> public void dispose(ISpielSessionService pSpielSessionService){
> pSpielSessionService.shutDown(null);
> if (LOG.isDebugEnabled()){
> LOG.debug("after calling shutDown");
> }
> }
>

There's not @Inject needed here, only @PreDestroy! Could you check
please if:
a) with a no-arg dispose
b) if it is call if you close simply the part

if b) works and the method is not called on shutdown this would be a bug

> I've got an ApplicationLifeCycleHandler:
>
> plugin.xml:
>
> <property
> name="lifeCycleURI"
>
> value="bundleclass://de.egladil.mcmatheraetsel.e4.app/de.egladil.mcmatheraetsel.e4.app.handlers.ApplicationLifeCycleHandler">
>
> </property>
>
> In the ApplicationLifeCycleHandler I annotated a method with @PreSave
> which I also expected to be called on application shutdown.
>
> Here are my questions:
>
> 1) both methods are only called, when I add an additional @Inject
> annotation, i.e. without something to be injected the methods are not
> called at all. That seems strange.
>

There's no @Inject needed for both of them

> 2) the @PreDestroy- method in the part is called twice: first at
> application startup (=strange), a second time at application shutdown
> (what is the expected moment)
>

Just to be clear you added the @PreDestroy to your part right?

> 3) the @PreSave method in the ApplicationLifeCycleHandler is only called
> on application start (=strange) but not when I close the application wit
> a QuitHandler or by merely closing the application window.
>
>
> Maybe that this behaviour is caused by the following framework
> exceptions that I ignored up to now because they address the
> PreferenceStore that I do not use up to now.
>

See org.eclipse.ui makes nosense at all. Are you running with the compat
layer in action?

> Maybe somebody knows how to get rid of these exceptions?
>
>

Something is really messed up with your application. Which version of
Eclipse 4 are you running with? Are you using the compat layer?

Tom
Re: Questions concerning @PreDestroy and @PreSave [message #870170 is a reply to message #870128] Mon, 07 May 2012 06:57 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas Schindl
Messages: 5422
Registered: July 2009
Senior Member
You should not need and never use org.eclipse.ui unless you want to use
the compat layer.

Tom

Am 06.05.12 22:12, schrieb Heike Winkelvoß:
> Hi,
>
> the problem with the "AssertionFailedException: null argument" I solved
> in the meantime: the org.eclipse.ui-bundle was missing in my product
> configuration but that did not cause validation errors in the run
> configuration. After I added org.eclipse.ui, there is no exception
> during startup any more.
>
> So that leaves only the 3 questions concerning the double lifecycle
> method calls.
>
> I would be glad if somebody could halp.
>
> Heike.
Re: Questions concerning @PreDestroy and @PreSave [message #870295 is a reply to message #870167] Mon, 07 May 2012 15:17 Go to previous message
Heike Winkelvoß is currently offline Heike Winkelvoß
Messages: 11
Registered: April 2012
Junior Member
Hi Tom,

thank you for your reply.

I just removed all Eclipse-3.x-dependencies from my e4-bundle (it was a migration from an RCP-3.x application), so that there are no dependencies to org.eclipse.ui, org.eclipse.ui.workbench any more and started with a pure e4 configuration (see osgi-console below)

I also removed the @Inject from both @PreDestroy (in the Part) and @PreSave (in the ApplicationLifeCycleHandler) methods and now it works fine: the methods are only called when I close the part or close the application.


So I think you are right: my setup was a bit messed up and there is probably no bug there.

Thanks a lot!
Heike




id State Bundle
0 ACTIVE org.eclipse.osgi_3.8.0.v20120312-2035
Fragments=31, 82
1 ACTIVE org.eclipse.equinox.common_3.6.100.v20120209-1951
2 ACTIVE org.eclipse.core.runtime_3.8.0.v20120308-2101
3 RESOLVED com.springsource.org.bouncycastle.jce_1.39.0
4 RESOLVED org.eclipse.core.runtime.compatibility.registry_3.5.0.v20110505
Master=46
5 ACTIVE org.eclipse.emf.ecore_2.8.0.v20120315-1035
6 ACTIVE org.eclipse.equinox.ds_1.2.0.v20100507
7 RESOLVED org.apache.commons.logging_1.0.4.v201101211617
10 ACTIVE org.eclipse.core.contenttype_3.4.1.R35x_v20090826-0451
11 STARTING org.eclipse.core.databinding_1.4.1.v20111007-1312
12 RESOLVED de.egladil.mcmatheraetsel.persistence.api_1.0.0
13 RESOLVED org.eclipse.e4.ui.css.core_0.10.0.v20120312-1146
15 RESOLVED org.eclipse.swt_3.8.0.v3823a
Fragments=109
16 ACTIVE org.eclipse.e4.core.contexts_1.0.0.v20120224-1633
17 RESOLVED com.springsource.slf4j.api_1.5.0
Fragments=28
18 RESOLVED com.springsource.org.apache.commons.io_1.4.0
19 RESOLVED org.eclipse.osgi.services_3.3.0.v20120307-2102
20 RESOLVED org.eclipse.jface.text_3.8.0.v20120314-1011
21 RESOLVED javax.xml_1.3.4.v201005080400
22 ACTIVE org.eclipse.e4.core.di_1.1.0.v20120223-2025
23 RESOLVED javax.inject_1.0.0.v20091030
24 RESOLVED com.springsource.org.apache.commons.lang_2.4.0
25 ACTIVE org.eclipse.equinox.util_1.0.200.v20100503
26 ACTIVE org.eclipse.e4.ui.workbench.addons.swt_0.10.0.v20120314-2016
27 RESOLVED com.springsource.org.apache.commons.logging_1.1.1
28 RESOLVED com.springsource.slf4j.log4j_1.5.0
Master=17
29 ACTIVE org.eclipse.jface_3.8.0.v20120301-1821
30 RESOLVED org.apache.batik.css_1.6.0.v201011041432
31 RESOLVED org.eclipse.equinox.weaving.hook_1.0.200.v20120307-1407
Master=0
33 ACTIVE de.egladil.mcmatheraetsel.resources.offline_1.0.0
35 STARTING org.eclipse.emf.edit_2.8.0.v20120319-0555
36 ACTIVE org.eclipse.equinox.app_1.3.100.v20111010-1614
37 ACTIVE org.apache.felix.gogo.runtime_0.8.0.v201108120515
38 RESOLVED de.egladil.base.orinoco_1.0.3
39 ACTIVE org.eclipse.core.jobs_3.5.200.v20120113-1913
40 ACTIVE org.eclipse.equinox.preferences_3.5.0.v20120120-1210
41 ACTIVE org.eclipse.e4.ui.css.swt_0.10.0.v20120314-1644
42 ACTIVE org.eclipse.e4.core.commands_0.10.0.v20120209-1845
43 STARTING de.egladil.base.utils_1.1.0
44 RESOLVED org.eclipse.jface.databinding_1.6.0.v20111007-1312
45 ACTIVE de.egladil.mcmatheraetsel.resources.online_1.0.0
46 ACTIVE org.eclipse.equinox.registry_3.5.200.v20111010-1614
Fragments=4
47 RESOLVED org.eclipse.core.resources.win32.x86_3.5.100.v20110423-0524
Master=69
48 ACTIVE de.egladil.base.exceptions_1.1.0
49 STARTING org.eclipse.core.databinding.property_1.4.0.v20111007-1312
50 RESOLVED com.springsource.org.apache.commons.codec_1.4.0
51 RESOLVED de.egladil.mcpunktgenerator.domain_1.0.0
52 RESOLVED org.w3c.dom.svg_1.1.0.v201011041433
53 STARTING org.eclipse.emf.databinding.edit_1.2.0.v20120319-0555
54 RESOLVED de.egladil.mcmatheraetsel.resources.api_1.0.0
55 STARTING com.ibm.icu_4.4.2.v20110823
56 ACTIVE org.eclipse.e4.ui.workbench.swt_0.10.0.v20120224-1612
57 RESOLVED org.w3c.dom.smil_1.0.0.v200806040011
58 ACTIVE org.eclipse.equinox.console_1.0.0.v20111215-1210
59 RESOLVED de.egladil.mcmatheraetsel.domain_1.0.0
60 ACTIVE org.eclipse.e4.ui.bindings_0.10.0.v20120313-1928
61 ACTIVE org.eclipse.emf.ecore.xmi_2.8.0.v20120315-1035
62 ACTIVE org.eclipse.e4.ui.services_0.10.0.v20120209-1845
63 ACTIVE org.eclipse.emf.common_2.8.0.v20120315-1035
64 RESOLVED org.eclipse.nebula.widgets.gallery_0.5.2.R_0_20090418
65 STARTING org.eclipse.emf.databinding_1.2.0.v20120319-0555
66 RESOLVED org.eclipse.core.databinding.beans_1.2.100.I20100601-0800
67 RESOLVED javax.annotation_1.0.0.v20101115-0725
68 STARTING org.eclipse.equinox.concurrent_1.0.200.v20111010-1614
69 ACTIVE org.eclipse.core.resources_3.8.0.v20120229-1128
Fragments=47
70 ACTIVE org.eclipse.e4.ui.workbench.renderers.swt_0.10.0.v20120314-1758
71 RESOLVED org.apache.batik.util.gui_1.6.0.v201011041432
72 RESOLVED org.eclipse.core.commands_3.6.0.v20111007-1312
73 ACTIVE org.eclipse.e4.ui.workbench_0.10.1.v20120314-1316
74 ACTIVE org.apache.felix.gogo.shell_0.8.0.v201110170705
75 STARTING org.eclipse.e4.tools.emf.ui_0.10.0.v20120214-2243
76 ACTIVE org.eclipse.e4.tools.services_0.11.0.v20120224-0022
77 RESOLVED de.egladil.base.logging_1.0.3
78 RESOLVED de.idyl.crypto.zip_1.0.0
80 ACTIVE org.eclipse.e4.core.services_1.0.0.v20120118-2149
81 RESOLVED org.eclipse.e4.ui.widgets_0.11.0.v20120312-0401
82 RESOLVED org.eclipse.equinox.transforms.hook_1.0.300.v20111010-1614
Master=0
83 STARTING org.eclipse.e4.core.di.extensions_0.10.0.v20120201-1503
84 RESOLVED org.w3c.css.sac_1.3.1.v200903091627
85 ACTIVE de.egladil.mcmatheraetsel.persistence.file_1.0.0
86 STARTING de.egladil.base.xml_1.0.3
87 ACTIVE org.apache.felix.gogo.command_0.8.0.v201108120515
88 RESOLVED org.eclipse.e4.ui.workbench3_0.12.0.v20120215-1332
90 RESOLVED com.springsource.org.apache.commons.httpclient_3.1.0
91 ACTIVE org.eclipse.core.expressions_3.4.300.v20110228
92 RESOLVED de.egladil.mcmatheraetsel.business.api_1.0.0
93 ACTIVE de.egladil.mcmatheraetsel.business.osgi_1.0.0
94 ACTIVE org.eclipse.e4.ui.css.swt.theme_0.9.1.v20120315-1637
95 ACTIVE org.eclipse.e4.tools.emf.liveeditor_0.10.0.v20120119-1728
96 RESOLVED org.apache.batik.util_1.6.0.v201011041432
97 ACTIVE org.eclipse.e4.ui.model.workbench_0.10.0.v20120221-1958
98 ACTIVE org.eclipse.core.filesystem_1.3.200.v20120306-1226
Fragments=102
99 ACTIVE org.eclipse.emf.ecore.change_2.8.0.v20120315-1035
100 RESOLVED de.egladil.mcmatheraetsel.files_1.0.0
102 RESOLVED org.eclipse.core.filesystem.win32.x86_1.1.300.v20110423-0524
Master=98
103 ACTIVE org.eclipse.equinox.event_1.2.100.v20111010-1614
104 RESOLVED de.egladil.base.collections_1.1.0
105 ACTIVE org.eclipse.e4.ui.di_0.10.0.v20120217-1935
106 ACTIVE de.egladil.base.log4j_1.1.0
107 STARTING de.egladil.base.file_1.0.4
108 ACTIVE org.eclipse.core.databinding.observable_1.3.0.I20100601-0800
109 RESOLVED org.eclipse.swt.win32.win32.x86_3.8.0.v3823a
Master=15
110 ACTIVE de.egladil.mcmatheraetsel.e4.app_1.0.0
111 STARTING org.eclipse.help_3.4.1.v20090805_35x
112 RESOLVED org.eclipse.text_3.5.0.v20090513-2000
Previous Topic:specify size/ratio for Perspective Layout
Next Topic:Eclipse 3.x RCP application editor
Goto Forum:
  


Current Time: Fri Oct 24 16:23:43 GMT 2014

Powered by FUDForum. Page generated in 0.01785 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software