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

Bug 324225

Summary: ClassCastException when trying to open EJB reference
Product: [WebTools] WTP Java EE Tools Reporter: Kaloyan Raev <kaloyan>
Component: jst.j2eeAssignee: Dimitar Giormov <dimitar.giormov>
Status: RESOLVED FIXED QA Contact: Chuck Bridgham <cbridgha>
Severity: normal    
Priority: P2 CC: ccc, david_williams, dimitar.giormov, vladislav.iliev
Version: 3.2Flags: david_williams: pmc_approved+
dimitar.giormov: pmc_approved? (raghunathan.srinivasan)
dimitar.giormov: pmc_approved? (naci.dai)
dimitar.giormov: pmc_approved? (deboer)
dimitar.giormov: pmc_approved? (neil.hauge)
dimitar.giormov: pmc_approved? (kaloyan)
cbridgha: review+
Target Milestone: 3.2.3   
Hardware: PC   
OS: Windows Vista   
Whiteboard: PMC_approved
Attachments:
Description Flags
exception
none
Patch
none
Patch
dimitar.giormov: iplog+
cleaned up commented code + backup plan for application client project. none

Description Kaloyan Raev CLA 2010-09-01 12:38:44 EDT
Created attachment 177985 [details]
exception

Reproducible on latest 3.2.2 and 3.3 builds. 

Steps to reproduce:
  1. Create new Web 2.5 project.
  2. Create new EJB 3.0 project. 
  3. Create new EAR 5 project and include the Web and EJB project created above. 
  4. Create new Session Bean in the EJB project. 
  5. Create new Servlet in the Web project. 
  6. Create a reference in the Servlet to the Session Bean - using @EJB in the Java code. 
  7. Expand the DD tree of the Web project > References. 
  8. Double-click on the reference. 

The following ClassCastException is thrown: 

org.eclipse.jst.javaee.web.internal.impl.WebAppImpl cannot be cast to org.eclipse.jst.javaee.ejb.EJBJar

Full exception log is attached.
Comment 1 Carl Anderson CLA 2010-09-02 08:20:43 EDT
This is a regression from WTP 3.2.0.  It was caused by bug 260705
Comment 2 Vladislav Iliev CLA 2011-01-13 07:32:12 EST
Created attachment 186716 [details]
Patch

This is a proposal for a patch.
Please check it.
Comment 3 Dimitar Giormov CLA 2011-01-13 10:53:28 EST
Vladislav, can you rework a little bit the patch.
1. Purely cosmetic, but remove the commented out code.
2. In the code you are checking for existing Resource reference, but in the list with Ejb references. (patch line 320)
Comment 4 Vladislav Iliev CLA 2011-01-14 05:06:55 EST
Created attachment 186809 [details]
Patch

Second version of the previously proposed patch.
Comment 5 Dimitar Giormov CLA 2011-01-14 07:12:50 EST
Created attachment 186819 [details]
cleaned up commented code + backup plan for application client project.
Comment 6 Chuck Bridgham CLA 2011-01-25 14:32:49 EST
approve
Comment 7 Dimitar Giormov CLA 2011-01-26 02:51:34 EST
Dear PMC members,

This bug causes the eclipse to open error dialog on double click in the case where a EJB reference is selected in Dynamic Web Project. The correct behavior is to open the class where the reference is defined using annotation, or to open the web.xml 
There is a workaround: find the reference you will need manually - search in the classes or the web.xml or both.
The fix is tested manually. Chuck has reviewed the change.
Risk: Low

Technical details:
The fix differentiates the ejb and web projects and artifacts and applies the same logic for both: 1. Check if the reference comes from xml if true opens the appropriate xml file, if false checks in which class the reference is defined and opens this class.
Comment 8 David Williams CLA 2011-01-27 15:16:30 EST
Note: this bug did not have 'PMC' in whiteboard, so has not shown up on review list and has gone unnoticed ... until Carl's watchful eye. I've update the whiteboard and will approve so (hopefully) Carl can release for our RC2.
Comment 9 Carl Anderson CLA 2011-01-27 15:19:05 EST
Committed to R3_2_maintenance for WTP 3.2.3 RC2