Bug 243692 - [buildpath] Cannot set Attached Source from Class File Editor
Summary: [buildpath] Cannot set Attached Source from Class File Editor
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.4   Edit
Hardware: All All
: P3 normal with 1 vote (vote)
Target Milestone: 3.4.2   Edit
Assignee: Jerome Lanneluc CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 243633 243693 246637 246659 246685 247178 248560 254630 258746 (view as bug list)
Depends on:
Blocks:
 
Reported: 2008-08-10 15:36 EDT by Steven Tamm CLA
Modified: 2009-02-13 12:54 EST (History)
13 users (show)

See Also:


Attachments
My config.txt (147.26 KB, text/plain)
2008-09-09 13:46 EDT, Steven Tamm CLA
no flags Details
Proposed fix and regression test (2.87 KB, patch)
2008-09-12 11:29 EDT, Jerome Lanneluc CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Steven Tamm CLA 2008-08-10 15:36:48 EDT
When I try to set a Source Attachment on a class file through the "Change Attached Source..." link on the edit page, it fails with the following error. 
 
Attempted to beginRule: R/, does not match outer scope rule: P/platform-main

In this case, it's a class whose source is defined inside an External Jar.  I can select the jar, but it then provides the above error immediately.  "platform-main" is the project in which the jar file is included and the .project & .classpath files are both writable.  The workaround is to attach the source through "Configure Build Path..." and editing the source attachment in the libraries tab.  

!ENTRY org.eclipse.jdt.ui 4 10001 2008-08-10 12:28:14.768
!MESSAGE Internal Error
!STACK 0
java.lang.reflect.InvocationTargetException
	at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:403)
	at org.eclipse.jface.dialogs.ProgressMonitorDialog.run(ProgressMonitorDialog.java:507)
	at org.eclipse.ui.internal.progress.ProgressMonitorJobsDialog.run(ProgressMonitorJobsDialog.java:275)
	at org.eclipse.ui.internal.progress.ProgressManager$3.run(ProgressManager.java:977)
	at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
	at org.eclipse.ui.internal.progress.ProgressManager.busyCursorWhile(ProgressManager.java:1012)
	at org.eclipse.ui.internal.progress.ProgressManager.busyCursorWhile(ProgressManager.java:987)
	at org.eclipse.ui.internal.progress.ProgressManager.run(ProgressManager.java:1195)
	at org.eclipse.jdt.internal.ui.javaeditor.ClassFileEditor$SourceAttachmentForm.applySourceAttachment(ClassFileEditor.java:303)
	at org.eclipse.jdt.internal.ui.javaeditor.ClassFileEditor$2.widgetSelected(ClassFileEditor.java:286)
	at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:228)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1158)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3401)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3033)
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2382)
	at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2346)
	at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2198)
	at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:493)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:288)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:488)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:113)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:193)
	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:382)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
	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:585)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:549)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:504)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1236)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1212)
Caused by: java.lang.IllegalArgumentException: Attempted to beginRule: R/, does not match outer scope rule: P/platform-main
	at org.eclipse.core.runtime.Assert.isLegal(Assert.java:64)
	at org.eclipse.core.internal.jobs.ThreadJob.illegalPush(ThreadJob.java:122)
	at org.eclipse.core.internal.jobs.ThreadJob.push(ThreadJob.java:232)
	at org.eclipse.core.internal.jobs.ImplicitJobs.begin(ImplicitJobs.java:58)
	at org.eclipse.core.internal.jobs.JobManager.beginRule(JobManager.java:230)
	at org.eclipse.core.internal.resources.WorkManager.checkIn(WorkManager.java:117)
	at org.eclipse.core.internal.resources.Workspace.prepareOperation(Workspace.java:1747)
	at org.eclipse.core.internal.resources.File.setContents(File.java:364)
	at org.eclipse.jdt.internal.core.JavaProject.setSharedProperty(JavaProject.java:2885)
	at org.eclipse.jdt.internal.core.JavaProject.writeFileEntries(JavaProject.java:2651)
	at org.eclipse.jdt.internal.core.JavaModelManager$7.run(JavaModelManager.java:1188)
	at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1800)
	at org.eclipse.jdt.internal.core.JavaModelManager$PerProjectInfo.writeAndCacheClasspath(JavaModelManager.java:1182)
	at org.eclipse.jdt.internal.core.SetClasspathOperation.executeOperation(SetClasspathOperation.java:61)
	at org.eclipse.jdt.internal.core.JavaModelOperation.run(JavaModelOperation.java:709)
	at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1800)
	at org.eclipse.jdt.internal.core.JavaModelOperation.runOperation(JavaModelOperation.java:775)
	at org.eclipse.jdt.internal.core.JavaProject.setRawClasspath(JavaProject.java:2815)
	at org.eclipse.jdt.internal.core.JavaProject.setRawClasspath(JavaProject.java:2846)
	at org.eclipse.jdt.internal.ui.wizards.buildpaths.BuildPathSupport.updateProjectClasspath(BuildPathSupport.java:277)
	at org.eclipse.jdt.internal.ui.wizards.buildpaths.BuildPathSupport.modifyClasspathEntry(BuildPathSupport.java:186)
	at org.eclipse.jdt.internal.ui.wizards.buildpaths.SourceAttachmentBlock$1.run(SourceAttachmentBlock.java:587)
	at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:121)
