[groovy-user] MissingProperty Exception due to JAXB?

20 views
Skip to first unread message

dynaMate

unread,
Feb 7, 2010, 6:43:40 PM2/7/10
to us...@groovy.codehaus.org

My environment is: Java 1.6 and Groovy 1.7.0, Jaxb library shipped with Java
1.6, no other 3rd party libarary.
the command i use to compile and run are:
groovyc -j UseDSL.java PayDSL.groovy -Jsource 1.6
java -classpath
%GROOVY_HOME%\embeddable\groovy-all-1.7.0.jar;paypal_platform_base.jar;paypal_platform_stubs.jar;.
UseDSL

I am getting the following exception and my guess is it is not able to find
JAXB library or some class. Unfortunately the exception does not tell me
which class it is not able to find in CP. How can i debug further and make
the missing JDK/JAXB classes in the classpath? Is it necessary? Or what is
the right thing to do? I have uploaded the entire source in a zip file.
INFO: The requests and reponses from PayPal webservices will be logged to
the file: paypal_sdk.log
Exception in thread "main" groovy.lang.MissingPropertyException: No such
property: result for class: Script1
at
org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:49)
at
org.codehaus.groovy.runtime.callsite.PogoGetPropertySite.getProperty(PogoGetPropertySite.java:49)
at
org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGroovyObjectGetProperty(AbstractCallSite.java:241)
at Script1$_run_closure1.doCall(Script1.groovy:4)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at
org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:88)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233)
at
org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:272)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:886)
at
org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:39)
at
org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:40)
at
org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:117)
at
org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:121)
at PayDSL.process(PayDSL.groovy:121)
at UseDSL.main(UseDSL.java:9)

This is a time critical project, I appreciate your help greatly..
-Regards http://old.nabble.com/file/p27493620/labrats.zip labrats.zip
--
View this message in context: http://old.nabble.com/MissingProperty-Exception-due-to-JAXB--tp27493620p27493620.html
Sent from the groovy - user mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email


Jackie Gleason

unread,
Feb 7, 2010, 6:48:17 PM2/7/10
to us...@groovy.codehaus.org
Have you declared your classes manually? The default doesn't work so you have to manually specify @elements

Jackie

dynaMate

unread,
Feb 7, 2010, 7:18:33 PM2/7/10
to us...@groovy.codehaus.org

Thanks for prompt reply
Well, i have imported all the classes i need or use directly in my groovy
script in the groovy script. I do not know transtive dependant classes. The
thing is it(groovyscript) has NOT complained on the statements involving
direct java classes i have implemented or i've explicitly imported..
I'm a newbie..i'm not sure how to use @elements? can you give an example..

--
View this message in context: http://old.nabble.com/MissingProperty-Exception-due-to-JAXB--tp27493620p27493833.html

Jackie Gleason

unread,
Feb 7, 2010, 10:13:14 PM2/7/10
to us...@groovy.codehaus.org
sorry look up 

@XmlAccessorType(XmlAccessType.NONE)

There are three ways this can be set you need to set it to none and then make sure you have @ element on all of the properties (or getters/setters) you have then JAXB should work, if you set it to anything else weird things can happen

Hope this helps.

Jackie

Jackie Gleason

unread,
Feb 7, 2010, 10:13:35 PM2/7/10
to us...@groovy.codehaus.org
Er @XmlElement or something like that

dynaMate

unread,
Feb 8, 2010, 2:17:09 PM2/8/10
to us...@groovy.codehaus.org

well, i get unable to resolve class XmlElement error or unable to resolve
class XmlAccessorType when i use the annotations you suggested...what is the
right value? I'm struck here...where can i lookup?

thanks

--
View this message in context: http://old.nabble.com/MissingProperty-Exception-due-to-JAXB--tp27493620p27504824.html

dynaMate

unread,
Feb 8, 2010, 4:39:00 PM2/8/10
to us...@groovy.codehaus.org

Just want to clarify that, i'm not using GroovyWS library...I depend on JAXB
library shipped wiht Java 1.6.

