File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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 EJB 3 in Action this week in the EJB and other Java EE Technologies 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: 18114

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

Joined: Sep 08, 2007
Posts: 3054

May be you could show us the code?

Mohamed Sanaulla | My Blog
I agree. Here's the link:
subject: XMLBeans and Groovy
Similar Threads
xmlBean Problem
XMLBean Extensions
XmlBean binding with webservices
xmlBean Parser.
[xmlbean] scomp giving me an exception: CreateProcess