[groovy-user] Can't get first groovyWS example to work with @Grab

120 views
Skip to first unread message

baltner

unread,
May 22, 2011, 10:12:32 AM5/22/11
to us...@groovy.codehaus.org
Greetings:

I am trying to get started with groovyWS but it really is an uphill battle
since I can't even get the first example posted to
http://groovy.codehaus.org/GroovyWS to work, namely:

@Grab(group='org.codehaus.groovy.modules', module='groovyws',
version='0.5.2')
import groovyx.net.ws.WSClient

proxy = new
WSClient("http://www.w3schools.com/webservices/tempconvert.asmx?WSDL",
this.class.classLoader)
proxy.initialize()

result = proxy.CelsiusToFahrenheit(0)
println "You are probably freezing at ${result} degrees Farhenheit"

What I am getting, consistently, is a java.lang.NoClassDefFoundError:
org/apache/cxf/endpoint/Client. I have installed the grapeConfig.xml, I
have javac in my PATH, and I'm using the latest groovy distribution
(includes Ivy 2.2). Running the script adds 58 jars to my .grrovy/grapes
directory, including org.apache.cxf which contains a cxf bundle that
includes org.apache.cxf.endpoint.Client.

I have Googled this to death, read all the Groovy Nabble postings (I think)
on the subject, but it just doesn't work on my system (Mac OS X 10.6.7 java
version "1.6.0_24"). I've tried emptying my .groovy/lib to resolve
conflicts, but obviously it still needs the groovyws jar. As soon as I put
that back I get the error.

I did get it to work by dumping the entire org.apache.cxf library into
.groovy/lib but a secondary goal is to learn how to use the Grape dependency
management system so this isn't very satisfactory. I also tried another
suggestion, to use the groovyws-standalone-0.2.0.jar instead of
groovyws-0.5.2.jar but this just gave me a different error:
java.lang.NoClassDefFoundError: org/springframework/beans/BeansException. I
have spent many hours trying to solve this. Can it really be this hard? At
one point Guillaume Laforge indicated that yes, it WAS this hard, because if
the cxf dependencies. But isn't this what Grape is supposed to solve?

Anyway, lots of others have encountered this issue but I have yet to find a
solution that will work other than manually adding all the cxf jars.

Thanks in advance for any help.

Bruce

--
View this message in context: http://groovy.329449.n5.nabble.com/Can-t-get-first-groovyWS-example-to-work-with-Grab-tp4416779p4416779.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


steve

unread,
May 22, 2011, 4:20:55 PM5/22/11
to us...@groovy.codehaus.org
Hi Bruce

I too have been playing with GroovyWS recently.

I don't know if this helps, but the example code works out of the box on
windows, when I run the code from GroovyConsole version 1.7.10 under java
version "1.6.0_20". I've attached my console output, maybe this helps? I'd
be interested to see your console output too...

My only other observation is that in order to get this going on a work PC I
had to make some proxy settings - see http://groovy.codehaus.org/Grape under
'Proxy settings'

Is it worth trying this on another OS just to gain confidence? Or perhaps
groovy v 1.7 - from your post it sounds like you're using 1.8...

I'd be really interested to hear how you get on with this. GroovyWS seems
like a really useful tool, however there doesn't seem to be a huge amount of
support for it on this forum; it would be great if we could build up more of
a community to support each others' issues...

Steve


groovy> @Grab(group='org.codehaus.groovy.modules', module='groovyws',
version='0.5.2')
groovy> import groovyx.net.ws.WSClient
groovy> proxy = new

groovy> proxy.initialize()
groovy> result = proxy.CelsiusToFahrenheit(0)
groovy> println "You are probably freezing at ${result} degrees Farhenheit"

22-May-2011 20:51:27
org.springframework.context.support.AbstractApplicationContext
prepareRefresh

