Bug 104456 - IllegalArgumentException when FlexibleProjectContainer updates classpath from resource changes
Summary: IllegalArgumentException when FlexibleProjectContainer updates classpath from...
Status: CLOSED FIXED
Alias: None
Product: WTP Java EE Tools
Classification: WebTools
Component: jst.j2ee (show other bugs)
Version: 0.7   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 1.0 M10   Edit
Assignee: Konstantin Komissarchik CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-07-20 01:03 EDT by Nitin Dahyabhai CLA
Modified: 2007-01-24 14:41 EST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Nitin Dahyabhai CLA 2005-07-20 01:03:47 EDT
I haven't been able to reproduce it so far, but I saw the following trace showed
up in my log.  I think it's updating the classpath of all of the projects when
the resource change event may already have a conflicting rule in place.

!ENTRY org.eclipse.core.resources 4 2 2005-07-20 00:40:44.587
!MESSAGE Problems occurred when invoking code from plug-in:
"org.eclipse.core.resources".
!STACK 0
java.lang.IllegalArgumentException: Attempted to beginRule: R/, does not match
outer scope rule:
MultiRule[P/84046,P/antlr,P/commons-beanutils,P/commons-digester,P/commons-fileupload,P/commons-logging,P/commons-validator,P/D,P/Design,P/docs,P/DTDs,P/EclipseWTP,P/F,P/f2,P/Flexible003,P/fresh,P/FsingleModule,P/images,P/J0000,P/J2,P/j2eeWebProject0,P/jakarta-oro,P/jakarta-tomcat-5.5.4-jsp-examples]
	at org.eclipse.core.internal.runtime.Assert.isLegal(Assert.java:58)
	at org.eclipse.core.internal.jobs.ThreadJob.illegalPush(ThreadJob.java:117)
	at org.eclipse.core.internal.jobs.ThreadJob.push(ThreadJob.java:211)
	at org.eclipse.core.internal.jobs.ImplicitJobs.begin(ImplicitJobs.java:81)
	at org.eclipse.core.internal.jobs.JobManager.beginRule(JobManager.java:190)
	at org.eclipse.core.internal.resources.WorkManager.checkIn(WorkManager.java:96)
	at
org.eclipse.core.internal.resources.Workspace.prepareOperation(Workspace.java:1674)
	at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1714)
	at
org.eclipse.jdt.internal.core.JavaModelOperation.runOperation(JavaModelOperation.java:782)
	at org.eclipse.jdt.internal.core.JavaProject.setRawClasspath(JavaProject.java:2834)
	at org.eclipse.jdt.core.JavaCore$6.run(JavaCore.java:3951)
	at
org.eclipse.jdt.internal.core.BatchOperation.executeOperation(BatchOperation.java:39)
	at
org.eclipse.jdt.internal.core.JavaModelOperation.run(JavaModelOperation.java:718)
	at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1719)
	at org.eclipse.jdt.core.JavaCore.run(JavaCore.java:3760)
	at org.eclipse.jdt.core.JavaCore.setClasspathContainer(JavaCore.java:3934)
	at
org.eclipse.jdt.internal.launching.JREContainerInitializer.initialize(JREContainerInitializer.java:54)
	at
org.eclipse.jdt.internal.core.JavaModelManager.initializeContainer(JavaModelManager.java:1591)
	at
org.eclipse.jdt.internal.core.JavaModelManager.getClasspathContainer(JavaModelManager.java:1040)
	at org.eclipse.jdt.core.JavaCore.getClasspathContainer(JavaCore.java:1326)
	at
org.eclipse.jst.common.jdt.internal.classpath.FlexibleProjectContainer$Listener.resourceChanged(FlexibleProjectContainer.java:330)
	at
org.eclipse.core.internal.events.NotificationManager$2.run(NotificationManager.java:276)
	at
org.eclipse.core.internal.runtime.InternalPlatform.run(InternalPlatform.java:1044)
	at org.eclipse.core.runtime.Platform.run(Platform.java:783)
	at
