Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 327934

Summary: File not found exception using content assist on JSP page
Product: [WebTools] WTP Source Editing Reporter: Chris Stodden <chris.stodden>
Component: jst.jspAssignee: Nick Sandonato <nsand.dev>
Status: RESOLVED FIXED QA Contact: Nick Sandonato <nsand.dev>
Severity: normal    
Priority: P3 CC: carlin.rogers, rakes123, thatnitind
Version: 3.2.2Flags: thatnitind: review+
Target Milestone: 3.2.3   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
patch
none
patch
none
patch none

Description Chris Stodden CLA 2010-10-15 13:58:02 EDT
Build Identifier:  M20100909-0800

This seems related to Bug 284427

Per Process Monitor:  There is no prior IO with regards to this file other than at the stack trace position.

Stack Trace:
!MESSAGE File not found: '/DWP/__2F_DWP_2F_WebContent_2F_WebIt_2E_jsp.java'
!STACK 1
org.eclipse.core.internal.resources.ResourceException: Resource '/DWP/__2F_DWP_2F_WebContent_2F_WebIt_2E_jsp.java' does not exist.
	at org.eclipse.core.internal.resources.Resource.checkExists(Resource.java:326)
	at org.eclipse.core.internal.resources.Resource.checkAccessible(Resource.java:200)
	at org.eclipse.core.internal.resources.File.getContents(File.java:291)
	at org.eclipse.jdt.internal.core.util.Util.getResourceContentsAsCharArray(Util.java:1186)
	at org.eclipse.jdt.internal.core.CompilationUnit.getContents(CompilationUnit.java:649)
	at org.eclipse.jdt.internal.core.CompilationUnit$1.getContents(CompilationUnit.java:223)
	at org.eclipse.jdt.internal.compiler.parser.Parser.parse(Parser.java:9590)
	at org.eclipse.jdt.internal.compiler.parser.Parser.parse(Parser.java:9562)
	at org.eclipse.jdt.internal.compiler.SourceElementParser.parseCompilationUnit(SourceElementParser.java:908)
	at org.eclipse.jdt.internal.core.CompilationUnitProblemFinder.process(CompilationUnitProblemFinder.java:180)
	at org.eclipse.jdt.internal.core.CompilationUnit.buildStructure(CompilationUnit.java:180)
	at org.eclipse.jdt.internal.core.Openable.generateInfos(Openable.java:258)
	at org.eclipse.jdt.internal.core.JavaElement.openWhenClosed(JavaElement.java:515)
	at org.eclipse.jdt.internal.core.BecomeWorkingCopyOperation.executeOperation(BecomeWorkingCopyOperation.java:38)
	at org.eclipse.jdt.internal.core.JavaModelOperation.run(JavaModelOperation.java:728)
	at org.eclipse.jdt.internal.core.JavaModelOperation.runOperation(JavaModelOperation.java:788)
	at org.eclipse.jdt.internal.core.CompilationUnit.getWorkingCopy(CompilationUnit.java:985)
	at org.eclipse.jdt.internal.core.CompilationUnit.getWorkingCopy(CompilationUnit.java:960)
	at org.eclipse.jst.jsp.core.internal.java.JSPTranslation.createCompilationUnit(JSPTranslation.java:441)
	at org.eclipse.jst.jsp.core.internal.java.JSPTranslation.getCompilationUnit(JSPTranslation.java:364)
	at org.eclipse.jst.jsp.core.internal.java.JSPTranslation.setProblemCollectingActive(JSPTranslation.java:502)
	at org.eclipse.jst.jsp.core.internal.validation.JSPJavaValidator.performValidation(JSPJavaValidator.java:329)
	at org.eclipse.jst.jsp.core.internal.validation.JSPJavaValidator.validateFile(JSPJavaValidator.java:406)
	at org.eclipse.jst.jsp.core.internal.validation.JSPValidator.validate(JSPValidator.java:196)
	at org.eclipse.wst.sse.ui.internal.reconcile.validator.ReconcileStepForValidator.validate(ReconcileStepForValidator.java:292)
	at org.eclipse.wst.sse.ui.internal.reconcile.validator.ReconcileStepForValidator.reconcileModel(ReconcileStepForValidator.java:258)
	at org.eclipse.jface.text.reconciler.AbstractReconcileStep.reconcile(AbstractReconcileStep.java:95)
	at org.eclipse.wst.sse.ui.internal.reconcile.validator.ValidatorStrategy.reconcile(ValidatorStrategy.java:267)
	at org.eclipse.wst.sse.ui.internal.reconcile.DocumentRegionProcessor.process(DocumentRegionProcessor.java:303)
	at org.eclipse.wst.sse.ui.internal.reconcile.StructuredRegionProcessor.process(StructuredRegionProcessor.java:248)
	at org.eclipse.wst.sse.ui.internal.reconcile.DirtyRegionProcessor.run(DirtyRegionProcessor.java:667)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