INFO: Refreshing org.apache.cxf.bus.spring.BusApplicationContext@2f360cf9:
display name [org.apache.cxf.bus.spring.BusApplicationContext@2f360cf9];
startup date [Sun May 22 20:51:27 BST 2011]; root of context hierarchy
22-May-2011 20:51:27
org.springframework.beans.factory.xml.XmlBeanDefinitionReader
loadBeanDefinitions

INFO: Loading XML bean definitions from class path resource
[META-INF/cxf/cxf.xml]
22-May-2011 20:51:27 org.apache.cxf.bus.spring.SpringBusFactory
createApplicationContext

WARNING: Initial attempt to crate application context was unsuccessful.

org.springframework.beans.factory.BeanDefinitionStoreException: IOException
parsing XML document from class path resource [META-INF/cxf/cxf.xml]; nested
exception is java.io.FileNotFoundException: class path resource
[META-INF/cxf/cxf.xml] cannot be opened because it does not exist

at
org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:349)

at
org.apache.cxf.bus.spring.ControlledValidationXmlBeanDefinitionReader.loadBeanDefinitions(ControlledValidationXmlBeanDefinitionReader.java:131)

at
org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:310)

at
org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:143)

at
org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:109)

at
org.apache.cxf.bus.spring.BusApplicationContext.loadBeanDefinitions(BusApplicationContext.java:262)

at
org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:123)

at
org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:422)

at
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:352)

at
org.apache.cxf.bus.spring.BusApplicationContext.<init>(BusApplicationContext.java:91)

at
org.apache.cxf.bus.spring.SpringBusFactory.createApplicationContext(SpringBusFactory.java:102)

at
org.apache.cxf.bus.spring.SpringBusFactory.createBus(SpringBusFactory.java:93)

at
org.apache.cxf.bus.spring.SpringBusFactory.createBus(SpringBusFactory.java:86)

at
org.apache.cxf.bus.spring.SpringBusFactory.createBus(SpringBusFactory.java:64)

at
org.apache.cxf.bus.spring.SpringBusFactory.createBus(SpringBusFactory.java:53)

at org.apache.cxf.BusFactory.getDefaultBus(BusFactory.java:69)

at org.apache.cxf.BusFactory.getThreadDefaultBus(BusFactory.java:106)

at org.apache.cxf.BusFactory.getThreadDefaultBus(BusFactory.java:97)

at
org.apache.cxf.endpoint.dynamic.DynamicClientFactory.newInstance(DynamicClientFactory.java:132)

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
org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:40)

at
org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)

at
org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:120)

at ConsoleScript0.run(ConsoleScript0:5)

at
groovy.lang.GroovyShell.runScriptOrMainOrTestOrRunnable(GroovyShell.java:266)

at groovy.lang.GroovyShell.run(GroovyShell.java:517)

at groovy.lang.GroovyShell.run(GroovyShell.java:172)

at groovy.lang.GroovyShell$run.call(Unknown Source)

at
org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:40)

at
org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)

at
org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:132)

at groovy.ui.Console$_runScriptImpl_closure16.doCall(Console.groovy:904)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

at java.lang.reflect.Method.invoke(Method.java:597)

at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)

at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233)

at
org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:273)

at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:886)

at
org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:66)

at
org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:44)

at
org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:141)

at
org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:149)

at groovy.ui.Console$_runScriptImpl_closure16.doCall(Console.groovy)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

at java.lang.reflect.Method.invoke(Method.java:597)

at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)

at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233)

at
org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:273)

at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:886)

at groovy.lang.Closure.call(Closure.java:282)

at groovy.lang.Closure.call(Closure.java:277)

at groovy.lang.Closure.run(Closure.java:360)

at java.lang.Thread.run(Thread.java:619)

Caused by: java.io.FileNotFoundException: class path resource
[META-INF/cxf/cxf.xml] cannot be opened because it does not exist

at
org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:143)

at
org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:336)

... 58 more
22-May-2011 20:51:27
org.springframework.context.support.AbstractApplicationContext
prepareRefresh

