Client webservice timeout on CXF webservice on Jboss

What a riveting blog title, but this one is mainly for people to find for a solution via google.

Problem: you have a JBoss server with a webservice CLIENT talking to a webservice somewhere else, and you keep getting timeouts, most likely with the following error

org.apache.cxf.phase.PhaseInterceptorChain doIntercept 
INFO: Interceptor has thrown exception, unwinding now
org.apache.cxf.interceptor.Fault: Could not send Message.
        at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:64)
        at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:226)

If this happens after 60 second (the CXF default timeout), then it is most likely not the target server refusing you, but your client timing out (if your luckily you can get to the target server logs and confirm). Sooo lets extend the client timeout period, personally i like doing this via server configs and indeed that was my first port of call (do a google search for CXF.xml for more details), however even after i figured out what to call the file (cxf.xml, jbossws-cxf.xml, or jboss-cxf.xml) and got it in the right place (inside the WEB-INF of the project for access via POJO’s) the darn thing just ignored me, incidentally the following is the “meat” of the file which should change the timeout (in fact the “*.http-conduit” changes the timeouts on all webservice clients on that app.

<http-conf:conduit name="*.http-conduit"> 
<http-conf:client ConnectionTimeout="120000" /> 
</http-conf:conduit> 

After a prolonged swear, and discovery that i was not the only person who had had this problem on JBoss for CFX clients, I binned that and went into the code, now if your getting this problem then your all ready making a web service client call so you will already have a line like this

Service client = service.yourwebservice();

if you cant find one, and make all you “client stubs” with something like WSDL2Java or via your IDE, do a search for “extends Service”, you are now looking for a line like this

public class myfunkyservice_Service extends Service { 

when you find it, it will tell you what you should go back and look for ie

funkyservice = new myfunkyservice_Service(URL);
myfunkyservice_Service client = funkyservice.yourwebservice();

well something like that anyway, now bung the following code in after it (changing ‘myfunkyservice_Service’ to what ever you client service is called, and not forgetting that the timeout is in milliseconds)

Client cl = ClientProxy.getClient(myfunkyservice_Service);
HTTPConduit http = (HTTPConduit) cl.getConduit();
HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy();
httpClientPolicy.setConnectionTimeout(120000);
httpClientPolicy.setReceiveTimeout(120000);
http.setClient(httpClientPolicy);

that’s the code done, it should all work swimmingly, one exception to this is if you get the error

java.lang.ClassCastException: com.sun.xml.ws.client.sei.SEIStub
at org.apache.cxf.frontend.ClientProxy.getClient(ClientProxy.java:93)

What this bundle of joy means is that sun’s library is loading with a higher priority that the CFX lib, if this is on a server its time to get dirty with your config, if this is on your IDE then, go to your projects properties –> Java build path –> Order and export, and bump the CXF lib up (try it at the top)

there you go, now wasn’t that fun 🙂
Old Comments
————
##### Nancy(15/11/2011 20:01:02 GMT)
Thank you very very VERY MUUUUUUUCHH!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Really
##### Mark Myers(16/11/2011 19:58:48 GMT)
@Nancy your welcome, glad it helped
##### Mark Myers(27/11/2011 21:48:18 GMT)
@Anneta no prob
##### lucky7175(20/12/2011 06:27:43 GMT)
It works this way

webClient = WebClient.create(URI);
HTTPConduit conduit = WebClient.getConfig(webClient).getHttpConduit();
conduit.getClient().setConnectionTimeout(120000);
##### lucky7175(20/12/2011 06:08:44 GMT)
I dont have control on server code and we use cxf webclient. Can u Pls. let me know how i can set only in client side
##### Mark Myers(22/12/2011 14:42:50 GMT)
yup thank you luckly, isn’t that snippet of code already in the blog at the bottom?

Making any ISO

While building a new win7 VM, I discovered that some of my software was still on DVD/CD only (the horror), I figured that there must be a easy linux way of making an iso image, and diddle me so there is, its called dd The ultimate frenzy guide to how to use this amazing command can be found at How To Do Everything With DD but for me it boiled down to

dd if=/dev/scd0 of=DVDBACKUP.iso

you just need to know where your dvd drive is mounted

$ mount

/dev/sda1 on / type ext3 (rw,noatime,errors=remount-ro)
/dev/sda3 on /home type ext3 (rw,noatime)
/dev/sda1 on /media/SecondHDD type ext3 (rw)
/dev/scd0 on /media/cdrom0 type udf (ro,nosuid,nodev,user=myers) <– This One looks Right

Sooo

myers@EX-L1:~$ sudo dd if=/dev/scd0 of=DVDBACKUP.iso

7816384+0 records in
7816384+0 records out
4001988608 bytes (4.0 GB) copied, 312.694 s, 12.8 MB/s

Cooooor, instant .iso or any order disk copy you might like (its built into all good OS’s, and by that i mean all with a Unix core { yes yes the turtle neck fruit boys can even be included on this one})

Fitness Week 1 AGAIN

Back at it again, this time I’m dragging a fellow member of LDC with me, Mr green and i are having a double competition, each with a prize (a slap up meal):

First person to win 250 squash games
Kieran: 0 Games
Mark: 3 Games

First person to loose 2 stone
Kieran ( Initially 15 Stone, 8 pounds) : 15 8″
Mark ( Initially 16 Stone, 8 pounds) : 16′ 8″

MAY THE BATTLE BEGIN!!!

Sticky Footers in domino

Any of you who have tried to do sticky footers with domino, may have ground
your teeth in frustration as the best CSS only solutions don’t seem to work,
how ever this one does!!! http://www.cssstickyfooter.com/, well initially it
does not, but in the best tradition of RTFM, all you have to do is look at the
tiny foot note at the bottom of the instructions which is aimed at .Net
developers

"When coding sites for ASP.net where each page is inside a <form> tag, be sure 
to add the form tag to the height:100% statement, else it will break the sticky 
footer. Like this;
html, body, form, #wrap {height: 100%;}"

 

Ohhhhh domino does those as well, and one line of css later, it all works