[Geoserver-devel] WCS 1.1.1 xml bindings progress

Hi all (hello Justin!),
so I'm trying to implement the xml post side of the
wcs 1.1.1 requests using the new shiny reflective bindings
support Justin added some days ago.

For GetCapabilities and DescribeFeatureType it has been quite
easy, and it worked perfectly.

For GetCoverage, I'm trying to use it all the way in order to
test it. That is, I've removed all the current bindings classes
and I'm instantiating ComplexEMFBinding instead. It's working
as well, but I guess error messages could be improved.

When an element does not have a binding declared various
exceptions can occurr. I've seen this two so far:

java.lang.RuntimeException: Parsing failed for GetCoverage: java.lang.NullPointerException
  at org.geotools.xml.impl.ParseExecutor.visit(ParseExecutor.java:151)
  at org.geotools.xml.impl.BindingWalker$BindingExecutionChain.execute(BindingWalker.java:191)
  at org.geotools.xml.impl.BindingWalker.walk(BindingWalker.java:157)
  at org.geotools.xml.impl.ElementHandlerImpl.endElement(ElementHandlerImpl.java:222)
  at org.geotools.xml.impl.ParserHandler.endElement(ParserHandler.java:566)
  at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source)
  at org.apache.xerces.impl.xs.XMLSchemaValidator.endElement(Unknown Source)
  at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanEndElement(Unknown Source)
  at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
  at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
  at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
  at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source)
  at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
  at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
  at org.geotools.xml.Parser.parse(Parser.java:179)
  at org.geotools.xml.Parser.parse(Parser.java:157)
  at org.geoserver.wcs.xml.v1_1_1.WcsXmlReader.read(WcsXmlReader.java:43)
  at org.geoserver.wcs.xml.GetCoverageXmlParserTest.testBasic(GetCoverageXmlParserTest.java:44)
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
  at java.lang.reflect.Method.invoke(Method.java:585)
  at junit.framework.TestCase.runTest(TestCase.java:154)
  at junit.framework.TestCase.runBare(TestCase.java:127)
  at junit.framework.TestResult$1.protect(TestResult.java:106)
  at junit.framework.TestResult.runProtected(TestResult.java:124)
  at junit.framework.TestResult.run(TestResult.java:109)
  at junit.framework.TestCase.run(TestCase.java:118)
  at junit.framework.TestSuite.runTest(TestSuite.java:208)
  at junit.framework.TestSuite.run(TestSuite.java:203)
  at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
  at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
  at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
  at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
  at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
  at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Caused by: java.lang.NullPointerException
  at java.lang.Class.isAssignableFrom(Native Method)
  at org.geotools.xml.AbstractComplexEMFBinding.parse(AbstractComplexEMFBinding.java:114)
  at org.geotools.xml.impl.ParseExecutor.visit(ParseExecutor.java:142)
  ... 35 more

and:

