Home » Eclipse Projects » Remote Application Platform (RAP) » NPE in ProgressInfoItem.init()
NPE in ProgressInfoItem.init() [message #900144] |
Sat, 04 August 2012 12:29  |
Eclipse User |
|
|
|
Hi,
I get following NullPointerException, when refreshing the browser page (F5):
java.lang.NullPointerException
at org.eclipse.ui.internal.progress.ProgressInfoItem.init(ProgressInfoItem.java:186)
at org.eclipse.ui.internal.progress.ProgressManager$ProgressManagerProvider.getInstance(ProgressManager.java:106)
at org.eclipse.ui.internal.progress.ProgressManager.getInstance(ProgressManager.java:188)
at org.eclipse.rap.ui.internal.progress.JobManagerAdapter$3.run(JobManagerAdapter.java:195)
at org.eclipse.rwt.internal.lifecycle.FakeContextUtil.runNonUIThreadWithFakeContext(FakeContextUtil.java:58)
at org.eclipse.rwt.lifecycle.UICallBack.runNonUIThreadWithFakeContext(UICallBack.java:50)
at org.eclipse.rap.ui.internal.progress.JobManagerAdapter.findSessionProgressManager(JobManagerAdapter.java:193)
at org.eclipse.rap.ui.internal.progress.JobManagerAdapter.createMonitor(JobManagerAdapter.java:82)
at org.eclipse.core.internal.jobs.JobManager.createMonitor(JobManager.java:454)
at org.eclipse.core.internal.jobs.JobManager.startJob(JobManager.java:1493)
at org.eclipse.core.internal.jobs.WorkerPool.startJob(WorkerPool.java:221)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:50)
Debug Info:
Thread [Worker-2] (Suspended (breakpoint at line 185 in ProgressInfoItem))
owns: Object (id=238)
owns: Object (id=307)
ProgressInfoItem.init() line: 185
ProgressManager$ProgressManagerProvider.getInstance() line: 106
ProgressManager.getInstance() line: 188
JobManagerAdapter$3.run() line: 195
FakeContextUtil.runNonUIThreadWithFakeContext(Display, Runnable) line: 58
UICallBack.runNonUIThreadWithFakeContext(Display, Runnable) line: 50
JobManagerAdapter.findSessionProgressManager(Job) line: 193
JobManagerAdapter.createMonitor(Job) line: 82
JobManager.createMonitor(Job) line: 454
JobManager.startJob() line: 1493
The name of the job is "Building workspace(4)".
I only get the NPE when I run my rap app on an external server (rhcloud). When I run it locally everything is fine ???
I'm using RAP 1.5.0.20120612-1510.
I think the problem is that Display.getCurrent() is called from a non UI-Thread and therefore returns null. So the section from line 103 to line 116 in ProgressManager is restricted for UI-Threads and non UI-Threads whould throw NPE. Therefore a UI-Thread must initialize the ProgressManager instance and set its display. As this is apparently not guaranteed, wouldn't it be better to use the display, set in the fake session (LifeCycleUtil.getSessionDisplay()), instead of Display.getCurrent() in ProgressInfoItem.init() and ProgressManagerProvider.getInstance().
regrads,
Matthias
|
|
|
Re: NPE in ProgressInfoItem.init() [message #900437 is a reply to message #900144] |
Tue, 07 August 2012 02:08   |
Eclipse User |
|
|
|
Hi Matthia,
if you look at the Display#getCurrent() inplementation you will see that
it uses LifeCycleUtil.getSessionDisplay() internally. If
Display#getCurrent() return null PlatformUI.getWorkbench().getDisplay()
will be useless too. Could you provide a simple self running snippet the
initialize the ProgressInfoItem from a background thread? Please open a
bugzilla end attach the snippet there.
Best,
Ivan
On 8/4/2012 7:29 PM, Matthias Lettmayer wrote:
> Hi,
>
> I get following NullPointerException, when refreshing the browser page
> (F5):
>
>
> java.lang.NullPointerException
> at
> org.eclipse.ui.internal.progress.ProgressInfoItem.init(ProgressInfoItem.java:186)
> at
> org.eclipse.ui.internal.progress.ProgressManager$ProgressManagerProvider.getInstance(ProgressManager.java:106)
> at
> org.eclipse.ui.internal.progress.ProgressManager.getInstance(ProgressManager.java:188)
> at
> org.eclipse.rap.ui.internal.progress.JobManagerAdapter$3.run(JobManagerAdapter.java:195)
> at
> org.eclipse.rwt.internal.lifecycle.FakeContextUtil.runNonUIThreadWithFakeContext(FakeContextUtil.java:58)
> at
> org.eclipse.rwt.lifecycle.UICallBack.runNonUIThreadWithFakeContext(UICallBack.java:50)
> at
> org.eclipse.rap.ui.internal.progress.JobManagerAdapter.findSessionProgressManager(JobManagerAdapter.java:193)
> at
> org.eclipse.rap.ui.internal.progress.JobManagerAdapter.createMonitor(JobManagerAdapter.java:82)
> at
> org.eclipse.core.internal.jobs.JobManager.createMonitor(JobManager.java:454)
> at
> org.eclipse.core.internal.jobs.JobManager.startJob(JobManager.java:1493)
> at
> org.eclipse.core.internal.jobs.WorkerPool.startJob(WorkerPool.java:221)
> at org.eclipse.core.internal.jobs.Worker.run(Worker.java:50)
>
> Debug Info:
>
> Thread [Worker-2] (Suspended (breakpoint at line 185 in
> ProgressInfoItem))
> owns: Object (id=238)
> owns: Object (id=307)
> ProgressInfoItem.init() line: 185
> ProgressManager$ProgressManagerProvider.getInstance() line: 106
> ProgressManager.getInstance() line: 188
> JobManagerAdapter$3.run() line: 195
> FakeContextUtil.runNonUIThreadWithFakeContext(Display, Runnable)
> line: 58
> UICallBack.runNonUIThreadWithFakeContext(Display, Runnable) line: 50
> JobManagerAdapter.findSessionProgressManager(Job) line: 193
> JobManagerAdapter.createMonitor(Job) line: 82
> JobManager.createMonitor(Job) line: 454
> JobManager.startJob() line: 1493
>
> The name of the job is "Building workspace(4)".
>
> I only get the NPE when I run my rap app on an external server
> (rhcloud). When I run it locally everything is fine ???
>
> I'm using RAP 1.5.0.20120612-1510.
>
> I think the problem is that Display.getCurrent() is called from a non
> UI-Thread and therefore returns null. So the section from line 103 to
> line 116 in ProgressManager is restricted for UI-Threads and non
> UI-Threads whould throw NPE. Therefore a UI-Thread must initialize the
> ProgressManager instance and set its display. As this is apparently
> not guaranteed, wouldn't it be better to use the display, set in the
> fake session (LifeCycleUtil.getSessionDisplay()), instead of
> Display.getCurrent() in ProgressInfoItem.init() and
> ProgressManagerProvider.getInstance().
>
> regrads,
> Matthias
--
Ivan Furnadjiev
Twitter: @EclipseRAP
Blog: http://eclipsesource.com/blogs/
Professional services for RAP and RCP?
http://eclipsesource.com/services/rap/
|
|
|
Re: NPE in ProgressInfoItem.init() [message #900497 is a reply to message #900437] |
Tue, 07 August 2012 06:00   |
Eclipse User |
|
|
|
Hi Ivan,
Thanks for your reply!
Yes, Display#getCurrent() uses LifeCycleUtil#getSessionDisplay(), but the problem here is that it returns null if the session display thread doesn't equal the current running thread (which is the case). So Display.getThread() will always return a UI thread and Display#getCurrent() will always return null if it's called from a non UI thread with fake context. Therefore, I think, using LifeCycleUtil#getSessionDisplay() directly would fix this NPE.
I've searched already for the root cause of this NPE, to provide a simple snippet, but it's not that easy. The weird thing (for me at least) is that I never get this NPE when I run my rap app locally, but only on external server.
If I deploy my app at openShift with tomcat and call it from the browser, ProgressInfoItem.init() is first called from the UI thread with the job "Identifier Update Job(13)" (scheduled state). When I refresh page, ProgressInfoItem.init() is called from a Worker thread with the job "Building workspace(4)", which results in the given NPE. Next thread, which calls ProgressInfoItem.init() is the UI thread with job "Identifier Update Job(16)", which I think should be calling it before the Worker thread to avoid the NPE.
If I run it locally (with tomcat) the UI thread (Identifier Update Job(16)) is first and initializes the ProgressInfoItem when refreshing page.
Why differs the job execution order at openShift? Java versions are equal (java 1.6.0_24).
Thanks in advance,
best regards,
Matthias
|
|
|
Re: NPE in ProgressInfoItem.init() [message #900504 is a reply to message #900497] |
Tue, 07 August 2012 06:18   |
Eclipse User |
|
|
|
Hi Matthias,
no... look at LifeCycleUtil#getSessionDisplay(). When running from a
background thread, probably there will be no context available.
I will suggest to file a bugzilla about this issue. Ofcourse, we need a
snippet to reproduce it in order to track it down.
Best,
Ivan
On 8/7/2012 1:00 PM, Matthias Lettmayer wrote:
> Hi Ivan,
>
> Thanks for your reply!
>
> Yes, Display#getCurrent() uses LifeCycleUtil#getSessionDisplay(), but
> the problem here is that it returns null if the session display thread
> doesn't equal the current running thread (which is the case). So
> Display.getThread() will always return a UI thread and
> Display#getCurrent() will always return null if it's called from a non
> UI thread with fake context. Therefore, I think, using
> LifeCycleUtil#getSessionDisplay() directly would fix this NPE.
>
> I've searched already for the root cause of this NPE, to provide a
> simple snippet, but it's not that easy. The weird thing (for me at
> least) is that I never get this NPE when I run my rap app locally, but
> only on external server.
> If I deploy my app at openShift with tomcat and call it from the
> browser, ProgressInfoItem.init() is first called from the UI thread
> with the job "Identifier Update Job(13)" (scheduled state). When I
> refresh page, ProgressInfoItem.init() is called from a Worker thread
> with the job "Building workspace(4)", which results in the given NPE.
> Next thread, which calls ProgressInfoItem.init() is the UI thread with
> job "Identifier Update Job(16)", which I think should be calling it
> before the Worker thread to avoid the NPE.
> If I run it locally (with tomcat) the UI thread (Identifier Update
> Job(16)) is first and initializes the ProgressInfoItem when refreshing
> page.
>
> Why differs the job execution order at openShift? Java versions are
> equal (java 1.6.0_24).
>
> Thanks in advance,
> best regards,
> Matthias
--
Ivan Furnadjiev
Twitter: @EclipseRAP
Blog: http://eclipsesource.com/blogs/
Professional services for RAP and RCP?
http://eclipsesource.com/services/rap/
|
|
|
Re: NPE in ProgressInfoItem.init() [message #900621 is a reply to message #900504] |
Tue, 07 August 2012 15:45  |
Eclipse User |
|
|
|
I found the bug:
I deleted a project before the session was destroyed (beforeDestroy listener). So if I refreshed the page, the listener was called. The project delete action caused somehow the creation of a new "building workspace" job, which is executed before the UI thread job and so caused the NPE.
As this bug is related to the org.eclipse.core.resources plugin, which is currently not provided by the RAP target runtime, I'm not going to file this bug.
If I should do it anyway, just let me know.
best regards,
Matthias
|
|
|
Goto Forum:
Current Time: Wed Jul 23 23:36:40 EDT 2025
Powered by FUDForum. Page generated in 0.03610 seconds
|