Error: Path for project must have only one segment

Error: Path for project must have only one segment

Even Though google shows 995,000 pages containg the text “Path for project must have only one segment” – None of them really explains what this error mean – Except if you 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 avialable or you might have forget to instantiate the IProject object or try to instantiate the IProject with different name.

Solution: Have a look at your code where you are calling


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;

Posted: July 9th, 2009
Categories: Java
Tags: ,
Comments: 1 Comment.