!SUBENTRY 1 org.eclipse.core.resources 4 368 2010-10-15 11:46:39.015
!MESSAGE Resource '/DWP/__2F_DWP_2F_WebContent_2F_WebIt_2E_jsp.java' does not exist.

Reproducible: Always

Steps to Reproduce:
1.Create a Dynamic Web Project
2.Create JSP File.
3.Add a jsp:attribute to the body
4.Select in the source view
5.Open the properties view
6.Add a name

This seems to only happen when the project is new the first time, and following the above execution path.
Comment 1 Rakesh CLA 2010-10-22 08:17:31 EDT
I was able to reproduce it , but very few times.And it can occur randomly while editing.

One possible reason for above error is possibility of creation of two threads, with two JspTranslators , one is removing buffer(from org.eclipse.jdt.internal.core.BufferManager)and  another adding it.This exception occurs if thread A creates a buffer adds it to BuffersManager later try to retrieve it, but fails since it has already been deleted by Thread B.

If we look at JSPTranslationAdapter.getJSPTranslation()(Lets say in Thread A from explanation above) , it is releasing jspTranslation and creating it at the very next line . 
In JspTranslation().release() it take a lock and creates a separate Job for releasing buffer(Lets call it Thread B).
As soon as we return from this function , a new translator is created at next line in JSPTranslationAdapter.

Now we have two jspTranslators in two threads , using separate locks for synchronization.

I have used class lock for locking.Let me know if my analysis is correct.
Comment 2 Rakesh CLA 2010-10-22 08:19:11 EDT
Created attachment 181492 [details]
patch
Comment 3 Nick Sandonato CLA 2010-10-22 16:06:43 EDT
Rakesh, wouldn't locking on JSPTranslation.this cause you to still lock on each instance of the enclosing JSPTranslation instance, causing two different locks still?

(In reply to comment #1)
> I was able to reproduce it , but very few times.And it can occur randomly while
> editing.
> 
> One possible reason for above error is possibility of creation of two threads,
> with two JspTranslators , one is removing buffer(from
> org.eclipse.jdt.internal.core.BufferManager)and  another adding it.This
> exception occurs if thread A creates a buffer adds it to BuffersManager later
> try to retrieve it, but fails since it has already been deleted by Thread B.
> 
> If we look at JSPTranslationAdapter.getJSPTranslation()(Lets say in Thread A
> from explanation above) , it is releasing jspTranslation and creating it at the
> very next line . 
> In JspTranslation().release() it take a lock and creates a separate Job for
> releasing buffer(Lets call it Thread B).
> As soon as we return from this function , a new translator is created at next
> line in JSPTranslationAdapter.
> 
> Now we have two jspTranslators in two threads , using separate locks for
> synchronization.
> 
> I have used class lock for locking.Let me know if my analysis is correct.
Comment 4 Rakesh CLA 2010-10-23 00:13:59 EDT
Created attachment 181573 [details]
patch

Sorry!!! it was meant to be JSPTranslation.class
Comment 5 Carlin Rogers CLA 2010-11-03 17:43:53 EDT
Yes, I've also ran into this issue while editing a page.
Comment 6 Nick Sandonato CLA 2010-12-06 17:06:50 EST
Created attachment 184663 [details]
patch

Hi, Rakesh. Your analysis is right; it looks like this came about when the WorkspaceJob was added for Bug 243547. While I think your patch is straightforward and would likely work, it may also not provide the best throughput as all translations would block on this, not just ones related to the particular compilation unit.

My reaction was "why are we discarding it, only to create a new translation?" This patch reuses translations when they're dirty, and resets the compilation unit's contents.
Comment 7 Nick Sandonato CLA 2010-12-14 15:24:38 EST
Code checked in. Thanks for the review, Nitin.