Root exception:
java.lang.IllegalArgumentException: Attempted to beginRule: R/, does not match outer scope rule: P/platform-main
	at org.eclipse.core.runtime.Assert.isLegal(Assert.java:64)
	at org.eclipse.core.internal.jobs.ThreadJob.illegalPush(ThreadJob.java:122)
	at org.eclipse.core.internal.jobs.ThreadJob.push(ThreadJob.java:232)
	at org.eclipse.core.internal.jobs.ImplicitJobs.begin(ImplicitJobs.java:58)
	at org.eclipse.core.internal.jobs.JobManager.beginRule(JobManager.java:230)
	at org.eclipse.core.internal.resources.WorkManager.checkIn(WorkManager.java:117)
	at org.eclipse.core.internal.resources.Workspace.prepareOperation(Workspace.java:1747)
	at org.eclipse.core.internal.resources.File.setContents(File.java:364)
	at org.eclipse.jdt.internal.core.JavaProject.setSharedProperty(JavaProject.java:2885)
	at org.eclipse.jdt.internal.core.JavaProject.writeFileEntries(JavaProject.java:2651)
	at org.eclipse.jdt.internal.core.JavaModelManager$7.run(JavaModelManager.java:1188)
	at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1800)
	at org.eclipse.jdt.internal.core.JavaModelManager$PerProjectInfo.writeAndCacheClasspath(JavaModelManager.java:1182)
	at org.eclipse.jdt.internal.core.SetClasspathOperation.executeOperation(SetClasspathOperation.java:61)
	at org.eclipse.jdt.internal.core.JavaModelOperation.run(JavaModelOperation.java:709)
	at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1800)
	at org.eclipse.jdt.internal.core.JavaModelOperation.runOperation(JavaModelOperation.java:775)
	at org.eclipse.jdt.internal.core.JavaProject.setRawClasspath(JavaProject.java:2815)
	at org.eclipse.jdt.internal.core.JavaProject.setRawClasspath(JavaProject.java:2846)
	at org.eclipse.jdt.internal.ui.wizards.buildpaths.BuildPathSupport.updateProjectClasspath(BuildPathSupport.java:277)
	at org.eclipse.jdt.internal.ui.wizards.buildpaths.BuildPathSupport.modifyClasspathEntry(BuildPathSupport.java:186)
	at org.eclipse.jdt.internal.ui.wizards.buildpaths.SourceAttachmentBlock$1.run(SourceAttachmentBlock.java:587)
	at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:121)
Comment 1 Olivier Thomann CLA 2008-08-11 08:49:14 EDT
*** Bug 243693 has been marked as a duplicate of this bug. ***
Comment 2 Jerome Lanneluc CLA 2008-08-20 06:18:05 EDT
I cannot reproduce the problem. What is the Eclipse build id? Do you have more accurate steps? An example project that shows the problem would be great.
Comment 3 Jerome Lanneluc CLA 2008-09-09 06:46:08 EDT
*** Bug 246659 has been marked as a duplicate of this bug. ***
Comment 4 Jerome Lanneluc CLA 2008-09-09 06:47:20 EDT
One possibility is that a plugin that is not part of the Eclipse SDK is using a PessimisticResourceRuleFactory.
Comment 5 Jerome Lanneluc CLA 2008-09-09 06:49:05 EDT
*** Bug 246685 has been marked as a duplicate of this bug. ***
Comment 6 Jerome Lanneluc CLA 2008-09-09 06:51:23 EDT
*** Bug 243633 has been marked as a duplicate of this bug. ***
Comment 7 Steven Tamm CLA 2008-09-09 13:46:47 EDT
Created attachment 112106 [details]
My config.txt

This is my configuration details.  I'll add more comments to the bug if necedssary
Comment 8 Steven Tamm CLA 2008-09-09 13:53:46 EDT
I've uploaded my configuration details (with the preferences removed).  I'm using the JEE version ganymede with the following non-eclipse.org plugins:

com.hudson.velocityweb (1.0.8) "Velocity Web Edit" [Starting]
com.perforce.p4api (2008.1.159134) "Perforce Client API" [Active]
dk.kamstruplinnet.projecttransfer (1.0.6) "Multi Project Import/Export plugin" [Starting]

