cxf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrew Dinn <>
Subject Re: [Deploy in JBOSS] Address already in use Exception
Date Wed, 21 Nov 2007 09:18:02 GMT
Eman Ali al-Maktari [IT Department] wrote:
> This is my code: 
> Endpoint eCategories = publishCategories(); 
> private Endpoint publishCategories() { 
> String address = "http://localhost:9090/sn_categories"; 
> CategoriesImpl categoriesImpl = new CategoriesImpl(); 
> //Endpoint e = Endpoint.publish(address, categoriesImpl); 
> CXFServlet cxf = new CXFServlet(); 
> Bus bus = cxf.getBus(); 
> BusFactory.setDefaultBus(bus); 
> Endpoint e = Endpoint.create(categoriesImpl); 
> e.publish(address); 
> return e; 
> } 
> public void init(ServletConfig config) throws ServletException { 
> super.init(config); 
> System.out.println("Server started\\"); 
> // Categories 
> if (!eCategories.isPublished()) { 
> String address = "http://localhost:9090/sn_categories"; 
> eCategories.publish(address); 
> } 
> } 
> public void destroy() { 
> if (eCategories.isPublished()) eCategories.stop(); 
> super.destroy(); 
> }

Ok, I am not certain what is going on because I don't know for sure 
where the first segment of code in your listing is invoked from. 
Assuming it is run when the app is deployed, I think I see the problem 
here. You are explicitly creating a CXFServlet() in your code rather 
than relying on cxf/JBoss deployer code to create it. This should mean 
that you need to explicitly delete the servlet (and its associated bus 
and transport) when your app is undeployed. You can verify this by 
checking to see if your destroy method is ever called. If not then I 
would expect this to leave the bus and transport holding on to the 
socket. Perhaps Dan or one of the other CXF team could confirm this?

I suggest you configure the cxf.xml/cxf-servlet.xml files to deploy your 
cxf servlet. This should ensure that JBoss and CXF co-operate to shut 
down the servlet when the app is undeployed. Alternatively, you will 
have to work out a way of catching the undeploy in your app code and 
deleting the servlet (e.g. if your app deploys some other servlet you 
can delete the cxf bus from its destroy method).

Andrew Dinn (JBoss Transactions)
JBoss, a Division of Red Hat
Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod 
Street, Windsor, Berkshire,
SI4 1TE, United Kingdom.
Registered in UK and Wales under Company Registration No. 3798903
Directors: Michael Cunningham (USA), Charlie Peters (USA) and David 
Owens (Ireland)

View raw message