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

Bug 338294

Summary: CorruptedResourceException when adding event in the calendar sample
Product: z_Archived Reporter: Raj Alagumalai <raj.alagumalai>
Component: SapphireAssignee: Konstantin Komissarchik <konstantin>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: konstantin
Version: unspecified   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:

Description Raj Alagumalai CLA 2011-02-25 20:27:08 EST
Build Identifier: 0.2.1.201102251334

org.eclipse.sapphire.modeling.CorruptedResourceException when adding event

install sapphire from update site

create a new file called calendar.xml
switch to events node right click and add event


following exception is logged in the .log file



!ENTRY org.eclipse.sapphire.ui 4 0 2011-02-25 17:08:19.603
!MESSAGE null
!STACK 0
org.eclipse.sapphire.modeling.CorruptedResourceException
	at org.eclipse.sapphire.modeling.xml.RootXmlResource.getXmlElement(RootXmlResource.java:144)
	at org.eclipse.sapphire.modeling.xml.StandardXmlListBindingImpl.getBaseXmlElement(StandardXmlListBindingImpl.java:201)
	at org.eclipse.sapphire.modeling.xml.StandardXmlListBindingImpl.getXmlElement(StandardXmlListBindingImpl.java:188)
	at org.eclipse.sapphire.modeling.xml.StandardXmlListBindingImpl.addUnderlyingObject(StandardXmlListBindingImpl.java:140)
	at org.eclipse.sapphire.modeling.LayeredListBindingImpl.add(LayeredListBindingImpl.java:58)
	at org.eclipse.sapphire.modeling.ModelElementList.addNewElement(ModelElementList.java:243)
	at org.eclipse.sapphire.samples.calendar.integrated.internal.CalendarResource$2.addUnderlyingObject(CalendarResource.java:110)
	at org.eclipse.sapphire.modeling.LayeredListBindingImpl.add(LayeredListBindingImpl.java:58)
	at org.eclipse.sapphire.modeling.ModelElementList.addNewElement(ModelElementList.java:243)
	at org.eclipse.sapphire.ui.swt.renderer.actions.internal.OutlineNodeAddActionHandlerFactory$AddActionHandler.run(OutlineNodeAddActionHandlerFactory.java:118)
	at org.eclipse.sapphire.ui.SapphireActionHandler.execute(SapphireActionHandler.java:89)
	at org.eclipse.sapphire.ui.SapphireActionLink$1.linkActivated(SapphireActionLink.java:125)
	at org.eclipse.sapphire.ui.swt.renderer.internal.formtext.SapphireFormText.activateLink(SapphireFormText.java:1547)
	at org.eclipse.sapphire.ui.swt.renderer.internal.formtext.SapphireFormText.handleMouseClick(SapphireFormText.java:1349)
	at org.eclipse.sapphire.ui.swt.renderer.internal.formtext.SapphireFormText.access$16(SapphireFormText.java:1320)
	at org.eclipse.sapphire.ui.swt.renderer.internal.formtext.SapphireFormText$6.mouseUp(SapphireFormText.java:440)
	at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:213)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4066)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3657)
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2640)
	at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2604)
	at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2438)
	at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:671)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:664)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:115)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:369)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:620)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:575)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1408)



Reproducible: Always
Comment 1 Konstantin Komissarchik CLA 2011-02-25 20:31:33 EST
Thanks for the report, Raj. I will look into this.
Comment 2 Konstantin Komissarchik CLA 2011-02-28 13:08:34 EST
The problem did not reproduce for me as described. I was able to trigger it by corrupting the calendar.xml file. There is an issue with how the calendar sample handles corrupted files. 

I was curious how Raj ended up with corrupted files, so I asked him. Here is the response:

"copy address.xsd, contacts.xsd and calendar.xsd into a new project
invoke new Xml file wizard and pick xml from schema and choose calendar.xsd schema in the next screen"

I usually use the generic file wizard that creates an empty file. Will investigate why files created by the new xml file wizard are considered corrupted.
Comment 3 Raj Alagumalai CLA 2011-02-28 13:14:31 EST
Comparison of file created by the two wizards

Case 1 which does not result in the exception

New file named Calendar.xml
Open in calendar editor
Add event
Delete event

