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

Bug 131406

Summary: [validation] Error when creating EJB project
Product: [WebTools] WTP EJB Tools Reporter: Tim deBoer <deboer>
Component: jst.ejbAssignee: Neeraj Agrawal <nagrawal>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: hshanka, lmandel
Version: 1.0.2   
Target Milestone: 1.5 RC4   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Tim deBoer CLA 2006-03-10 17:25:44 EST
I'm not sure if this bug has already been opened, but it is really confusing for novice users that an error message appears in the Problems view immediately after creating a new EJB project. The error is 'correct' (an empty EJB project is invalid) but the message is poor and I've had several users say that they think there was a problem in the wizard and even avoid creating an EJB (which would fix the problem) because they want to figure out what the problem is first.

Not sure what the best solution is here - changing the error to a warning might help, or making the error text more readable. Another option would be to not do this particular validation until deployment or later in the cycle.
Comment 1 Tim deBoer CLA 2006-03-12 16:37:57 EST
Defect also reported by SVT tester.
Comment 2 Neeraj Agrawal CLA 2006-03-13 12:01:20 EST
The error in the  problems view is coming from the  XML validator.
If you  like the  error message to be changed or ignored  please  assign this defect to  wst.xml , 

Otherwise  there is a defect to  allow you create  default session bean on project creation

https://bugs.eclipse.org/bugs/show_bug.cgi?id=119311

*** This bug has been marked as a duplicate of 119311 ***
Comment 3 Tim deBoer CLA 2006-04-22 12:11:26 EDT
I'd like you to reconsider this bug for the following reasons:
 * This was brought up as one of the top WTP usability issues on the build call a few weeks ago, along with the related error on EAR projects. The EAR validation has been fixed.
 * 119311 isn't a direct duplicate, it is a change that will avoid this problem when users follow the regular path. Users can still end up in this situation through other paths and a more appropriate J2EE error message would be useful in any case.
 * 119311 is an enhancement and sounds like more work. If there is any chance that it will not be contained in 1.5, I think we should use this bug to pursue the same fix as the EAR validation, which should be much more easily contained.
Comment 4 Neeraj Agrawal CLA 2006-04-24 09:39:54 EDT
Tim, this  error message is from  the XML validator
Comment 5 Neeraj Agrawal CLA 2006-04-24 09:40:39 EDT
Targeting the defect to the right component.
Comment 6 Lawrence Mandel CLA 2006-05-15 00:47:47 EDT
Seems to me the correct action is not to change the error message but rather to correct the way in which EJB projects are created. Why are we creating invalid projects? Does it make sense to create an EJB project without a module? Can the wizard be updated to create a default module?

If the solution that will be pursued is to update the error message, the XML validator now (as of 1.0.2) provides a mechanism to customize error messages for specific namespaces. The EJB component can make use of this mechanism to customize the error message on default EJB projects. See the WST ISV docs for information on the extension point. There is a sample for J2EE already in place in WTP and let me know if you need help with this.
Comment 7 John Lanuti CLA 2006-05-15 09:21:46 EDT
Neeraj, much like the more explanatory informational message for empty ears, we should use the extension point from Lawrence to add a more meaningful message about empty ejb projects.  
Comment 8 Neeraj Agrawal CLA 2006-05-15 09:48:44 EDT
John, Lawrence,  the  message is coming from the  XML validator, and the message is 

cvc-complex-type.2.4.a: Invalid content was found starting with element 'ejb-client-jar'. One of '{"http://java.sun.com/xml/ns/j2ee":display-name, "http://java.sun.com/xml/ns/j2ee":icon, "http://java.sun.com/xml/ns/j2ee":enterprise-beans}' is expected.	Ejb2/ejbModule/META-INF	ejb-jar.xml	line 5	1147700890021	19



So, i dont follow in which code i  should  the new  extension  mechanism.
Comment 9 Lawrence Mandel CLA 2006-05-15 10:47:33 EDT
Correct. That's the default error message produced by the XML validator. You can customize the error message using the org.eclipse.wst.xml.core.errorCustomizer. Custom error messages for EJBs should be stored in EJB centric plug-ins.
Comment 10 Neeraj Agrawal CLA 2006-05-16 11:35:18 EDT
Lawrence, what  info  gets into   ElementInformation elementInfo   of customizeMessage, 

for  the  EAR  case, i see elementInfo.getLocalname() as  "application"  whereas  for the  ejb error    elementInfo.getLocalname() as "display-name", 
shouldn't it be  "ejb-jar" ?


cvc-complex-type.2.4.b: The content of element 'application' is not complete. One of '{"http://java.sun.com/xml/ns/j2ee":display-name, "http://java.sun.com/xml/ns/j2ee":icon, "http://java.sun.com/xml/ns/j2ee":module}' is expected.	EAR3/EarContent/META-INF	application.xml	



cvc-complex-type.2.4.b: The content of element 'ejb-jar' is not complete. One of '{"http://java.sun.com/xml/ns/j2ee":display-name, "http://java.sun.com/xml/ns/j2ee":icon, "http://java.sun.com/xml/ns/j2ee":enterprise-beans}' is expected.	Ejb2/ejbModule/META-INF	ejb-jar.xml	
Comment 11 Lawrence Mandel CLA 2006-05-16 12:54:20 EDT
The localname in the ElementInformation object should contain the name of the element for which the error is being reported. In your case this should be "ejb-jar" as you state. I did a quick test and my test confirmed that when the error is reported it is reported with a local name of ejb-jar. However, I also saw that a second call was made for the same error with the localname of display-name. I'll have to investigate further to find out if  this second call for display-name is correct. For the EJB dd you should check the element name as well as the error key. See [1] for an example.

[1]http://dev.eclipse.org/viewcvs/index.cgi/jst/components/j2ee/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/core/internal/validation/xmlerrorcustomization/J2EEErrorMessageCustomizer.java?rev=1.1&cvsroot=WebTools_Project&content-type=text/vnd.viewcvs-markup
Comment 12 Lawrence Mandel CLA 2006-05-16 13:24:46 EDT
I did some further investigation and the call for display-name is incorrect and is a result of information being retained from a previous validation run. I've opened bug 142034 to track this problem. I've already attached a patch that you can use while working on this fix if it makes your life easier :)
Comment 13 Lawrence Mandel CLA 2006-05-23 00:21:25 EDT
*** Bug 143064 has been marked as a duplicate of this bug. ***
Comment 14 Neeraj Agrawal CLA 2006-05-24 15:14:22 EDT
Fixed,
added logic in  J2EEErrorMessageCustomizer to display meaningful message when an ejb project is created without any enterprise beans.
Comment 15 Tim deBoer CLA 2006-06-13 11:50:45 EDT
Verified, closing.