org.eclipse.core.internal.events.NotificationManager.notify(NotificationManager.java:270)
	at
org.eclipse.core.internal.events.NotificationManager.handleEvent(NotificationManager.java:242)
	at org.eclipse.core.internal.resources.Workspace.broadcastEvent(Workspace.java:195)
	at org.eclipse.core.internal.resources.Project.close(Project.java:171)
	at
org.eclipse.ui.actions.CloseResourceAction.invokeOperation(CloseResourceAction.java:169)
	at org.eclipse.ui.actions.WorkspaceAction.execute(WorkspaceAction.java:133)
	at
org.eclipse.ui.actions.WorkspaceAction$2.runInWorkspace(WorkspaceAction.java:424)
	at
org.eclipse.core.internal.resources.InternalWorkspaceJob.run(InternalWorkspaceJob.java:38)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:76)
Comment 1 Chuck Bridgham CLA 2005-08-02 15:28:39 EDT
Hi - Are you adding a Job rule with the specific projects?   Looks like jdt is
using the workspace root, so this rule may need to include that.
Comment 2 Konstantin Komissarchik CLA 2005-08-02 15:32:54 EDT
Chuck, I am not sure why you assigned this to me. Did you mean to assign it to 
Nitin?
Comment 3 Chuck Bridgham CLA 2005-08-29 11:13:33 EDT
Looking at the stack again... do we want to open this against jdt?

The platform is in the middle of a close resource action, and the container is
just calling: JavaCore.getClasspathContainer() - which gets the rule conflict.

Not sure why this should be illegal.

I'll move to jdt.
Comment 4 Chuck Bridgham CLA 2005-08-29 11:14:19 EDT
Looking at the stack again... do we want to open this against jdt?

The platform is in the middle of a close resource action, and the container is
just calling: JavaCore.getClasspathContainer() - which gets the rule conflict.

Not sure why this should be illegal.

I'll move to jdt.
Comment 5 Olivier Thomann CLA 2005-08-30 14:28:13 EDT
Moving to Platform/Resources.
Comment 6 Rafael Chaves CLA 2005-08-30 15:16:53 EDT
Closing a project uses a project-level scheduling rule. The call to
JavaCore.getClasspathContainer() can actually modify resources, and in order to
do that it uses the workspace root as the scheduling rule (and it has to). One
cannot try to begin a rule that is more comprehensive than the current rule.
Thus, calling that method from a resource change listener is not safe. Also,
doing so from a PRE_CLOSE resource change listener is not valid either.
Comment 7 Rafael Chaves CLA 2005-08-30 15:28:35 EDT
A similar issue in PDE: bug 94435.
Comment 8 Chuck Bridgham CLA 2005-09-08 23:58:42 EDT
Looks like the jdt team will consider a fix in 3.2....

*** This bug has been marked as a duplicate of 94764 ***
Comment 9 Rafael Chaves CLA 2005-09-09 11:47:20 EDT
Bug 94764 is in Platform/Resources, not JDT, and is only about improving error
reporting, so this problem will still occur even if that bug is fixed.

It is wrong to call JavaCore.getClasspathContainer() from a PRE_CLOSE resource
change listener, because it may create resources, and you are not allowed to do
so from this type of resource change listener.
Comment 10 Chuck Bridgham CLA 2005-09-09 14:22:41 EDT
Ok Kostantin, looks like this is back to you again...

JavaCore.getClasspathContainer() can't be called on the PRE_CLOSE event, so maybe
listen for this in your FlexibleProjectContainer$Listener class?
Comment 11 Konstantin Komissarchik CLA 2005-11-30 21:32:55 EST
Thanks for doing the legwork to investigate this. I committed the fix. Haven't released it as there are other changes in the plugin. This may or may not be in RC1.
Comment 12 Nitin Dahyabhai CLA 2005-12-13 18:53:44 EST
Can't reproduce on 1.0rc4