Reply to comment
groovyws, too much of a good thing is bad;)
stitches, my grails-based project has an example client that uses the groovyws to connect to the soap services that stitches exposes. I have tests that invoke, "push, pull, prod" the web services to do all kinds of things. However, on a very regular basis, I was getting the following perplexing error:
What was perplexing was that I was able to create a class with this same proxy in another test. While I don't understand why this error is generated, I figured out a workaround. Do not create multiple proxy objects. That is, if you create a proxy in your Integration Test, don't create another one in your controller, pass the proxy to the controller from your test, and things will work. I am guessing that the classes that are generated by a Thread or classloader are private to that Thread/classloader.
org.apache.cxf.interceptor.Fault: Marshalling Error: class org.authsum.stitches.external.TagRequest nor any of its super class is known to this context.
at org.apache.cxf.jaxb.JAXBEncoderDecoder.marshall(JAXBEncoderDecoder.java:159)
at org.apache.cxf.jaxb.io.DataWriterImpl.write(DataWriterImpl.java:169)
at org.apache.cxf.interceptor.AbstractOutDatabindingInterceptor.writeParts(AbstractOutDatabindingInterceptor.java:104)
at org.apache.cxf.interceptor.BareOutInterceptor.handleMessage(BareOutInterceptor.java:68)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:226)
[javax.xml.bind.JAXBException: class org.authsum.stitches.external.TagRequest nor any of its super class is known to this context.]
at com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:328)
at com.sun.xml.bind.v2.runtime.MarshallerImpl.marshal(MarshallerImpl.java:254)
at javax.xml.bind.helpers.AbstractMarshallerImpl.marshal(AbstractMarshallerImpl.java:75)
at org.apache.cxf.jaxb.JAXBEncoderDecoder.writeObject(JAXBEncoderDecoder.java:441)
at org.apache.cxf.jaxb.JAXBEncoderDecoder.marshall(JAXBEncoderDecoder.java:138)
... 382 more
Caused by: javax.xml.bind.JAXBException: class org.authsum.stitches.external.TagRequest nor any of its super class is known to this context.
at com.sun.xml.bind.v2.runtime.XMLSerializer.reportError(XMLSerializer.java:242)
at com.sun.xml.bind.v2.runtime.XMLSerializer.reportError(XMLSerializer.java:257)
at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsXsiType(XMLSerializer.java:649)
at com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl$1.serializeBody(ElementBeanInfoImpl.java:151)
at com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl$1.serializeBody(ElementBeanInfoImpl.java:185)
at com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl.serializeBody(ElementBeanInfoImpl.java:305)
at com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl.serializeRoot(ElementBeanInfoImpl.java:312)
at com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl.serializeRoot(ElementBeanInfoImpl.java:71)
at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsRoot(XMLSerializer.java:490)
at com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:325)
... 386 more
Caused by: javax.xml.bind.JAXBException: class org.authsum.stitches.external.TagRequest nor any of its super class is known to this context.
at com.sun.xml.bind.v2.runtime.JAXBContextImpl.getBeanInfo(JAXBContextImpl.java:566)
at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsXsiType(XMLSerializer.java:644)
... 393 more
Here is an example of my integration test, I am passing my groovyws proxy:
void testSaveExistingTag() {
Long tagId = helper.getTagId(name:"testSaveExistingTag")
def controller = new TagsController()
controller.helper = helper
controller.request.parameters = ['name':"testSaveExistingTag2",id:tagId.toString()]
controller.saveTag()
//let's verify it worked
def tagHolder = helper.findTagById(tagId)
assertTrue tagHolder.name == 'testSaveExistingTag2'
}
Here is my controller:
def helper = null
def getHelper() {
if (helper == null) {
helper = new Helper()
}
return helper
}
def saveTag = {
def proxy = getHelper().getProxy()
def tagRequest = proxy.create("org.authsum.stitches.external.TagRequest")
def tagHolder = proxy.create("org.authsum.stitches.external.TagHolder")
if (!tagRequest.tagHolders) {
def tagHolders = proxy.create("org.authsum.stitches.external.ArrayOfTagHolder")
tagRequest.tagHolders = tagHolders
tagRequest.tagHolders.tagHolder.add(tagHolder)
}
bindData(tagHolder, params)
//TEMP, need to set the id manually
if (params['id']) {
tagHolder.id = params['id'].toLong()
}
def response =proxy.saveTag(tagRequest)
assert response.responseCode == '200'
flash.message = 'tag saved'
chain(action:index)
}