INFO: Refreshing org.apache.cxf.bus.spring.BusApplicationContext@7e1fb64:
display name [org.apache.cxf.bus.spring.BusApplicationContext@7e1fb64];
startup date [Sun May 22 20:51:27 BST 2011]; root of context hierarchy
22-May-2011 20:51:28
org.springframework.beans.factory.support.DefaultListableBeanFactory
registerBeanDefinition

INFO: Overriding bean definition for bean
'org.apache.cxf.transport.http.policy.HTTPClientAssertionBuilder': replacing
[Generic bean: class
[org.apache.cxf.transport.http.policy.HTTPClientAssertionBuilder];
scope=singleton; abstract=false; lazyInit=false; autowireMode=0;
dependencyCheck=0; autowireCandidate=true; primary=false;
factoryBeanName=null; factoryMethodName=null; initMethodName=null;
destroyMethodName=null; defined in URL
[jar:file:/C:/Users/steve/.groovy/grapes/org.apache.cxf/cxf-bundle/bundles/cxf-bundle-2.2.7.jar!/META-INF/cxf/cxf-extension-http.fixml]]
with [Generic bean: class
[org.apache.cxf.transport.http.policy.HTTPClientAssertionBuilder];
scope=singleton; abstract=false; lazyInit=false; autowireMode=0;
dependencyCheck=0; autowireCandidate=true; primary=false;
factoryBeanName=null; factoryMethodName=null; initMethodName=null;
destroyMethodName=null; defined in URL
[jar:file:/C:/Users/steve/.groovy/grapes/org.apache.cxf/cxf-bundle/bundles/cxf-bundle-2.2.7.jar!/META-INF/cxf/cxf-extension-http.fixml]]
22-May-2011 20:51:28
org.springframework.beans.factory.support.DefaultListableBeanFactory
registerBeanDefinition

INFO: Overriding bean definition for bean
'org.apache.cxf.transport.http.policy.HTTPServerAssertionBuilder': replacing
[Generic bean: class
[org.apache.cxf.transport.http.policy.HTTPServerAssertionBuilder];
scope=singleton; abstract=false; lazyInit=false; autowireMode=0;
dependencyCheck=0; autowireCandidate=true; primary=false;
factoryBeanName=null; factoryMethodName=null; initMethodName=null;
destroyMethodName=null; defined in URL
[jar:file:/C:/Users/steve/.groovy/grapes/org.apache.cxf/cxf-bundle/bundles/cxf-bundle-2.2.7.jar!/META-INF/cxf/cxf-extension-http.fixml]]
with [Generic bean: class
[org.apache.cxf.transport.http.policy.HTTPServerAssertionBuilder];
scope=singleton; abstract=false; lazyInit=false; autowireMode=0;
dependencyCheck=0; autowireCandidate=true; primary=false;
factoryBeanName=null; factoryMethodName=null; initMethodName=null;
destroyMethodName=null; defined in URL
[jar:file:/C:/Users/steve/.groovy/grapes/org.apache.cxf/cxf-bundle/bundles/cxf-bundle-2.2.7.jar!/META-INF/cxf/cxf-extension-http.fixml]]
22-May-2011 20:51:28
org.springframework.beans.factory.support.DefaultListableBeanFactory
registerBeanDefinition

