This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
The moose likes Groovy and the fly likes XMLBeans and Groovy Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Languages » Groovy
Bookmark "XMLBeans and Groovy" Watch "XMLBeans and Groovy" New topic

XMLBeans and Groovy

Robert Harvey

Joined: Nov 18, 2011
Posts: 8
I am developing in Netbeans and have 2 XMLBean libraries (Schemas1.jar, Schemas2.jar). One of my XMLBeans, Class A, is defined in Schemas1.jar. Class A contains a type, Class B, defined in Schemas2.jar. I have a Groovy class, Class MyGroovy, that operates on Class A to obtain a reference to Class B. My compilation works, but runtime produces a nullpointer exception:

at org.apache.xmlbeans.impl.schema.SchemaPropertyImpl.getType(
at org.apache.xmlbeans.impl.schema.SchemaTypeImpl.createElementType(
at org.apache.xmlbeans.impl.values.XmlObjectBase.create_element_user(
at schemas1.model.impl.ClassAImpl.getClassB(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(
at sun.reflect.DelegatingMethodAccessorImpl.invoke(
at java.lang.reflect.Method.invoke(
at org.codehaus.groovy.reflection.CachedMethod.invoke(
at groovy.lang.MetaMethod.doMethodInvoke(
at groovy.lang.MetaClassImpl$GetBeanMethodMetaProperty.getProperty(
at org.codehaus.groovy.runtime.callsite.GetEffectivePojoPropertySite.getProperty(
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGetProperty(
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGetPropertySafe(

I posted a question to the XMLBean folks, but they have not responded in over 2 weeks. Thought I would post this at CodeRanch to help me solve this. If I operate on ClassA and ClassB from a normal Java class, the nullpointer is not observed. Seems to be tied to how groovy handles "aggregate" XMLBeans objects.

Any help is much appreciated,
Paul Clapham

Joined: Oct 14, 2005
Posts: 19864

Sounds like a Groovy question to me, and we have a Groovy forum. Moving...
Mohamed Sanaulla
Saloon Keeper

Joined: Sep 08, 2007
Posts: 3151

May be you could show us the code?

Mohamed Sanaulla | My Blog
It is sorta covered in the JavaRanch Style Guide.
subject: XMLBeans and Groovy
It's not a secret anymore!