Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 321007 - RuntimeDelegate. setAttribute throwing NPE
Summary: RuntimeDelegate. setAttribute throwing NPE
Status: RESOLVED INVALID
Alias: None
Product: WTP ServerTools
Classification: WebTools
Component: wst.server (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: wst.server CLA
QA Contact: Angel Vera CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-07-27 09:03 EDT by James Kingdon CLA
Modified: 2010-08-19 15:35 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description James Kingdon CLA 2010-07-27 09:03:09 EDT
Build Identifier: 3.2.0.v201005290030-377A88s73533E6K4C6E

I'm working on an adopting product that uses RuntimeDelegate.setAttribute to associate data with a server runtime instance. We have reports where our code is failing in a manner consistent with the data not being stored in the instance. Once the IDE gets into this state it appears to fail every time and the problem is not solved by restarting the IDE. Unfortunately I have not been able to reproduce the problem locally.

One user provided .log files that show the setAttribute method failing with NPE:

!ENTRY org.eclipse.wst.common.project.facet.core 4 0 2010-07-07 07:24:06.750
!MESSAGE null
!STACK 0
java.lang.NullPointerException
	at org.eclipse.wst.server.core.model.RuntimeDelegate.setAttribute(Unknown Source)

Since the setAttribute method is a one-liner we can infer that the runtimeWC instance variable must be null

org.eclipse.wst.server.core.model. RuntimeDelegate.setAttribute(String, String):
protected final void setAttribute(String id, String value) {
         runtimeWC.setAttribute(id, value);
    }

The runtimeWC instance variable looks to be set in the initialize method

final void initialize(Runtime newRuntime, IProgressMonitor monitor) {
       runtime = newRuntime;
       if (runtime instanceof RuntimeWorkingCopy)
              runtimeWC = (RuntimeWorkingCopy) runtime;
       initialize();
     }

In my (working) environment I can see this method getting called and setting runtimeWC appropriately. I'd appreciate any guidance on how the RuntimeDelegate is initialized and why it might fail to be correctly initialized under some circumstances.

Regards,
James

Reproducible: Always

Steps to Reproduce:
Once the failure occurs for a user it appears to be permanent (I've asked for them to try a new workspace to see if it is WS specific), but unfortunately I do not have a way of reproducing the problem.
Comment 1 James Kingdon CLA 2010-08-19 15:35:09 EDT
Looks like the problem was that the client code needed to check for being passed a IRuntime or an IRuntimeWorkingCopy and create the working copy if necessary.