Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 346526 - NPE's and no guidance for user when schema in library is unresolved
Summary: NPE's and no guidance for user when schema in library is unresolved
Status: RESOLVED FIXED
Alias: None
Product: Dali JPA Tools
Classification: WebTools
Component: JAXB (show other bugs)
Version: 3.0   Edit
Hardware: PC Windows Vista
: P3 major (vote)
Target Milestone: 3.0 RC3   Edit
Assignee: Paul Fullbright CLA
QA Contact:
URL:
Whiteboard: PMC_approved
Keywords:
Depends on:
Blocks:
 
Reported: 2011-05-19 15:01 EDT by Paul Fullbright CLA
Modified: 2011-05-26 13:43 EDT (History)
3 users (show)

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


Attachments
proposed patch (8.24 KB, patch)
2011-05-20 14:50 EDT, Paul Fullbright CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Paul Fullbright CLA 2011-05-19 15:01:01 EDT
When a schema in the JAXB project library is unresolved (such as when a workspace file is deleted or renamed) the following errors/exceptions occur in the log:

java.lang.NullPointerException
	at org.eclipse.jpt.jaxb.core.internal.SchemaLibraryImpl.addSchema(SchemaLibraryImpl.java:73)
	at org.eclipse.jpt.jaxb.core.internal.SchemaLibraryImpl.getSchema(SchemaLibraryImpl.java:63)
	at org.eclipse.jpt.jaxb.core.internal.context.GenericPackage.getXsdSchema(GenericPackage.java:118)
	at org.eclipse.jpt.jaxb.core.internal.context.java.AbstractJavaPersistentType.validateXmlType(AbstractJavaPersistentType.java:375)
...

JAXB Validator finished validating: file:/C:/dev/workspaces/jpt/TestGenericJaxb21/src/test/GlobalType2.java

org.eclipse.emf.ecore.resource.Resource$IOWrappedException: Resource '/TestXml/schema/nons.xsd' does not exist.
	at org.eclipse.emf.ecore.resource.impl.PlatformResourceURIHandlerImpl$WorkbenchHelper.createPlatformResourceInputStream(PlatformResourceURIHandlerImpl.java:222)
	at org.eclipse.emf.ecore.resource.impl.PlatformResourceURIHandlerImpl.createInputStream(PlatformResourceURIHandlerImpl.java:452)
	at org.eclipse.emf.ecore.resource.impl.ExtensibleURIConverterImpl.createInputStream(ExtensibleURIConverterImpl.java:350)
	at org.eclipse.emf.ecore.resource.impl.ExtensibleURIConverterImpl.createInputStream(ExtensibleURIConverterImpl.java:344)
	at org.eclipse.jpt.jaxb.core.xsd.XsdUtil.buildXSDModel(XsdUtil.java:126)
	at org.eclipse.jpt.jaxb.core.internal.SchemaLibraryImpl.addSchema(SchemaLibraryImpl.java:72)
	at org.eclipse.jpt.jaxb.core.internal.SchemaLibraryImpl.getSchema(SchemaLibraryImpl.java:63)
	at org.eclipse.jpt.jaxb.core.internal.context.GenericPackage.getXsdSchema(GenericPackage.java:118)
	at org.eclipse.jpt.jaxb.core.internal.context.java.AbstractJavaPersistentType.validateXmlType(AbstractJavaPersistentType.java:375)
...


Validation does not complete.  Need better handling (and probably validation) for unresolved schemas.
Comment 1 Paul Fullbright CLA 2011-05-20 14:50:41 EDT
Created attachment 196245 [details]
proposed patch

Added exception handling for attempting to load schema resources from bad URI's and validation for projects with such URI's.
Comment 2 Neil Hauge CLA 2011-05-20 15:39:04 EDT
Patch is working well in my testing so far.
Comment 3 Neil Hauge CLA 2011-05-23 18:30:40 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. 

Upon renaming/moving an XML schema that is referred to by our Schema Library the user will loose all validation and content assist for their JAXB classes. This results in NPE's in the log.

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

Workaround is to go to the Schema repository and edit the schema file reference in our properties UI.  The problem is that the user may not realize this is what they need to do.

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

The fix has been tested by Paul and myself. 

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

See comment 1.  I have reviewed the fix.

    What is the risk associated with this fix? 

Risk is low.  This fix is isolated and straightforward.
Comment 4 Paul Fullbright CLA 2011-05-24 11:05:31 EDT
committed for rc3
Comment 5 Chuck Bridgham CLA 2011-05-24 11:06:59 EDT
looks good