| Summary: | [validation] Error when creating EJB project | ||
|---|---|---|---|
| Product: | [WebTools] WTP EJB Tools | Reporter: | Tim deBoer <deboer> |
| Component: | jst.ejb | Assignee: | 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
Defect also reported by SVT tester. 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 *** 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. Tim, this error message is from the XML validator Targeting the defect to the right component. 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. 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. 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.
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. 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
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 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 :) *** Bug 143064 has been marked as a duplicate of this bug. *** Fixed, added logic in J2EEErrorMessageCustomizer to display meaningful message when an ejb project is created without any enterprise beans. Verified, closing. |