INFO: Overriding bean definition for bean
'org.apache.cxf.transport.http.policy.NoOpPolicyInterceptorProvider':
replacing [Generic bean: class
[org.apache.cxf.transport.http.policy.NoOpPolicyInterceptorProvider];
scope=singleton; abstract=false; lazyInit=false; autowireMode=0;
dependencyCheck=0; autowireCandidate=true; primary=false;
factoryBeanName=null; factoryMethodName=null; initMethodName=null;
destroyMethodName=null; defined in URL
[jar:file:/C:/Users/steve/.groovy/grapes/org.apache.cxf/cxf-bundle/bundles/cxf-bundle-2.2.7.jar!/META-INF/cxf/cxf-extension-http.fixml]]
with [Generic bean: class
[org.apache.cxf.transport.http.policy.NoOpPolicyInterceptorProvider];
scope=singleton; abstract=false; lazyInit=false; autowireMode=0;
dependencyCheck=0; autowireCandidate=true; primary=false;
factoryBeanName=null; factoryMethodName=null; initMethodName=null;
destroyMethodName=null; defined in URL
[jar:file:/C:/Users/steve/.groovy/grapes/org.apache.cxf/cxf-bundle/bundles/cxf-bundle-2.2.7.jar!/META-INF/cxf/cxf-extension-http.fixml]]
22-May-2011 20:51:28
org.springframework.beans.factory.support.DefaultListableBeanFactory
registerBeanDefinition

INFO: Overriding bean definition for bean
'org.apache.cxf.transport.http.ClientOnlyHTTPTransportFactory': replacing
[Generic bean: class
[org.apache.cxf.transport.http.ClientOnlyHTTPTransportFactory];
scope=singleton; abstract=false; lazyInit=true; autowireMode=0;
dependencyCheck=0; autowireCandidate=true; primary=false;
factoryBeanName=null; factoryMethodName=null; initMethodName=null;
destroyMethodName=null; defined in URL
[jar:file:/C:/Users/steve/.groovy/grapes/org.apache.cxf/cxf-bundle/bundles/cxf-bundle-2.2.7.jar!/META-INF/cxf/cxf-extension-http.fixml]]
with [Generic bean: class
[org.apache.cxf.transport.http.ClientOnlyHTTPTransportFactory];
scope=singleton; abstract=false; lazyInit=true; autowireMode=0;
dependencyCheck=0; autowireCandidate=true; primary=false;
factoryBeanName=null; factoryMethodName=null; initMethodName=null;
destroyMethodName=null; defined in URL
[jar:file:/C:/Users/steve/.groovy/grapes/org.apache.cxf/cxf-bundle/bundles/cxf-bundle-2.2.7.jar!/META-INF/cxf/cxf-extension-http.fixml]]
22-May-2011 20:51:28
org.springframework.context.support.AbstractApplicationContext
obtainFreshBeanFactory

INFO: Bean factory for application context
[org.apache.cxf.bus.spring.BusApplicationContext@7e1fb64]:
org.springframework.beans.factory.support.DefaultListableBeanFactory@1f37cadb
22-May-2011 20:51:29
org.springframework.beans.factory.support.DefaultListableBeanFactory
preInstantiateSingletons