java.lang.RuntimeException: Parsing failed for DomainSubset: java.lang.ClassCastException: java.util.HashMap
  at org.geotools.xml.impl.ParseExecutor.visit(ParseExecutor.java:151)
  at org.geotools.xml.impl.BindingWalker$BindingExecutionChain.execute(BindingWalker.java:191)
  at org.geotools.xml.impl.BindingWalker.walk(BindingWalker.java:157)
  at org.geotools.xml.impl.ElementHandlerImpl.endElement(ElementHandlerImpl.java:222)
  at org.geotools.xml.impl.ParserHandler.endElement(ParserHandler.java:566)
  at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source)
  at org.apache.xerces.impl.xs.XMLSchemaValidator.endElement(Unknown Source)
  at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanEndElement(Unknown Source)
  at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
  at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
  at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
  at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source)
  at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
  at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
  at org.geotools.xml.Parser.parse(Parser.java:179)
  at org.geotools.xml.Parser.parse(Parser.java:157)
  at org.geoserver.wcs.xml.v1_1_1.WcsXmlReader.read(WcsXmlReader.java:43)
  at org.geoserver.wcs.xml.GetCoverageXmlParserTest.testBasic(GetCoverageXmlParserTest.java:44)
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
  at java.lang.reflect.Method.invoke(Method.java:585)
  at junit.framework.TestCase.runTest(TestCase.java:154)
  at junit.framework.TestCase.runBare(TestCase.java:127)
  at junit.framework.TestResult$1.protect(TestResult.java:106)
  at junit.framework.TestResult.runProtected(TestResult.java:124)
  at junit.framework.TestResult.run(TestResult.java:109)
  at junit.framework.TestCase.run(TestCase.java:118)
  at junit.framework.TestSuite.runTest(TestSuite.java:208)
  at junit.framework.TestSuite.run(TestSuite.java:203)
  at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
  at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
  at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
  at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
  at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
  at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Caused by: java.lang.ClassCastException: java.util.HashMap
  at net.opengis.wcs.v1_1_1.impl.DomainSubsetTypeImpl.eSet(DomainSubsetTypeImpl.java:210)
  at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eSet(BasicEObjectImpl.java:654)
  at org.geotools.xml.EMFUtils.set(EMFUtils.java:58)
  at org.geotools.xml.AbstractComplexEMFBinding.setProperty(AbstractComplexEMFBinding.java:184)
  at org.geotools.xml.AbstractComplexEMFBinding.parse(AbstractComplexEMFBinding.java:148)
  at org.geotools.xml.impl.ParseExecutor.visit(ParseExecutor.java:142)
  ... 35 more

Now, in both cases the cause is a missing binding. It would be nice if the xml-xsd parser emitted a strong warning saying "hey, I don't know
what xxx:hullabaloo is, but I'm doing my best to parse it anyways".
As I said, figuring out the missing binding is usually easy by looking
at what emf property was being accessed, but more error reporting would
speed up coding even further.

Cheers
Andrea

Glad to see you are making progress Andrea!! I definitely agree with you
that this case needs a good error message. However its a bit more
difficult than just that. THe problem is that sometimes there are
elements and types in a schema which you dont want to bind to. the most
common case being those types that extend from string but we dont
care... leaving them as a string is fine.

However... I think for non simple types we could probably impose that
restriction. Opening a jira for this one.

http://jira.codehaus.org/browse/GEOT-1664

-Justin

Andrea Aime wrote:

Hi all (hello Justin!),
so I'm trying to implement the xml post side of the
wcs 1.1.1 requests using the new shiny reflective bindings
support Justin added some days ago.

For GetCapabilities and DescribeFeatureType it has been quite
easy, and it worked perfectly.

For GetCoverage, I'm trying to use it all the way in order to
test it. That is, I've removed all the current bindings classes
and I'm instantiating ComplexEMFBinding instead. It's working
as well, but I guess error messages could be improved.

When an element does not have a binding declared various
exceptions can occurr. I've seen this two so far:

java.lang.RuntimeException: Parsing failed for GetCoverage:
java.lang.NullPointerException
  at org.geotools.xml.impl.ParseExecutor.visit(ParseExecutor.java:151)
  at
org.geotools.xml.impl.BindingWalker$BindingExecutionChain.execute(BindingWalker.java:191)
  at org.geotools.xml.impl.BindingWalker.walk(BindingWalker.java:157)
  at
org.geotools.xml.impl.ElementHandlerImpl.endElement(ElementHandlerImpl.java:222)
  at org.geotools.xml.impl.ParserHandler.endElement(ParserHandler.java:566)
  at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source)
  at org.apache.xerces.impl.xs.XMLSchemaValidator.endElement(Unknown Source)
  at
org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanEndElement(Unknown
Source)
  at
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown
Source)
  at
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown
Source)
  at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
  at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source)
  at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
  at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
  at org.geotools.xml.Parser.parse(Parser.java:179)
  at org.geotools.xml.Parser.parse(Parser.java:157)
  at org.geoserver.wcs.xml.v1_1_1.WcsXmlReader.read(WcsXmlReader.java:43)
  at