My feeling is it is bug in Groovy...Only Groovy expert can help
me...thanks..

--
View this message in context: http://old.nabble.com/MissingProperty-Exception-due-to-JAXB--tp27493620p27506679.html

Paul King

unread,
Feb 8, 2010, 5:32:41 PM2/8/10
to us...@groovy.codehaus.org

Perhaps the JAXB slides (52-53) or Jersey slides (59-61) in this
presentation will help you:

http://www.slideshare.net/paulk_asert/xml-and-web-services-with-groovy-presentation

(The JAXB example has the 'build' dir in the classpath.
See the wsimport line. The Jersey one has all the Jersey jar files
in the classpath).

Another (RESTful) Jersey example:

/////////////////////////////////
package com.asert

import javax.xml.bind.annotation.*
import javax.ws.rs.*
import com.sun.jersey.api.container.httpserver.HttpServerFactory
import groovy.xml.MarkupBuilder

@XmlRootElement
@XmlAccessorType (XmlAccessType.FIELD)
final class Song {
@XmlElement String name
@XmlElement int duration
@XmlElement Artist artist
}
@XmlRootElement
@XmlAccessorType (XmlAccessType.FIELD)
final class Artist {
@XmlElement String name
}

class SongList {
static song(sn, d, an) { new Song(name:sn, duration:d, artist:new Artist(name:an)) }
static songs = [song("S1", 5, "A1"), song("S2", 8, "A2"), song("S3", 13, "A3")]
}

@Path ("/songs/{listId}")
class SongListResource {
@GET @Produces(["text/xml", "application/json", "application/atom"])
Song getList(@PathParam('listId') String listId) {
SongList.songs[listId as int]
}
}
//<name>S2</name><duration>8</duration><artist><name>A2</name></artist>
@Path ("/songsxml/{listId}")
class SongXmlResource {
@GET @Produces("text/xml")
String getSong(@PathParam('listId') String listId) {
def s = SongList.songs[listId as int]
def sw = new StringWriter()
new MarkupBuilder(sw).song{
name(s.name)
duration(s.duration)
artist{ name(s.artist.name) }
}
sw.toString()
}
}

def baseUri = "http://localhost:9998/"

println """
Starting HTTP server with Jersey...
App WADL available at ${baseUri}application.wadl
App available at ${baseUri}songs/listId
"""
HttpServerFactory.create(baseUri).start()
/////////////////////////////////


Cheers, Paul.

dynaMate

unread,
Feb 8, 2010, 7:02:46 PM2/8/10
to us...@groovy.codehaus.org

Thank you for your reply. It helped me to think and ask this question. The
runtime exception i'm getting
is perhaps due to the dependancy on the my own class ( which is in a jar
file and specified in the classpath as posted) not compiled as part of
groovyc -j compilation? I have developed a library purely using Java and my
new Groovy script import those library classes. The library classes in-turn
depend on Jaxb. My question is should the library be compiled as part of
groovyc command? I guess not.

Since Groovy script does not directly use anu JAXB dependant classes your
slides or example didn't help much. I have uploaded complete source code in
a zip which gives a good picture and it is fairly simple code...groovy
script in question is less than 20 lines... the issue is in getResult and
during the
call ap.pay(request) which depend on JAXB.

--
View this message in context: http://old.nabble.com/MissingProperty-Exception-due-to-JAXB--tp27493620p27508439.html

dynaMate

unread,
Feb 18, 2010, 11:02:21 PM2/18/10
to us...@groovy.codehaus.org

The issue turned out be silly and simpler to fix..

some how the GetResult method was not recognized as 'result" property as per
the artilce
http://www.javaworld.com/javaworld/jw-09-2008/jw-09-dsls-in-java-4.html?page=4.

I do not know what other step either the article or the script i wrote is
missig

--
View this message in context: http://old.nabble.com/MissingProperty-Exception-due-to-JAXB--tp27493620p27649518.html

Reply all
Reply to author
Forward
0 new messages