Consume web service in Grails app

Consume web service in Grails app

Hi,in my Grails evaluation project I am now fighting web services support in Grails. Following what I found in the net I tries to use GroovyWS (0.5.1) together with the CXF plugin (0.5.1) - my Grails version is 1.2.1.
However I seem to be trapped in the kind of jar incompatibility situation that some others have reported in the web as well:

java.lang.LinkageError: loader constraint violation: when resolving interface
method
"org.w3c.dom.Node.setUserData(Ljava/lang/String;Ljava/lang/Object;Lorg/w3c/dom/UserDataHandler;)Ljava/lang/Object;"
the class loader (instance of
org/codehaus/groovy/grails/cli/support/GrailsRootLoader) of the current class,
org/apache/cxf/staxutils/StaxUtils, and the class loader (instance of
<bootloader>) for resolved class, org/w3c/dom/Node, have different Class
objects for the type org/w3c/dom/UserDataHandler used in the signature

> Hi,
> in my Grails evaluation project I am now fighting web services support in Grails. Following what I found in the net I tries to use GroovyWS (0.5.1) together with the CXF plugin (0.5.1) - my Grails version is 1.2.1.
> However I seem to be trapped in the kind of jar incompatibility situation that some others have reported in the web as well:
>
> java.lang.LinkageError: loader constraint violation: when resolving interface method "org.w3c.dom.Node.setUserData(Ljava/lang/String;Ljava/lang/Object;Lorg/w3c/dom/UserDataHandler;)Ljava/lang/Object;" the class loader (instance of org/codehaus/groovy/grails/cli/support/GrailsRootLoader) of the current class, org/apache/cxf/staxutils/StaxUtils, and the class loader (instance of <bootloader>) for resolved class, org/w3c/dom/Node, have different Class objects for the type org/w3c/dom/UserDataHandler used in the signature
>
> Any idea how a working configuration could look like?
>
> Thanks

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

Re: Consume web service in Grails app

Re: Consume web service in Grails app

Hi There,

I got the same problem by consuming a webservice with groovyws. That's the stacktrace:

ERROR errors.GrailsExceptionResolver - Exception occurred when processing request: [POST] /WSTS/webService/operationCall - parameters:
to: Fahrenheit
submit: Convert
value: 10.0
from: Fahrenheit
Stacktrace follows:
org.codehaus.groovy.grails.web.servlet.mvc.exceptions.ControllerExecutionException: Executing action [operationCall] of controller [wsts.WebServiceController] caused exception: java.lang.LinkageError: loader constraint violation: when resolving interface method "org.w3c.dom.Node.setUserData(Ljava/lang/String;Ljava/lang/Object;Lorg/w3c/dom/UserDataHandler;)Ljava/lang/Object;" the class loader (instance of org/codehaus/groovy/grails/cli/support/GrailsRootLoader) of the current class, org/apache/cxf/staxutils/StaxUtils, and the class loader (instance of <bootloader>) for resolved class, org/w3c/dom/Node, have different Class objects for the type org/w3c/dom/UserDataHandler used in the signature
at java.lang.Thread.run(Thread.java:662)
Caused by: org.codehaus.groovy.runtime.InvokerInvocationException: java.lang.LinkageError: loader constraint violation: when resolving interface method "org.w3c.dom.Node.setUserData(Ljava/lang/String;Ljava/lang/Object;Lorg/w3c/dom/UserDataHandler;)Ljava/lang/Object;" the class loader (instance of org/codehaus/groovy/grails/cli/support/GrailsRootLoader) of the current class, org/apache/cxf/staxutils/StaxUtils, and the class loader (instance of <bootloader>) for resolved class, org/w3c/dom/Node, have different Class objects for the type org/w3c/dom/UserDataHandler used in the signature
... 1 more
Caused by: java.lang.LinkageError: loader constraint violation: when resolving interface method "org.w3c.dom.Node.setUserData(Ljava/lang/String;Ljava/lang/Object;Lorg/w3c/dom/UserDataHandler;)Ljava/lang/Object;" the class loader (instance of org/codehaus/groovy/grails/cli/support/GrailsRootLoader) of the current class, org/apache/cxf/staxutils/StaxUtils, and the class loader (instance of <bootloader>) for resolved class, org/w3c/dom/Node, have different Class objects for the type org/w3c/dom/UserDataHandler used in the signature
at org.apache.cxf.staxutils.StaxUtils.addLocation(StaxUtils.java:941)
at org.apache.cxf.staxutils.StaxUtils.startElement(StaxUtils.java:799)
at org.apache.cxf.staxutils.StaxUtils.readDocElements(StaxUtils.java:868)
at org.apache.cxf.staxutils.StaxUtils.read(StaxUtils.java:755)
at org.apache.cxf.wsdl11.WSDLManagerImpl.loadDefinition(WSDLManagerImpl.java:217)
at org.apache.cxf.wsdl11.WSDLManagerImpl.getDefinition(WSDLManagerImpl.java:161)
at org.apache.cxf.wsdl11.WSDLServiceFactory.<init>(WSDLServiceFactory.java:67)
at org.apache.cxf.endpoint.ClientImpl.<init>(ClientImpl.java:148)
at org.apache.cxf.endpoint.dynamic.DynamicClientFactory.createClient(DynamicClientFactory.java:253)
at org.apache.cxf.endpoint.dynamic.DynamicClientFactory.createClient(DynamicClientFactory.java:196)
at org.apache.cxf.endpoint.dynamic.DynamicClientFactory.createClient(DynamicClientFactory.java:175)
at groovyx.net.ws.AbstractCXFWSClient.createClient(AbstractCXFWSClient.java:229)
at groovyx.net.ws.WSClient.initialize(WSClient.java:108)
at groovyx.net.ws.IWSClient$initialize.call(Unknown Source)
at wsts.WebServiceController$_closure4.doCall(WebServiceController.groovy:31)
at wsts.WebServiceController$_closure4.doCall(WebServiceController.groovy)
... 1 more