org.geoserver.wcs.xml.GetCoverageXmlParserTest.testBasic(GetCoverageXmlParserTest.java:44)
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
  at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
  at java.lang.reflect.Method.invoke(Method.java:585)
  at junit.framework.TestCase.runTest(TestCase.java:154)
  at junit.framework.TestCase.runBare(TestCase.java:127)
  at junit.framework.TestResult$1.protect(TestResult.java:106)
  at junit.framework.TestResult.runProtected(TestResult.java:124)
  at junit.framework.TestResult.run(TestResult.java:109)
  at junit.framework.TestCase.run(TestCase.java:118)
  at junit.framework.TestSuite.runTest(TestSuite.java:208)
  at junit.framework.TestSuite.run(TestSuite.java:203)
  at
org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
  at
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
  at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
  at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
  at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
  at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Caused by: java.lang.NullPointerException
  at java.lang.Class.isAssignableFrom(Native Method)
  at
org.geotools.xml.AbstractComplexEMFBinding.parse(AbstractComplexEMFBinding.java:114)
  at org.geotools.xml.impl.ParseExecutor.visit(ParseExecutor.java:142)
  ... 35 more

and:

java.lang.RuntimeException: Parsing failed for DomainSubset:
java.lang.ClassCastException: java.util.HashMap
  at org.geotools.xml.impl.ParseExecutor.visit(ParseExecutor.java:151)
  at
org.geotools.xml.impl.BindingWalker$BindingExecutionChain.execute(BindingWalker.java:191)
  at org.geotools.xml.impl.BindingWalker.walk(BindingWalker.java:157)
  at
org.geotools.xml.impl.ElementHandlerImpl.endElement(ElementHandlerImpl.java:222)
  at org.geotools.xml.impl.ParserHandler.endElement(ParserHandler.java:566)
  at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source)
  at org.apache.xerces.impl.xs.XMLSchemaValidator.endElement(Unknown Source)
  at
org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanEndElement(Unknown
Source)
  at
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown
Source)
  at
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown
Source)
  at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
  at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source)
  at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
  at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
  at org.geotools.xml.Parser.parse(Parser.java:179)
  at org.geotools.xml.Parser.parse(Parser.java:157)
  at org.geoserver.wcs.xml.v1_1_1.WcsXmlReader.read(WcsXmlReader.java:43)
  at
org.geoserver.wcs.xml.GetCoverageXmlParserTest.testBasic(GetCoverageXmlParserTest.java:44)
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
  at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
  at java.lang.reflect.Method.invoke(Method.java:585)
  at junit.framework.TestCase.runTest(TestCase.java:154)
  at junit.framework.TestCase.runBare(TestCase.java:127)
  at junit.framework.TestResult$1.protect(TestResult.java:106)
  at junit.framework.TestResult.runProtected(TestResult.java:124)
  at junit.framework.TestResult.run(TestResult.java:109)
  at junit.framework.TestCase.run(TestCase.java:118)
  at junit.framework.TestSuite.runTest(TestSuite.java:208)
  at junit.framework.TestSuite.run(TestSuite.java:203)
  at
org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
  at
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
  at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
  at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
  at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
  at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Caused by: java.lang.ClassCastException: java.util.HashMap
  at
net.opengis.wcs.v1_1_1.impl.DomainSubsetTypeImpl.eSet(DomainSubsetTypeImpl.java:210)
  at
org.eclipse.emf.ecore.impl.BasicEObjectImpl.eSet(BasicEObjectImpl.java:654)
  at org.geotools.xml.EMFUtils.set(EMFUtils.java:58)
  at
org.geotools.xml.AbstractComplexEMFBinding.setProperty(AbstractComplexEMFBinding.java:184)
  at
org.geotools.xml.AbstractComplexEMFBinding.parse(AbstractComplexEMFBinding.java:148)
  at org.geotools.xml.impl.ParseExecutor.visit(ParseExecutor.java:142)
  ... 35 more

Now, in both cases the cause is a missing binding. It would be nice if
the xml-xsd parser emitted a strong warning saying "hey, I don't know
what xxx:hullabaloo is, but I'm doing my best to parse it anyways".
As I said, figuring out the missing binding is usually easy by looking
at what emf property was being accessed, but more error reporting would
speed up coding even further.

Cheers
Andrea

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
Geoserver-devel mailing list
Geoserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-devel

!DSPAM:4007,47878e6e211021439371379!

--
Justin Deoliveira
The Open Planning Project
http://topp.openplans.org