Christian, This is definitely a bug. It is supposed to treat elements of "unresolved types" as "anyType", but we seem to have missed a couple of guards for null (unresolved) type in our XSDEcoreBuilder subclass.
Please open a JIRA, and we will fix it soon. Thanks, Frank. "Christian Landbo Frederiksen" <[EMAIL PROTECTED]> wrote on 03/28/2007 09:47:02 AM: > Hi Kelvin > > I can't seem to find out precisely what causes it, because I can > generate a test case where this does not occur. > Fortunately I can also generate one where it does. > > Let me first say that if I create a new helperContext when the > IllegalArgumentException occurs the problem can be avoided... > > Since I am not sure how else to supply this I have just done a > copy/paste og the test case (JUnit 3.8): > > --------------- COPY ------------------- > > > package dk.test; > import junit.framework.TestCase; > import org.apache.tuscany.sdo.util.SDOUtil; > import commonj.sdo.helper.HelperContext; > > public class TestSDOErronousSchemaReferences extends TestCase { > private HelperContext helperContext; > public TestSDOErronousSchemaReferences(String arg0) { > super(arg0); > this.helperContext = SDOUtil.createHelperContext(true); > } > public void testSDOErronousSchemaReferences() { > > try { > String xsd = "<?xml version=\"1.0\" > encoding=\"ISO-8859-1\"?> <schema > xmlns=\"http://www.w3.org/2001/XMLSchema\" > xmlns:brugerinformation=\"http://rep.oio.dk/brugerinformation.dk/xml/sch > emas/2007/01/01/\" > xmlns:XKOM=\"http://rep.oio.dk/xkom.dk/xml/schemas/2006/01/06/\" > xmlns:DKCC=\"http://rep.oio.dk/ebxml/xml/schemas/dkcc/2005/03/15/\" > xmlns:DKCC2=\"http://rep.oio.dk/ebxml/xml/schemas/dkcc/2003/02/13/\" > targetNamespace=\"http://rep.oio.dk/brugerinformation.dk/xml/schemas/200 > 7/01/01/\" elementFormDefault=\"qualified\" xml:lang=\"en\"><import > namespace=\"http://rerp.oio.dk/ebxml/xml/schemas/dkcc/2005/03/15/\" > schemaLocation=\"http://rep.oio.dk/ebxml/xml/schemas/dkcc/2005/03/15/DKC > C_PostCodeIdentifier.xsd\"/><import > namespace=\"http://rep.oio.dk/ebxml/xml/schemas/dkcc/2005/03/15/\" > schemaLocation=\"http://rep.oio.dk/ebxml/xml/schemas/dkcc/2005/03/15/DKC > C_DistrictName.xsd\"/><import > namespace=\"http://rep.oio.dk/ebxml/xml/schemas/dkcc/2005/03/15/\" > schemaLocation=\"http://rep.oio.dk/ebxml/xml/schemas/dkcc/2005/03/15/DKC > C_StreetName.xsd\"/><import > namespace=\"http://rep.oio.dk/ebxml/xml/schemas/dkcc/2003/02/13/\" > schemaLocation=\"http://rep.oio.dk/ebxml/xml/schemas/dkcc/2003/02/13/DKC > C_StreetBuildingIdentifier.xsd\"/><import > namespace=\"http://rep.oio.dk/ebxml/xml/schemas/dkcc/2005/03/15/\" > schemaLocation=\"http://rep.oio.dk/ebxml/xml/schemas/dkcc/2005/03/15/DKC > C_DistrictSubdivisionIdentifier.xsd\"/><import > namespace=\"http://rep.oio.dk/ebxml/xml/schemas/dkcc/2003/02/13/\" > schemaLocation=\"http://rep.oio.dk/ebxml/xml/schemas/dkcc/2003/02/13/DKC > C_FloorIdentifier.xsd\"/><import > namespace=\"http://rep.oio.dk/ebxml/xml/schemas/dkcc/2003/02/13/\" > schemaLocation=\"http://rep.oio.dk/ebxml/xml/schemas/dkcc/2003/02/13/DKC > C_SuiteIdentifier.xsd\"/><annotation><documentation/></annotation><eleme > nt name=\"InstitutionAddress\" > type=\"brugerinformation:InstitutionAddressType\"/><complexType > name=\"InstitutionAddressType\"><sequence><element > name=\"DaycareServiceName\" type=\"string\"/><element > ref=\"DKCC:StreetName\"/><element > ref=\"DKCC2:StreetBuildingIdentifier\"/><element > ref=\"DKCC2:FloorIdentifier\" minOccurs=\"0\"/><element > ref=\"DKCC2:SuiteIdentifier\" minOccurs=\"0\"/><element > ref=\"DKCC:PostCodeIdentifier\"/><element > ref=\"DKCC:DistrictName\"/><element > ref=\"DKCC:DistrictSubdivisionIdentifier\"/><element > name=\"InstitutionPhonenrText\" type=\"string\"/><element > name=\"EmailaddText\" type=\"string\"/><element name=\"WeblinkText\" > type=\"string\"/></sequence></complexType></schema>"; > String root = "InstitutionAddress"; > String namespace = > "http://rep.oio.dk/brugerinformation.dk/xml/schemas/2007/01/01/"; > > System.out.println("First define with erronous > reference"); > try { > test(xsd, root, namespace); > } catch (IllegalArgumentException e) { > e.printStackTrace(); > } > > System.out.println("\nSecond define just dummy > valid schema"); > xsd = "<?xml version=\"1.0\" > encoding=\"ISO-8859-1\"?> <schema > xmlns=\"http://www.w3.org/2001/XMLSchema\" > xmlns:brugerinformation=\"http://rep.oio.dk/brugerinformation.dk/xml/sch > emas/2007/01/01/\" > targetNamespace=\"http://rep.oio.dk/brugerinformation.dk/xml/schemas/200 > 7/01/01/\" elementFormDefault=\"qualified\" > xml:lang=\"EN\"><annotation><documentation/></annotation><element > name=\"InstitutionSpacePerkid\" > type=\"brugerinformation:InstitutionSpacePerkidType\"/><complexType > name=\"InstitutionSpacePerkidType\"><sequence><element > name=\"InstitutionSpacesqmQuantity\" > type=\"brugerinformation:InstitutionSpacesqmQuantityType\"/></sequence>< > /complexType><simpleType > name=\"InstitutionSpacesqmQuantityType\"><restriction > base=\"unsignedInt\"/></simpleType></schema>"; > root = "InstitutionSpacePerkid"; > > try { > test(xsd, root, namespace); > } catch (Exception e) { > e.printStackTrace(); > throw e; > } > } catch (Exception e) { > fail(e.toString()); > } > } > > public void test(final String xsdFile, final String rootElement, > final String namespace) throws Exception { > > System.out.println("Calling define..."); > this.helperContext.getXSDHelper().define(new > String(xsdFile.getBytes("ISO-8859-1"))); > System.out.println("Define successful..."); > > System.out.println("Calling create..."); > this.helperContext.getDataFactory().create(namespace, > rootElement + "Type"); > System.out.println("Create successful...\n"); > > return; > } > } > > ------------------ END COPY -------------------- > > > -----Original Message----- > From: kelvin goodson [mailto:[EMAIL PROTECTED] > Sent: 28. marts 2007 09:53 > To: tuscany-user@ws.apache.org > Subject: Re: SDO Java M3 Release Candidate RC1 > > Hi Christian, > could you please post some code snippets or better still a test case. > It > appears that the Type that you are trying to create an instance of is > associated with an EMF factory rather than an SDO Factory. > > On the subject of HelperContext lifecycle, there's no constraint on the > longevity of a HelperContext instance. At the moment I imagine that > each > instance would be relatively long lived, since there are no fine > grained > controls on the lifecycle of the Types within a scope. So I imagine > that > for many applications a single HelperContext will suffice for the > lifetime > of the application. > > It may be the case that in the future we provide ways of associating > HelperContexts in order that one may delegate to another/others. I can > imagine in that scenario more opportunities to control the type system > by > having short lived HelperContext instances, but as I say, we don't > have > that yet. > > Regards, Kelvin. > > > On 27/03/07, Christian Landbo Frederiksen < > [EMAIL PROTECTED]> wrote: > > > > Hi Frank et. al. > > > > I applied the fix and it helped, but I also get an error like the one > > mentioned in this thread (NullPointerException), when a referenced > > schema cannot be found! > > > > But that is not the worst part. Once I run into that error, all later > > attempts to create using a dataFactory from the context also fail, but > > this time with the following error: > > > > java.lang.ClassCastException: > > org.eclipse.emf.ecore.impl.DynamicEObjectImpl incompatible with > > commonj.sdo.DataObject > > at > > > org.apache.tuscany.sdo.helper.DataFactoryImpl.create(DataFactoryImpl.jav > > a:61) > > at > > > org.apache.tuscany.sdo.helper.DataFactoryImpl.create(DataFactoryImpl.jav > > a:46) > > > > Any ideas? > > > > Could you describe some helpercontext scenarios? I am specifically > > wondering how long the helperContext instance should live. Currently I > > am trying to use a long living context inside a singleton - imagining > it > > is the most efficient way. Is that recommendable? > > > > /Chr > > > > > > -----Original Message----- > > From: Frank Budinsky [mailto:[EMAIL PROTECTED] > > Sent: 27. marts 2007 16:27 > > To: tuscany-user@ws.apache.org > > Subject: RE: SDO Java M3 Release Candidate RC1 > > > > Hi Christian, > > > > Your schema seems to be using http:// schemaLocations. For performance > > reasons, we recently disabled that, but I guess we really shouldn't do > > that, without it being an option. We will fix it in the next driver. > > > > If you want to try it out yourself, the fix is to comment out line > 2473 > > in > > DataObjectUtil: > > > > //resourceSet.setURIConverter(new SDOURIConverterImpl()); > > > > Frank. > > > > "Christian Landbo Frederiksen" > <[EMAIL PROTECTED]> > > > > wrote on 03/27/2007 03:51:43 AM: > > > > > Hi again. > > > > > > Though my simple testcase now functions, I have run into a > nullpointer > > > exception with a schema that functions in M2. > > > > > > java.lang.NullPointerException > > > at > > > > > > org.apache.tuscany.sdo.helper.SDOXSDEcoreBuilder.getEClassifier(SDOXSDEc > > > oreBuilder.java:123) > > > > > > As far as I can tell: In BaseSDOXSDEcoreBuilder: > > > > > > protected EStructuralFeature createFeature > > > (EClass eClass, XSDElementDeclaration xsdElementDeclaration, > > > String name, XSDComponent xsdComponent, int minOccurs, int > > > maxOccurs) { > > > > > > XSDTypeDefinition elementTypeDefinition = > > > getEffectiveTypeDefinition(xsdComponent, xsdElementDeclaration); > > > > > > The call to getEffectiveTypeDefinition returns null, resulting in > the > > > nullpointer in the next call to > > > > > > EClassifier eClassifier = getEClassifier(elementTypeDefinition); > > > > > > The schema has references to other schemas and it is in the first of > > > those (StreetName) it fails. > > > > > > This is the schema I try to define: > > > > > > <?xml version="1.0" encoding="UTF-8"?> > > > <schema xmlns="http://www.w3.org/2001/XMLSchema" > > > > > > xmlns:brugerinformation="http://rep.oio.dk/brugerinformation.dk/xml/sche > > > mas/2007/01/01/" > > > xmlns:XKOM="http://rep.oio.dk/xkom.dk/xml/schemas/2006/01/06/" > > > xmlns:DKCC="http://rep.oio.dk/ebxml/xml/schemas/dkcc/2005/03/15/" > > > xmlns:DKCC2="http://rep.oio.dk/ebxml/xml/schemas/dkcc/2003/02/13/" > > > > > > targetNamespace="http://rep.oio.dk/brugerinformation.dk/xml/schemas/2007 > > > /01/01/" elementFormDefault="qualified" xml:lang="en"> > > > <import > > > namespace="http://rep.oio.dk/ebxml/xml/schemas/dkcc/2005/03/15/" > > > > > > schemaLocation="http://rep.oio.dk/ebxml/xml/schemas/dkcc/2005/03/15/DKCC > > > _PostCodeIdentifier.xsd"/> > > > <import > > > namespace="http://rep.oio.dk/ebxml/xml/schemas/dkcc/2005/03/15/" > > > > > > schemaLocation="http://rep.oio.dk/ebxml/xml/schemas/dkcc/2005/03/15/DKCC > > > _DistrictName.xsd"/> > > > <import > > > namespace="http://rep.oio.dk/ebxml/xml/schemas/dkcc/2005/03/15/" > > > > > > schemaLocation="http://rep.oio.dk/ebxml/xml/schemas/dkcc/2005/03/15/DKCC > > > _StreetName.xsd"/> > > > <import > > > namespace="http://rep.oio.dk/ebxml/xml/schemas/dkcc/2003/02/13/" > > > > > > schemaLocation="http://rep.oio.dk/ebxml/xml/schemas/dkcc/2003/02/13/DKCC > > > _StreetBuildingIdentifier.xsd"/> > > > <import > > > namespace="http://rep.oio.dk/ebxml/xml/schemas/dkcc/2005/03/15/" > > > > > > schemaLocation="http://rep.oio.dk/ebxml/xml/schemas/dkcc/2005/03/15/DKCC > > > _DistrictSubdivisionIdentifier.xsd"/> > > > <import > > > namespace="http://rep.oio.dk/ebxml/xml/schemas/dkcc/2003/02/13/" > > > > > > schemaLocation="http://rep.oio.dk/ebxml/xml/schemas/dkcc/2003/02/13/DKCC > > > _FloorIdentifier.xsd"/> > > > <import > > > namespace="http://rep.oio.dk/ebxml/xml/schemas/dkcc/2003/02/13/" > > > > > > schemaLocation="http://rep.oio.dk/ebxml/xml/schemas/dkcc/2003/02/13/DKCC > > > _SuiteIdentifier.xsd"/> > > > <annotation> > > > <documentation/> > > > </annotation> > > > <element name="InstitutionAddress" > > > type="brugerinformation:InstitutionAddressType"/> > > > <complexType name="InstitutionAddressType"> > > > <sequence> > > > <element name="DaycareServiceName" > > > type="string"/> > > > <element ref="DKCC:StreetName"/> > > > <element ref="DKCC2:StreetBuildingIdentifier"/> > > > <element ref="DKCC2:FloorIdentifier" > > > minOccurs="0"/> > > > <element ref="DKCC2:SuiteIdentifier" > > > minOccurs="0"/> > > > <element ref="DKCC:PostCodeIdentifier"/> > > > <element ref="DKCC:DistrictName"/> > > > <element > > > ref="DKCC:DistrictSubdivisionIdentifier"/> > > > <element name="InstitutionPhonenrText" > > > type="string"/> > > > <element name="EmailaddText" type="string"/> > > > <element name="WeblinkText" type="string"/> > > > </sequence> > > > </complexType> > > > </schema> > > > > > > Any ideas? > > > > > > > > > -----Original Message----- > > > From: Frank Budinsky [mailto:[EMAIL PROTECTED] > > > Sent: 26. marts 2007 19:12 > > > To: tuscany-user@ws.apache.org > > > Subject: RE: SDO Java M3 Release Candidate RC1 > > > > > > You need to get your DataFactory from the HelperContext: > > > > > > DataObject documentDataObject = > hc.getDataFactory().create(namespace, > > > "DocumentRoot"); > > > > > > You should generally stop using INSTANCE fields in all cases, > because > > > they > > > are probably going to be deprecated in the next version of SDO. > > > HelperContext is the replacement. It defines a metadata scope, so > you > > > should always use it to get the helpers for your scope. > > > > > > Frank. > > > > > > "Christian Landbo Frederiksen" > > <[EMAIL PROTECTED]> > > > > > > wrote on 03/26/2007 01:01:00 PM: > > > > > > > > > > > In M2 & M3 this works for a specific schema: > > > > > > > > XSDHelper.INSTANCE.define(new String(xsdFile.getBytes("UTF-8"))); > > > > DataObject documentDataObject = > > DataFactory.INSTANCE.create(namespace, > > > > "DocumentRoot"); > > > > > > > > But this doesn't > > > > > > > > HelperContext hc = SDOUtil.createHelperContext(true); > > > > hc.getXSDHelper().define(new String(xsdFile.getBytes("UTF-8"))); > > > > > > > > DataObject documentDataObject = > > DataFactory.INSTANCE.create(namespace, > > > > "DocumentRoot"); > > > > > > > > > > > > java.lang.IllegalArgumentException > > > > at > > > > > > > > > > org.apache.tuscany.sdo.helper.DataFactoryImpl.create(DataFactoryImpl.jav > > > > a:63) > > > > at > > > > > > > > > > org.apache.tuscany.sdo.helper.DataFactoryImpl.create(DataFactoryImpl.jav > > > > a:46) > > > > at > > > > > > > > > > sandbox.TestTypeChangesAndExtensibleNamespaces.generate(TestTypeChangesA > > > > ndExtensibleNamespaces.java:153) > > > > at > > > > > > > > > > sandbox.TestTypeChangesAndExtensibleNamespaces.main(TestTypeChangesAndEx > > > > tensibleNamespaces.java:77) > > > > > > > > > > > > Any ideas? > > > > > > > > -----Original Message----- > > > > From: Frank Budinsky [mailto:[EMAIL PROTECTED] > > > > Sent: 22. marts 2007 13:38 > > > > To: tuscany-user@ws.apache.org > > > > Subject: RE: SDO Java M3 Release Candidate RC1 > > > > > > > > Sorry, there's not much documentation, just the JavaDoc. You need > to > > > get > > > > a > > > > HelperContext by calling SDOUtil.createHelperContext() and then > get > > > your > > > > > > > > XSDHelper from it. > > > > > > > > If you want the new extensible namespaces behavior you need to > pass > > > > "true" > > > > to createHelperContext: > > > > > > > > HelperContext hc = SDOUtil.createHelperContext(true); > > > > > > > > Frank. > > > > > > > > > > > > > > > > > > > > "Christian Landbo Frederiksen" > > > <[EMAIL PROTECTED]> > > > > > > > > 03/22/2007 06:30 AM > > > > Please respond to > > > > tuscany-user@ws.apache.org > > > > > > > > > > > > To > > > > <tuscany-user@ws.apache.org> > > > > cc > > > > > > > > Subject > > > > RE: SDO Java M3 Release Candidate RC1 > > > > > > > > > > > > > > > > > > > > > > > > > > > > The testcase I used the last time does not function using SDO M3, > > but > > > I > > > > guess It is because I can't just use XSDHelper.INSTANCE. I > remember > > > > Frank > > > > mentioning something about helpercontexts. Have you got any > > > > documentation > > > > as to hov this is done. > > > > > > > > /Chr > > > > > > > > ps. the test case is the one from: > > > > > > > > > > https://issues.apache.org/jira/browse/TUSCANY-1113?page=com.atlassian.ji > > > > ra.plugin.system.issuetabpanels:comment-tabpanel#action_12473251 > > > > < > > > > > > > > > > https://webmail.topnordic.com/exchweb/bin/redir.asp?URL=https://issues.a > > > > > > > > > > pache.org/jira/browse/TUSCANY-1113?page=com.atlassian.jira.plugin.system > > > > .issuetabpanels:comment-tabpanel%23action_12473251 > > > > > > > > > > > > > > > > > > > > > ________________________________ > > > > > > > > From: kelvin goodson [mailto:[EMAIL PROTECTED] > > > > Sent: Fri 3/16/2007 9:14 AM > > > > To: tuscany-user@ws.apache.org > > > > Subject: Re: SDO Java M3 Release Candidate RC1 > > > > > > > > > > > > > > > > Christian, > > > > The required jars for EMF 2.2.2 and the SDO 2.1 API are packaged > > in > > > > the > > > > binary release. > > > > Regards, Kelvin. > > > > > > > > On 15/03/07, Christian Landbo Frederiksen < > > > > [EMAIL PROTECTED]> wrote: > > > > > > > > > > > > > > > What version of EMF and SDO api is needed for this release? > > > > > > > > > > -----Original Message----- > > > > > From: kelvin goodson [mailto:[EMAIL PROTECTED] > > > > > Sent: 15. marts 2007 16:42 > > > > > To: tuscany-dev; Tuscany Users > > > > > Subject: SDO Java M3 Release Candidate RC1 > > > > > > > > > > I have posted an SDO Java M3 release candidate here: > > > > > > > > > > > > > > > http://people.apache.org/~kelvingoodson/sdo_java/M3/RC1/<http://people.a > > > > > pache.org/%7Erobbinspg/M3-RC1/> > > > > > > > > > > Please take a look at this and try it out, so that I can pick up > > any > > > > > errors > > > > > quickly and move towards a vote on a proper release in the short > > > term. > > > > > > > > > > Thanks, Kelvin. > > > > > > > > > > > > > > --------------------------------------------------------------------- > > > > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > > > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > --------------------------------------------------------------------- > > > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > > > > > > > > > > > > --------------------------------------------------------------------- > > > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > > > > > > > > --------------------------------------------------------------------- > > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > > > > > > > --------------------------------------------------------------------- > > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]