The perforce plugin doesn't refer to PessimisticResourceRuleFactory, neither do the others (at least through grepping).  
http://www.perforce.com/downloads/http/p4-wsad/install/

The multi-project transfer plugin is available from here
http://eclipse-tools.sourceforge.net/updates/

The velocity plugin is probably not it, because other developers have reported the problem and none of them use it
http://velocitywebedit.sourceforge.net/
Comment 9 Brian Anderson CLA 2008-09-10 13:43:22 EDT
The only non SDK plugin I have is Perforce.  I've removed it and the beginRule errors disappear.
Comment 10 Carmelo CLA 2008-09-11 04:55:08 EDT
I have got perforce plug-in too ... 
kar
Comment 11 Steven Tamm CLA 2008-09-11 10:03:22 EDT
I've filed a bug with Perforce just so that they know what's going on.  

I'm using an older version of the plugin, so I'm going to upgrade and see if it helps
http://www.perforce.com/perforce/doc.current/user/p4wsadnotes.txt
Comment 12 Steven Tamm CLA 2008-09-11 10:07:17 EDT
Upgrading to the latest perforce plugin (P4WSAD 2008.1.162483) made this go away. Can the other cc'd people try to upgrade their plugin and see if it helps?
Comment 13 Carmelo CLA 2008-09-12 06:03:52 EDT
Hi guys ... 
i have got already installed the last perforce plugin installed 
from http://www.perforce.com/downloads/http/p4-wsad/install/

it says version 2008.1.162483

java.lang.IllegalArgumentException: Attempted to beginRule: R/, does not match outer scope rule: P/EnginePlugin
at org.eclipse.core.runtime.Assert.isLegal(Assert.java:64)
at org.eclipse.core.internal.jobs.ThreadJob.illegalPush(ThreadJob.java:122)
at org.eclipse.core.internal.jobs.ThreadJob.push(ThreadJob.java:232)
at org.eclipse.core.internal.jobs.ImplicitJobs.begin(ImplicitJobs.java:58)
at org.eclipse.core.internal.jobs.JobManager.beginRule(JobManager.java:230)
at org.eclipse.core.internal.resources.WorkManager.checkIn(WorkManager.java:117)
at org.eclipse.core.internal.resources.Workspace.prepareOperation(Workspace.java:1747)
at org.eclipse.core.internal.resources.File.setContents(File.java:364)
at org.eclipse.jdt.internal.core.JavaProject.setSharedProperty(JavaProject.java:2885)
at org.eclipse.jdt.internal.core.JavaProject.writeFileEntries(JavaProject.java:2651)
at org.eclipse.jdt.internal.core.JavaModelManager$7.run(JavaModelManager.java:1188)
at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1800)
at org.eclipse.jdt.internal.core.JavaModelManager$PerProjectInfo.writeAndCacheClasspath(JavaModelManager.java:1182)
at org.eclipse.jdt.internal.core.SetClasspathOperation.executeOperation(SetClasspathOperation.java:61)
at org.eclipse.jdt.internal.core.JavaModelOperation.run(JavaModelOperation.java:709)
at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1800)
at org.eclipse.jdt.internal.core.JavaModelOperation.runOperation(JavaModelOperation.java:775)
at org.eclipse.jdt.internal.core.JavaProject.setRawClasspath(JavaProject.java:2815)
at org.eclipse.jdt.internal.core.JavaProject.setRawClasspath(JavaProject.java:2846)
at org.eclipse.pde.internal.core.ClasspathComputer.setClasspath(ClasspathComputer.java:38)
at org.eclipse.pde.internal.ui.editor.plugin.ExecutionEnvironmentSection$2.linkActivated(ExecutionEnvironmentSection.java:155)
at org.eclipse.ui.forms.widgets.AbstractHyperlink.handleActivate(AbstractHyperlink.java:228)
at org.eclipse.ui.forms.widgets.AbstractHyperlink.handleMouseUp(AbstractHyperlink.java:316)
at org.eclipse.ui.forms.widgets.AbstractHyperlink.access$2(AbstractHyperlink.java:300)
at org.eclipse.ui.forms.widgets.AbstractHyperlink$4.handleEvent(AbstractHyperlink.java:119)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1003)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3823)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3422)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2382)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2346)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2198)
at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:493)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:288)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:488)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:113)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:193)
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:382)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
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:549)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:504)
at org.eclipse.equinox.launcher.Main.run(Main.java:1236)


-----------


eclipse.buildId=I20080617-2000
java.version=1.6.0_07
java.vendor=Sun Microsystems Inc.
BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=en_US
Command-line arguments:  -os win32 -ws win32 -arch x86

