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

Bug 376926

Summary: Wrong Validation Error Message -"pageContext cannot be resolved" for tag file
Product: [WebTools] WTP Source Editing Reporter: Bin Ouyang <bouyang>
Component: jst.jspAssignee: Nick Sandonato <nsand.dev>
Status: RESOLVED FIXED QA Contact: Nick Sandonato <nsand.dev>
Severity: normal    
Priority: P3 CC: thatnitind
Version: 3.4   
Target Milestone: 3.5 M3   
Hardware: PC   
OS: Windows 7   
Whiteboard:
Attachments:
Description Flags
Snapshot for the wrong validation error message none

Description Bin Ouyang CLA 2012-04-16 23:54:50 EDT
Build Identifier: Version: 4.2.0 Build id: I20120315-1300

Our projects have a lot tag files, when we clean projects or manually validate projects, some tag files always have the validation error messages on a couple of lines. It's wierd when you validate a tag file individually, the error messages are gone.

I try to reproduce this in a simple tag file and a simple dynamic web project, but fails to reproduce it.

So I checked the source codes. I found that JspJavaValidator reported those errors, which were caused by TagTranslator translating a tag file to a java file with compilation errors.

e.g
AddToWatchList.tag(partial)

<%@ tag description="Creates dropdown component" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ attribute name="id" description="component ID" %>
<%@ attribute name="model" required="true" type="com.ebay.raptor.viewitem.pres.model.AddToWatchListModel" description="model" %>
...

__2F_ViewItemWeb_2F_src_2F_main_2F_webapp_2F_WEB_2D_INF_2F_tags_2F_viewitem_2F_addtowatch_2F_AddToWatchList_2E_tag.java (partial)

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.jsp.*;

public class __2F_ViewItemWeb_2F_src_2F_main_2F_webapp_2F_WEB_2D_INF_2F_tags_2F_viewitem_2F_addtowatch_2F_AddToWatchList_2E_tag extends javax.servlet.jsp.tagext.SimpleTagSupport{
/** 
component ID
 */ 
private java.lang.String id = (java.lang.String) pageContext.getAttribute("id");
/** 
model
 */ 
private com.ebay.raptor.viewitem.pres.model.AddToWatchListModel model = (com.ebay.raptor.viewitem.pres.model.AddToWatchListModel) pageContext.getAttribute("model");
...

Here we can find that the translated's java class uses "pageContext" field, but no definition here and base class. 

So all tag files translate into wrong java files, why not all reports the error messages? I checked the codes and find the cause is in createMessageFromProblem method of JSPJavaValidator, it will filter IProblem when cannot mapping the problem from Java to JSP.

Reproducible: Always

Steps to Reproduce:
I can reproduce this issue in my projects every time, but I cannot share the project to you, and I fail to reproduce this in a simple tag file of a simple dynamic web project.
Comment 1 Bin Ouyang CLA 2012-04-17 00:00:07 EDT
Created attachment 214078 [details]
Snapshot for the wrong validation error message
Comment 2 Nick Sandonato CLA 2012-11-07 16:29:04 EST
I  pushed changes to our translation process to make sure that we're using the correct context for Tag files.

http://git.eclipse.org/c/sourceediting/webtools.sourceediting.git/commit/?id=4305b41ed114390556aab681e545287b727d0a8b