INFO: Pre-instantiating singletons in
org.springframework.beans.factory.support.DefaultListableBeanFactory@1f37cadb:
defining beans
[cxf,org.apache.cxf.bus.spring.BusApplicationListener,org.apache.cxf.bus.spring.BusWiringBeanFactoryPostProcessor,org.apache.cxf.bus.spring.Jsr250BeanPostProcessor,org.apache.cxf.bus.spring.BusExtensionPostProcessor,org.apache.cxf.resource.ResourceManager,org.apache.cxf.configuration.Configurer,org.apache.cxf.binding.BindingFactoryManager,org.apache.cxf.transport.DestinationFactoryManager,org.apache.cxf.transport.ConduitInitiatorManager,org.apache.cxf.wsdl.WSDLManager,org.apache.cxf.phase.PhaseManager,org.apache.cxf.workqueue.WorkQueueManager,org.apache.cxf.buslifecycle.BusLifeCycleManager,org.apache.cxf.endpoint.ServerRegistry,org.apache.cxf.endpoint.ServerLifeCycleManager,org.apache.cxf.endpoint.ClientLifeCycleManager,org.apache.cxf.transports.http.QueryHandlerRegistry,org.apache.cxf.endpoint.EndpointResolverRegistry,org.apache.cxf.headers.HeaderManager,org.apache.cxf.catalog.OASISCatalogManager,org.apache.cxf.endpoint.ServiceContractResolverRegistry,org.apache.cxf.binding.corba.CorbaBindingFactory,org.apache.cxf.binding.corba.wsdl.WSDLExtensionRegister#0,org.apache.cxf.jaxws.context.WebServiceContextResourceResolver,org.apache.cxf.jaxws.context.WebServiceContextImpl,org.apache.cxf.binding.soap.SoapBindingFactory,org.apache.cxf.binding.soap.SoapTransportFactory,org.apache.cxf.binding.soap.customEditorConfigurer,org.apache.cxf.binding.xml.XMLBindingFactory,org.apache.cxf.ws.addressing.policy.AddressingAssertionBuilder,org.apache.cxf.ws.addressing.policy.AddressingPolicyInterceptorProvider,org.apache.cxf.ws.addressing.policy.UsingAddressingAssertionBuilder,org.apache.cxf.javascript.JavascriptQueryHandlerRegistry,org.apache.cxf.transport.local.LocalTransportFactory,org.apache.cxf.transport.http.policy.HTTPClientAssertionBuilder,org.apache.cxf.transport.http.policy.HTTPServerAssertionBuilder,org.apache.cxf.transport.http.policy.NoOpPolicyInterceptorProvider,org.apache.cxf.transport.http.ClientOnlyHTTPTransportFactory,org.apache.cxf.management.InstrumentationManager,org.apache.cxf.transport.http_jetty.JettyHTTPTransportFactory,org.apache.cxf.transport.jms.JMSTransportFactory,org.apache.cxf.binding.object.ObjectBindingFactory,org.apache.cxf.binding.http.HttpBindingFactory,org.apache.cxf.jaxrs.JAXRSBindingFactory,org.apache.cxf.ws.security.policy.WSSecurityPolicyLoader,org.apache.cxf.ws.policy.AssertionBuilderRegistry,org.apache.cxf.ws.policy.PolicyInterceptorProviderRegistry,org.apache.cxf.ws.policy.attachment.external.DomainExpressionBuilderRegistry,org.apache.cxf.ws.policy.attachment.external.EndpointReferenceDomainExpressionBuilder,org.apache.cxf.ws.policy.PolicyBuilder,org.apache.cxf.ws.policy.PolicyEngine,org.apache.cxf.ws.policy.attachment.wsdl11.Wsdl11AttachmentPolicyProvider,org.apache.cxf.ws.policy.attachment.ServiceModelPolicyProvider,org.apache.cxf.ws.policy.mtom.MTOMAssertionBuilder,org.apache.cxf.ws.policy.mtom.MTOMPolicyInterceptorProvider,org.apache.cxf.ws.rm.RMManager,org.apache.cxf.ws.rm.policy.RMPolicyInterceptorProvider,org.apache.cxf.ws.rm.RMAssertionBuilder];
root of factory hierarchy
22-May-2011 20:51:32 org.apache.cxf.jaxb.JAXBUtils logGeneratedClassNames

INFO: Created classes: org.tempuri.CelsiusToFahrenheit,
org.tempuri.CelsiusToFahrenheitResponse, org.tempuri.FahrenheitToCelsius,
org.tempuri.FahrenheitToCelsiusResponse, org.tempuri.ObjectFactory
You are probably freezing at 32 degrees Farhenheit


--
View this message in context: http://groovy.329449.n5.nabble.com/Can-t-get-first-groovyWS-example-to-work-with-Grab-tp4416779p4417505.html

steve

unread,
May 22, 2011, 4:54:13 PM5/22/11
to us...@groovy.codehaus.org
Just upgraded to groovy 1.8 and again it works clean out of the box... Surely
this points to an OS or config issue? I also deleted the whole of the grapes
directory and it download 39Mb of dependencies OK.

--
View this message in context: http://groovy.329449.n5.nabble.com/Can-t-get-first-groovyWS-example-to-work-with-Grab-tp4416779p4417558.html

Reply all
Reply to author
Forward
0 new messages