Have a look at the source code of WorkspaceRoot class, particularly ‘getProject’ method:
This problem usually occurs when you try to access a project name/path,etc, when it is not available or you might have forget to instantiate the IProject object or try to instantiate the IProject with different name. Have a look at your code where you are calling getProject. Check names, paths are called correctly.
public IProject getProject(String JavaDoc name) { //first check our project cache Project result = (Project) projectTable.get(name); if (result == null) { IPath projectPath = new Path(null, name).makeAbsolute(); String JavaDoc message = "Path for project must have only one segment."; //$NON-NLS-1$ Assert.isLegal(projectPath.segmentCount() == ICoreConstants.PROJECT_SEGMENT_LENGTH, message); //try to get the project using a canonical name String JavaDoc canonicalName = projectPath.lastSegment(); result = (Project) projectTable.get(canonicalName); if (result != null) return result; result = new Project(projectPath, workspace); projectTable.put(canonicalName, result); } return result; }