Hey Bryan,
I think I know what the issue is. The class FooType corresponds to the complexType FooType from your schema. So, on its own, a FooType has no element name associated with it. There should be another class called FooTypeDocument; this class corresponds to the Foo global element declaration from your schema. Since XmlBeansResourceProperty#add() checks that the name of the passed-in element matches the name from that resource property's ResourcePropertyMetaData, you need to pass it a FooTypeDocument instead of a FooType. That is:
FooTypeDocument fooDoc = FooTypeDocument.Factory.newInstance();
FooType foo = fooDoc.addNewFoo();
...
prop.add(foo);
We definitely ought to add a resource prop w/ maxOccurs="unlimited" to the Filesystem example, so we can provide an example of a callback like yours. I'll file an issue for this.
-Ian
Murray, Bryan P. wrote:
Thanks Ian,
This certainly pointed me to the right place. I do have a ResourcePropertyCallback associated with this property (it is not modifiable). I am including the refresh method. The backend returns a List of objects. I then iterate through the list to regenerate the XmlBean list. Am I doing this incorectly?
public ResourceProperty refreshProperty(ResourceProperty prop) { prop.clear(); List foos = m_backendResource.getFoos(); for (int i = 0; i < foos.size(); ++i) { FooType ft = FooType.Factory.newInstance(); Foo ff = (Foo)foos.get(i); ft.setName(ff.getName());
ft.setType(TypeEnumeration.Enum.forString(ff.getType())); List spiffies = ff.getSpiffies(); for (int j = 0; j < spiffies.size(); ++j) ft.addSpiffy((byte[])spiffies.get(j));
prop.add(ft); }
return prop; }
Thanks, Bryan
-----Original Message-----
From: Ian Springer [mailto:[EMAIL PROTECTED] Sent: Friday, March 25, 2005 8:33 AM
To: [email protected]
Subject: Re: MetaDataViolationException
Hi Bryan,
It's too bad we're not logging the stack trace of the MDVE (I'll look at
remedying this). Looking at the source though, an MDVE with the message
"Property element to add must be named ..." is only thrown in one place
- XmlBeansResourceProperty#load(), which is only called in two places: XmlBeansResourceProperty#add() and the constructor of
XmlBeansResourcePropertySet. Neither of these code paths should get
touched during processing of a GetRP request. Do you by any chance have
a ResourcePropertyCallback associated with the property? Perhaps in its
refreshProperty() impl you're calling XmlBeansResourceProperty#add()?
If none of the above helps you solve the problem, then it will be necessary to attach to the JVM with a remote debugger and step through the execution of the code. If you haven't done this before, I can help you set it up; it's actually much easier than it sounds.
Ian
Murray, Bryan P. wrote:
I sent a GetResourceProperty request message to retrieve a property and
received a JAXRPCException with the following message: "Unexpected error. Cause:
org.apache.ws.resource.properties.MetaDataViolationException: Property element to add must be named ...". This is puzzling since I am just reading a property.
The type for my property looks something like: <xs:complexType name="FooType"> <xs:sequence> <xs:element name="Spiffy" type="xs:hexBinary" minOccurs="1" maxOccurs="unbounded"/> <xs:element name="Type" type="x:TypeEnumeration"/> <xs:element name="Name" type="xs:string"/> </xs:sequence> </xs:complexType> <xs:element name="Foo" type="x:FooType"/>
And the property is declared as follows in the resource property document: <xs:element ref="x:Foo" minOccurs="0" maxOccurs="unbounded"/>
The documentation for MetaDataViolationException does not indicate the conditions for which it will be thrown. The stack trace does not reach my code, so I don't know what to change.
Can you help me understand why this exception is being thrown.
Thanks, Bryan
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
