Grails-Plugin-Consortium / grails-cxf-client

Easy cxf client for grails
http://grails.org/plugin/cxf-client
27 stars 30 forks source link

Setting timeout properties : java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String #50

Closed JcrGit closed 9 years ago

JcrGit commented 9 years ago

Hi,

We use grails-cxf-client in our Grails project and we declare our Webservices in config.groovy like this :

// Code from config.groovy {...} cxf { client { serviceAutoSoapClientStub { clientInterface = fr.myproject.tp.serviceauto.webserviceauto.RefAutoServiceSoap serviceEndpointAddress = '${service.webserviceauto.root}/mockrefAutoServiceSoap}'
connectionTimeout=100 receiveTimeout=100 } } } {...}

-> When we test this WS with a Soap UI Server, the timeout works well.

But, we need to externalize the timeout to properties file; the above code became :

// Code from config.groovy {...} cxf { client { serviceAutoSoapClientStub { clientInterface = fr.myproject.tp.serviceauto.webserviceauto.RefAutoServiceSoap serviceEndpointAddress = '${service.webserviceauto.root}/mockrefAutoServiceSoap}' } } } {...}

// Code from config.properties {...}

Timeout parameters

cxf.client.serviceAutoSoapClientStub.connectionTimeout=100 cxf.client.serviceAutoSoapClientStub.receiveTimeout=100 {...}

-> When the application started, we got this error and the application stopped : "java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String at java.lang.String.compareTo(String.java:110) at CxfClientGrailsPlugin$_closure3.doCall(CxfClientGrailsPlugin.groovy:139) at CxfClientGrailsPlugin$_closure2.doCall(CxfClientGrailsPlugin.groovy:100) at CxfClientGrailsPlugin$_closure1_closure6.doCall(CxfClientGrailsPlugin.groovy:60) at CxfClientGrailsPlugin$_closure1.doCall(CxfClientGrailsPlugin.groovy:58) at grails.spring.BeanBuilder.invokeBeanDefiningClosure(BeanBuilder.java:757) at grails.spring.BeanBuilder.beans(BeanBuilder.java:584) at grails.spring.BeanBuilder.invokeMethod(BeanBuilder.java:527) at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334) at java.util.concurrent.FutureTask.run(FutureTask.java:166) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) at java.lang.Thread.run(Thread.java:722)"

If i replaced the value 100 by a single number (1 to 9), the application works well.

I think the parsing of timeout properties is not good.

ctoestreich commented 9 years ago

Are you using any particular plugin to read the properties file? Have you tried using something like

cxf.client.serviceAutoSoapClientStub.connectionTimeout="100" //try single and double quotes
JcrGit commented 9 years ago

Hi,

Thanks for reply ;) We don't use specific plugin for properties, we use standard Grails Mechanic.

We had already test these differents case with same result : {code} cxf.client.serviceAutoSoapClientStub.connectionTimeout=100 cxf.client.serviceAutoSoapClientStub.connectionTimeout='100' cxf.client.serviceAutoSoapClientStub.connectionTimeout="100" {code}

Don't you have the same issue ?

PS : We use Grails 2.2

ctoestreich commented 9 years ago

Found the issue. Will be in the forth coming 2.0.1 release in a few minutes.

JcrGit commented 9 years ago

Re, Thanks for the correction, we wil test this as soon as possible !

Gj :)

JcrGit commented 9 years ago

Hi,

We test the plugin in version 2.0.1, and we had another cast problem; org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object '100' with class 'java.lang.String' to class 'long' at com.grails.cxf.client.WebServiceClientFactoryImpl.getHttpClientPolicy(WebServiceClientFactoryImpl.groovy:403) at com.grails.cxf.client.WebServiceClientFactoryImpl.configureReceiveTimeout(WebServiceClientFactoryImpl.groovy:389) at com.grails.cxf.client.WebServiceClientFactoryImpl.addInterceptors(WebServiceClientFactoryImpl.groovy:319) at com.grails.cxf.client.WebServiceClientFactoryImpl.assignCxfProxy(WebServiceClientFactoryImpl.groovy:237) at com.grails.cxf.client.WebServiceClientFactoryImpl.getWebServiceClient(WebServiceClientFactoryImpl.groovy:78) at com.grails.cxf.client.DynamicWebServiceClient.getObject(DynamicWebServiceClient.groovy:38) at grails.plugin.cache.web.filter.AbstractFilter.getBean(AbstractFilter.java:196) at grails.plugin.cache.web.filter.PageFragmentCachingFilter.lookupController(PageFragmentCachingFilter.java:842) at grails.plugin.cache.web.filter.PageFragmentCachingFilter.doFilter(PageFragmentCachingFilter.java:176) at grails.plugin.cache.web.filter.AbstractFilter.doFilter(AbstractFilter.java:63) at fr.mma.souse.authentication.AnnuaireCredentialCheckerFilter.doFilter(AnnuaireCredentialCheckerFilter.groovy:58) at fr.covea.troisma.soauth.security.web.SoAuthTokenAuthenticationFilter.doFilter(SoAuthTokenAuthenticationFilter.java:165) at com.granicus.grails.plugins.cookiesession.CookieSessionFilter.doFilterInternal(CookieSessionFilter.java:78) at fr.mma.use.navigation.NexturlValidationFilter.doFilter(NexturlValidationFilter.groovy:52) at fr.mma.use.requestid.RequestIdFilter.doFilter(RequestIdFilter.groovy:38) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) at java.lang.Thread.run(Thread.java:722)

You add controls to 'validateTimeouts' but when timeout are setted in 'configureCxfClientBeans' (in CxfClientGrailsPlugin.groovy) they are String, not Integer and another class cast exception is thrown.

ctoestreich commented 9 years ago

ugh. found the issue and added a test. get 2.0.2

JcrGit commented 9 years ago

Hi,

We have tested the correction and it seems to work well !

Thanks ;)