1

Updated to reflect new error message after changes

Howdy, I am trying to call a web service from Grails, but keep running in to errors.

Here's what my class looks like:

import groovyx.net.ws.WSClient

...

    def serviceUrl = "http://www.w3schools.com/webservices/tempconvert.asmx?WSDL"
    def proxy = new WSClient(serviceUrl.toString(), this.class.classLoader)
    serviceResult = proxy.FahrenheitToCelsius("80")
    println serviceResult

...

I am encountering a grails runtime exception:

Error 500: Executing action [index] of controller [myPackage.myController] caused exception: java.lang.NoClassDefFoundError: org/apache/cxf/endpoint/Client

Have been trying to troubleshoot, but have been unable to find any helpful resources. Any help or suggestions on how to remedy would be much appreciated.

Thanks.

Jason MacLean
  • 513
  • 6
  • 15

1 Answers1

0

You missed the new operator it looks like:

def proxy = new WSClient(serviceUrl.toString(), this.class.classLoader)
tim_yates
  • 167,322
  • 27
  • 342
  • 338
  • Big oversight by me, haha... however a new error now exists: Error 500: Executing action [index] of controller [myPackage.myController] caused exception: java.lang.NoClassDefFoundError: org/apache/cxf/endpoint/Client – Jason MacLean Feb 24 '11 at 14:22
  • That looks like you're missing a dependency... how are you getting the required libs on the classpath? Using `@Grab` like it says on the documentation works for me... http://groovy.codehaus.org/GroovyWS – tim_yates Feb 24 '11 at 14:29
  • Getting an 'error grabbing grapes' runtime exception while trying to run the grails application if I include that @Grab line. Saying org.codehaus.groovy.modules#groovyws;0.5.2: not found. I had already put groovyws-0.5.2.jar in my lib file, and I thought it was being imported, but I'll try fussing around with that @grab to see if I can get it working. – Jason MacLean Feb 24 '11 at 14:45
  • Just putting the single jar in lib won't be enough... It has a fair few dependencies: http://mvnrepository.com/artifact/org.codehaus.groovy.modules/groovyws/0.5.2 (26 of them) – tim_yates Feb 24 '11 at 15:51
  • Thanks Tim... was able to find all the dependencies I needed and the call is now working! – Jason MacLean Feb 24 '11 at 16:03