Re: Consume web service in Grails app

Very much thanks to you Ronny! I had tried to getting this example to
run for a few days in different ways. For anyone else having the same
problem, my BuildConfig.groovy now looks like:
- Zitierten Text ausblenden -

Re: Consume web service in Grails app

I used your BuildConfig.groovy to make WSclinet working but i still got error:

Error 500: Executing action [conversion] of controller [wstest.TemperatureController] caused exception: java.lang.LinkageError: loader constraint violation: when resolving interface method "org.w3c.dom.Node.setUserData(Ljava/lang/String;Ljava/lang/Object;Lorg/w3c/dom/UserDataHandler;)Ljava/lang/Object;" the class loader (instance of org/codehaus/groovy/grails/cli/support/GrailsRootLoader) of the current class, org/apache/cxf/staxutils/StaxUtils, and the class loader (instance of <bootloader>) for resolved class, org/w3c/dom/Node, have different Class objects for the type org/w3c/dom/UserDataHandler used in the signature

Re: Consume web service in Grails app

> the class loader (instance of
> org/codehaus/groovy/grails/cli/support/GrailsRootLoader) of the current
> class, org/apache/cxf/staxutils/StaxUtils, and the class loader (instance of
> <bootloader>) for resolved class, org/w3c/dom/Node, have different Class
> objects for the type org/w3c/dom/UserDataHandler used in the signature

Your class loader is different than the one which loaded the class originally.

How are you passing the class loader to the WSClient?

Rob

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

Re: Consume web service in Grails app

I have nearly completed work and documentation on a cxf client plugin. You can find the source for the plugin here https://github.com/ctoestreich/cxf-client. I found the current plugins a bit cumbersome for consuming soap services. It was especially slow consuming wsdls that were complex and large due to ws client dynamically recreating the proxy service and objects every time.

If you are consuming soap services this offers a pretty easy and fast alternative to existing plugins.

This plugin is still a wip and I am still testing un/pw secured services with wss4j, so that might not be working 100%, but simple services not backed with credentials should be working. You will have to get code and refer to the plugin inline in the buildconfig or do a package-plugin and put the zip into your lib dir or install it from the file system for now.

Re: Consume web service in Grails app

You have two instances of org.w3c.dom.UserDatahandler in your classpath. One of them is the one included in Java 6. You need to find the other one, and exclude it. The usual suspect is xml-apis.
If you use IntelliJ, you can use "Go To" --> "Class..." and type in "UserDataHandler". If your using Eclipse, there's "Open Type" if I remember correctly. Or you can use some command line grepping.
If you get more than one result, you have your problem right there.

build ":tomcat:$grailsVersion"
}
}
and i m using ubuntu 12.04.......what i should do.........................
no plugin have been added though i have tried,but unsuccessful...................................
plz guide me what i should do n prerequuisite for calling a web service in grails 2.0.3..................proxy() initialise is having some error??????????????????????????