<?xml version="1.0" encoding="UTF-8"?>
<cal:calendar xmlns:cal="http://www.eclipse.org/sapphire/samples/calendar" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:schemaLocation="http://www.eclipse.org/sapphire/samples/calendar http://www.eclipse.org/sapphire/samples/calendar/1.0">
</cal:calendar>


Case 2 which results in the exception

new XML File wizard and pick XML file from XML schema option

<?xml version="1.0" encoding="UTF-8"?>
<tns:calendar xmlns:tns="http://www.eclipse.org/sapphire/samples/calendar" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:schemaLocation="http://www.eclipse.org/sapphire/samples/calendar Calendar.xsd "> </tns:calendar>


The only difference is the schemalocation

if I modify file 2 as follows, this works fine

<?xml version="1.0" encoding="UTF-8"?>
<tns:calendar xmlns:tns="http://www.eclipse.org/sapphire/samples/calendar" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eclipse.org/sapphire/samples/calendar http://www.eclipse.org/sapphire/samples/calendar/1.0 ">
</tns:calendar>
Comment 4 Konstantin Komissarchik CLA 2011-02-28 13:32:35 EST
Raj,

I am not seeing this issue even if I use the xml file wizard as you describe. The event is created just fine. There is an exception in the console, but it doesn't cause CorruptedResourceException or block the event from being created:

java.net.MalformedURLException: no protocol: Calendar.xsd
	at java.net.URL.<init>(Unknown Source)
	at java.net.URL.<init>(Unknown Source)
	at java.net.URL.<init>(Unknown Source)
	at org.eclipse.sapphire.modeling.xml.schema.XmlDocumentSchema.parse(XmlDocumentSchema.java:585)
	at org.eclipse.sapphire.modeling.xml.schema.XmlDocumentSchema.parseSchema(XmlDocumentSchema.java:178)
	at org.eclipse.sapphire.modeling.xml.schema.XmlDocumentSchema.<init>(XmlDocumentSchema.java:65)
	at org.eclipse.sapphire.modeling.xml.schema.XmlDocumentSchemasCache.getSchema(XmlDocumentSchemasCache.java:51)
	at org.eclipse.sapphire.modeling.xml.XmlElement.getContentModel(XmlElement.java:186)
	at org.eclipse.sapphire.modeling.xml.XmlElement.addChildElement(XmlElement.java:487)
	at org.eclipse.sapphire.modeling.xml.XmlElement.addChildElement(XmlElement.java:547)
	at org.eclipse.sapphire.modeling.xml.StandardXmlListBindingImpl.addUnderlyingObject(StandardXmlListBindingImpl.java:140)
	at org.eclipse.sapphire.modeling.LayeredListBindingImpl.add(LayeredListBindingImpl.java:58)
	at org.eclipse.sapphire.modeling.ModelElementList.addNewElement(ModelElementList.java:243)
	at org.eclipse.sapphire.samples.calendar.integrated.internal.CalendarResource$2.addUnderlyingObject(CalendarResource.java:110)
	at org.eclipse.sapphire.modeling.LayeredListBindingImpl.add(LayeredListBindingImpl.java:58)
	at org.eclipse.sapphire.modeling.ModelElementList.addNewElement(ModelElementList.java:243)
	at org.eclipse.sapphire.ui.swt.renderer.actions.internal.OutlineNodeAddActionHandlerFactory$AddActionHandler.run(OutlineNodeAddActionHandlerFactory.java:125)
	at org.eclipse.sapphire.ui.SapphireActionHandler.execute(SapphireActionHandler.java:89)
	at org.eclipse.sapphire.ui.SapphireActionLink$1.linkActivated(SapphireActionLink.java:125)
	at org.eclipse.sapphire.ui.swt.renderer.internal.formtext.SapphireFormText.activateLink(SapphireFormText.java:1547)
	at org.eclipse.sapphire.ui.swt.renderer.internal.formtext.SapphireFormText.handleMouseClick(SapphireFormText.java:1349)
	at org.eclipse.sapphire.ui.swt.renderer.internal.formtext.SapphireFormText.access$16(SapphireFormText.java:1320)
	at org.eclipse.sapphire.ui.swt.renderer.internal.formtext.SapphireFormText$6.mouseUp(SapphireFormText.java:440)
	at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:219)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4126)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3715)
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2697)
	at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2661)
	at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2495)
	at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:674)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:667)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:115)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:344)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:622)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:577)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1410)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1386)