Comment 14 Jerome Lanneluc CLA 2008-09-12 06:45:58 EDT
*** Bug 246637 has been marked as a duplicate of this bug. ***
Comment 15 Jerome Lanneluc CLA 2008-09-12 10:52:17 EDT
Thanks for investigating this. So it looks like the Perforce plugin is causing grief. However I thing we should behave correctly in the presence of such plugin. I'll investigate a fix.
Comment 16 Jerome Lanneluc CLA 2008-09-12 11:29:25 EDT
Created attachment 112433 [details]
Proposed fix and regression test

(Note to verify that the fix is in, one can remove the fix and run the test, it should show the same trace as reported in this bug in the console)
Comment 17 Jerome Lanneluc CLA 2008-09-12 11:44:06 EDT
Fix and test released for 3.5M2
Comment 18 Dani Megert CLA 2008-09-13 04:11:51 EDT
*** Bug 247178 has been marked as a duplicate of this bug. ***
Comment 19 Olivier Thomann CLA 2008-09-15 10:22:07 EDT
Verified for 3.5M2 using I20080914-2000
Comment 20 Dani Megert CLA 2008-10-03 03:48:23 EDT
*** Bug 248560 has been marked as a duplicate of this bug. ***
Comment 21 Dani Megert CLA 2008-10-03 04:01:29 EDT
Might be a good candidate for 3.4.2.
Comment 22 Jerome Lanneluc CLA 2008-10-03 05:30:44 EDT
Philippe, +1 for 3.4.2 ? (fix is trivial, this is a regression comparing to 3.3.x, and there is no workaround but disable the Perforce plugin)
Comment 23 Philipe Mulet CLA 2008-10-03 06:59:21 EDT
+1 for 3.4.2
Comment 24 Jerome Lanneluc CLA 2008-10-03 10:13:25 EDT
Fix and test released for 3.4.2
Comment 25 Jerome Lanneluc CLA 2008-11-13 12:54:24 EST
*** Bug 254630 has been marked as a duplicate of this bug. ***
Comment 26 Dani Megert CLA 2008-12-14 10:53:54 EST
*** Bug 258746 has been marked as a duplicate of this bug. ***
Comment 27 Frederic Fusier CLA 2009-02-03 11:54:47 EST
Verified for 3.4.2 running ClasspathTests v_894_R34x
Comment 28 Kevin Sawicki CLA 2009-02-13 11:58:26 EST
(In reply to comment #4)
> One possibility is that a plugin that is not part of the Eclipse SDK is using a
> PessimisticResourceRuleFactory.
> 

Hi,
Isn't the PessimisticResourceRuleFactory the default one returned by RepositoryProvider.getRuleFactory ?

I work on the Perforce Plugin and was just wondering if it is wrong to use the base implementation of that method or should it be overriden with a custom rule factory?
Comment 29 Rob Clevenger CLA 2009-02-13 12:10:33 EST
(In reply to comment #28)
> (In reply to comment #4)
> > One possibility is that a plugin that is not part of the Eclipse SDK is using a
> > PessimisticResourceRuleFactory.
> > 
> 
> Hi,
> Isn't the PessimisticResourceRuleFactory the default one returned by
> RepositoryProvider.getRuleFactory ?
> 
> I work on the Perforce Plugin and was just wondering if it is wrong to use the
> base implementation of that method or should it be overriden with a custom rule
> factory?
> 

Look @ the CVS Implementation for a custom one.  I think this should work fine (and I just sent a similiar patch to egit)

  private static final ResourceRuleFactory RESOURCE_RULE_FACTORY = new ResourceRuleFactory() {};

  @Override
  public IResourceRuleFactory getRuleFactory() {
    return RESOURCE_RULE_FACTORY;
  }




Comment 30 Kevin Sawicki CLA 2009-02-13 12:54:53 EST
(In reply to comment #29)
> (In reply to comment #28)
> > (In reply to comment #4)
> > > One possibility is that a plugin that is not part of the Eclipse SDK is using a
> > > PessimisticResourceRuleFactory.
> > > 
> > 
> > Hi,
> > Isn't the PessimisticResourceRuleFactory the default one returned by
> > RepositoryProvider.getRuleFactory ?
> > 
> > I work on the Perforce Plugin and was just wondering if it is wrong to use the
> > base implementation of that method or should it be overriden with a custom rule
> > factory?
> > 
> 
> Look @ the CVS Implementation for a custom one.  I think this should work fine
> (and I just sent a similiar patch to egit)
> 
>   private static final ResourceRuleFactory RESOURCE_RULE_FACTORY = new
> ResourceRuleFactory() {};
> 
>   @Override
>   public IResourceRuleFactory getRuleFactory() {
>     return RESOURCE_RULE_FACTORY;
>   }
> 


Thanks, looking into fixing this on the Perforce plugin end so users can avoid this on pre-3.4.2 builds.