Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 311386 - NPE encountered in Generic JAXB schema generation
Summary: NPE encountered in Generic JAXB schema generation
Status: VERIFIED FIXED
Alias: None
Product: Dali JPA Tools
Classification: WebTools
Component: JAXB (show other bugs)
Version: 2.3   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 2.3 RC1   Edit
Assignee: Tran Le CLA
QA Contact:
URL:
Whiteboard: PMC_approved
Keywords:
Depends on:
Blocks:
 
Reported: 2010-05-03 11:33 EDT by Neil Hauge CLA
Modified: 2010-09-29 12:19 EDT (History)
4 users (show)

See Also:
neil.hauge: pmc_approved? (david_williams)
raghunathan.srinivasan: pmc_approved+
neil.hauge: pmc_approved? (naci.dai)
neil.hauge: pmc_approved? (deboer)
neil.hauge: pmc_approved? (neil.hauge)
neil.hauge: pmc_approved? (kaloyan)
neil.hauge: review+


Attachments
Patch (7.82 KB, patch)
2010-05-04 17:27 EDT, Tran Le CLA
no flags Details | Diff
Patch with externalized messages (18.60 KB, patch)
2010-05-05 16:03 EDT, Tran Le CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Neil Hauge CLA 2010-05-03 11:33:13 EDT
I'm not quite sure of the cause of this NPE, but once the NPE is fixed we should get a better idea.  For some reason I haven't been able to reproduce this yet in debug.

In jpt.jaxb.core.schemagen.Main an NPE can occur on line 102, where 'message' can be null.  I null check is need here with some additional logic to handle this case and provide feedback to help with fixing the problem.
Comment 1 Neil Hauge CLA 2010-05-03 11:55:58 EDT
OK...figured out the cause of this problem.  I was trying to generate a schema using the JAXB RI, but the jaxb.properties file had MOXy specified as the JAXBContext.  This resulted in some sort of JAXBException that apparently returns a null message.

In these cases, EclipseLink won't be on the classpath, so the error message should indicate to the user that they need to have EclipseLink MOXy available on the classpath when using the EclipseLink JAXB context.
Comment 2 Tran Le CLA 2010-05-04 17:27:26 EDT
Created attachment 167051 [details]
Patch
Comment 3 Tran Le CLA 2010-05-04 17:28:00 EDT
Fixed the NPE and display a message to guide the user.
Comment 4 Tran Le CLA 2010-05-04 18:07:29 EDT
Fix ready for review.
Comment 5 Neil Hauge CLA 2010-05-05 10:55:54 EDT
It looks like we need to externalize the messages in these Main classes.
Comment 6 Tran Le CLA 2010-05-05 16:03:18 EDT
Created attachment 167217 [details]
Patch with externalized messages
Comment 7 Neil Hauge CLA 2010-05-05 16:21:15 EDT
* Explain why you believe this is a stop-ship defect. Or, if it is a "hotbug" (requested by an adopter) please document it as such. 

NPE prevents the user from getting any useful feedback as to what could be causing this schema generation problem.  

* Is there a work-around? If so, why do you believe the work-around is insufficient? 

Yes, but it will be very difficult for the user to figure out how to work around the problem.

* How has the fix been tested? Is there a test case attached to the bugzilla record? Has a JUnit Test been added? 

Developer tested.

* Give a brief technical overview. Who has reviewed this fix? 

The change was basically just to check for null to avoid the NPE, and then provide usable feedback for the user.  Most the patch deals with externalizing the help messages.

* What is the risk associated with this fix? 

Low risk.
Comment 8 Raghunathan Srinivasan CLA 2010-05-05 16:48:18 EDT
Suggestion: Review System.out in the patch.
Comment 9 Tran Le CLA 2010-05-05 18:15:10 EDT
Fixed in RC1
Comment 10 Karen Butzke CLA 2010-05-11 10:51:54 EDT
verified fixed in build WTP-I-3.2.0-20100507065327