Comment 5 Konstantin Komissarchik CLA 2011-02-28 13:33:56 EST
Forgot to mention that the check that throws CorruptedResourceException only checks namespace and root element name. Schema location is not looked at.
Comment 6 Raj Alagumalai CLA 2011-02-28 14:16:10 EST
I'm not seeing the issue in the current installation, but do see the following exception logged in the .log file

I was able to consistently reproduce earlier until I ran the previous tests.

I will re run the same scenario on a fresh install and update the bug shortly


java.net.MalformedURLException: no protocol: Calendar.xsd
at java.net.URL.<init>(Unknown Source)
at java.net.URL.<init>(Unknown Source)
at java.net.URL.<init>(Unknown Source)
at org.eclipse.sapphire.modeling.xml.schema.XmlDocumentSchema.parse(XmlDocumentSchema.java:585)
at org.eclipse.sapphire.modeling.xml.schema.XmlDocumentSchema.parseSchema(XmlDocumentSchema.java:178)
at org.eclipse.sapphire.modeling.xml.schema.XmlDocumentSchema.<init>(XmlDocumentSchema.java:65)
at org.eclipse.sapphire.modeling.xml.schema.XmlDocumentSchemasCache.getSchema(XmlDocumentSchemasCache.java:51)
at org.eclipse.sapphire.modeling.xml.XmlElement.getContentModel(XmlElement.java:186)
at org.eclipse.sapphire.modeling.xml.XmlElement.addChildElement(XmlElement.java:487)
at org.eclipse.sapphire.modeling.xml.XmlElement.addChildElement(XmlElement.java:547)
at org.eclipse.sapphire.modeling.xml.StandardXmlListBindingImpl.addUnderlyingObject(StandardXmlListBindingImpl.java:140)
at org.eclipse.sapphire.modeling.LayeredListBindingImpl.add(LayeredListBindingImpl.java:58)
at org.eclipse.sapphire.modeling.ModelElementList.addNewElement(ModelElementList.java:243)
at org.eclipse.sapphire.samples.calendar.integrated.internal.CalendarResource$2.addUnderlyingObject(CalendarResource.java:110)
at org.eclipse.sapphire.modeling.LayeredListBindingImpl.add(LayeredListBindingImpl.java:58)
at org.eclipse.sapphire.modeling.ModelElementList.addNewElement(ModelElementList.java:243)
at org.eclipse.sapphire.ui.swt.renderer.actions.internal.OutlineNodeAddActionHandlerFactory$AddActionHandler.run(OutlineNodeAddActionHandlerFactory.java:118)
at org.eclipse.sapphire.ui.SapphireActionHandler.execute(SapphireActionHandler.java:89)
at org.eclipse.sapphire.ui.SapphireActionLink$1.linkActivated(SapphireActionLink.java:125)
at org.eclipse.sapphire.ui.swt.renderer.internal.formtext.SapphireFormText.activateLink(SapphireFormText.java:1547)
at org.eclipse.sapphire.ui.swt.renderer.internal.formtext.SapphireFormText.handleMouseClick(SapphireFormText.java:1349)
at org.eclipse.sapphire.ui.swt.renderer.internal.formtext.SapphireFormText.access$16(SapphireFormText.java:1320)
at org.eclipse.sapphire.ui.swt.renderer.internal.formtext.SapphireFormText$6.mouseUp(SapphireFormText.java:440)
at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:213)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4066)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3657)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2640)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2604)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2438)
at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:671)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:664)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:115)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:369)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:620)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:575)
at org.eclipse.equinox.launcher.Main.run(Main.java:1408)
Comment 7 Konstantin Komissarchik CLA 2011-02-28 14:25:35 EST
I fixed two problems in relation to this bug:

1. The calendar sample editor was not properly handling malformed files. You are supposed to get a prompt asking if you want to recover. This case can be simulated by corrupting the root element name and/or namespace.

2. The schema parser was unable to handle local schema URL references. This is the case that is produced by using new xml file wizard in the manner that Raj described. You should no longer see the MalformedURLException in this scenario.

Released fixes to 0.2.1 and 0.3 streams.
Comment 8 Raj Alagumalai CLA 2011-02-28 15:09:17 EST
verified with Sapphire_0.2.1.201102281413

start from scratch option is provided and the exception is no longer logged in the .log file
Comment 9 Konstantin Komissarchik CLA 2011-02-28 15:12:52 EST
Closing per Raj's verification.