cxf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrew Dinn <ad...@redhat.com>
Subject Re: [Deploy in JBOSS] Address already in use Exception
Date Mon, 26 Nov 2007 09:16:50 GMT
Hi Eman,

Your config files look ok. I'm afraid I don't really understand what is 
going wrong in that case.

Regarding your destroy code I have two comments. Firstly, I was 
suggesting you destroy the cxf *servlet*, not (just) the cxf bus. Also, 
there is no guarantee that the default bus at the point where your 
destroy code is run is the same bus as the one you installed at the 
point where the create code was run. Maybe you should stash the cxf 
servlet somewhere when you create e.g. attach it to the servlet which is 
running the create code. Then you can pick it up later and call its 
destroy method.

Hope this helps. If not then I am afraid I am stumped :-(

regards,


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)

Eman Ali al-Maktari [IT Department] wrote:
> Hi Andrew, 
> I tried to stop the bus using: 
> public void destroy() { 
> Bus bus = CXFBusFactory.getDefaultBus(); 
> if (eCategories.isPublished()){ 
> System.out.println("I'll stop Categories!"); 
> eCategories.stop(); 
> bus.shutdown(false); 
> System.out.println("I't was stopped"); 
> } 
> super.destroy(); 
> } 
> 
> but the problem still exist, I also tried removing 
> NOTE: this destroy() method is the servlet method. 
> I also tried to not explicitly create a CXFServlet(), and the problem happened again
and again :-( 
> 
> These are my XML files: 
> ================CXF.XML======================= 
> <beans xmlns="http://www.springframework.org/schema/beans" 
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
> xmlns:jaxws="http://cxf.apache.org/jaxws" 
> xsi:schemaLocation=" 
> http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd

> http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd"> 
> 
> <bean id="logInbound" class="org.apache.cxf.interceptor.LoggingInInterceptor"/>

> <bean id="logOutbound" class="org.apache.cxf.interceptor.LoggingOutInterceptor"/>

> 
> <bean id="cxf" class="org.apache.cxf.bus.CXFBusImpl"> 
> <property name="inInterceptors"> 
> <list> 
> <ref bean="logInbound"/> 
> </list> 
> </property> 
> <property name="outInterceptors"> 
> <list> 
> <ref bean="logOutbound"/> 
> </list> 
> </property> 
> <property name="outFaultInterceptors"> 
> <list> 
> <ref bean="logOutbound"/> 
> </list> 
> </property> 
> </bean> 
> </beans> 
> ====================CXF-SERVLET.XML======================== 
> <?xml version="1.0" encoding="UTF-8"?> 
> <beans xmlns="http://www.springframework.org/schema/beans" 
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
> xmlns:jaxws="http://cxf.apache.org/jaxws" 
> xmlns:soap="http://cxf.apache.org/bindings/soap" 
> xsi:schemaLocation=" 
> http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd

> http://cxf.apache.org/bindings/soap http://cxf.apache.org/schemas/configuration/soap.xsd

> http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd"> 
> </beans> 
> 
> ===================WEB.XML (When I create the CXFServlet explicitly)=================================

> <!DOCTYPE web-app PUBLIC 
> "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" 
> "http://java.sun.com/dtd/web-app_2_3.dtd" > 
> 
> <web-app> 
> <servlet> 
> <servlet-name>WebServiceServlet</servlet-name> 
> <servlet-class>com.lit.linkinnews.WebServiceServlet</servlet-class> 
> <load-on-startup>1</load-on-startup> 
> </servlet> 
> <servlet> 
> <servlet-name>cxf</servlet-name> 
> <display-name>cxf</display-name> 
> <description>Apache CXF Endpoint</description> 
> <servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class>

> <load-on-startup>1</load-on-startup> 
> </servlet> 
> <servlet-mapping> 
> <servlet-name>cxf</servlet-name> 
> <url-pattern>/services/*</url-pattern> 
> </servlet-mapping> 
> <servlet-mapping> 
> <servlet-name>WebServiceServlet</servlet-name> 
> <url-pattern>/WebServiceServlet</url-pattern> 
> </servlet-mapping> 
> </web-app> 
> ===================WEB.XML (When I don't create the CXFServlet explicitly)=================================

> <!DOCTYPE web-app PUBLIC 
> "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" 
> "http://java.sun.com/dtd/web-app_2_3.dtd" > 
> 
> <web-app> 
> <servlet> 
> <servlet-name>WebServiceServlet</servlet-name> 
> <servlet-class>com.lit.linkinnews.WebServiceServlet</servlet-class> 
> <load-on-startup>1</load-on-startup> 
> </servlet> 
> <servlet-mapping> 
> <servlet-name>WebServiceServlet</servlet-name> 
> <url-pattern>/WebServiceServlet</url-pattern> 
> </servlet-mapping> 
> </web-app> 
> 
> =============================================================== 
> The WebServiceServlet is the servlet where I publish and unpublish the end points, 
> 
> Any help will be really, really, really appreciated. 
> 
> 
> ----- Original Message ----- 
> From: "Eman Ali al-Maktari [IT Department]" <ealmaktari@linkintime.com> 
> To: cxf-user@incubator.apache.org 
> Sent: Wednesday, November 21, 2007 5:33:51 PM (GMT+0300) Asia/Kuwait 
> Subject: Re: [Deploy in JBOSS] Address already in use Exception 
> 
> Thanks a lot Andrew, 
> 
> I really needed a clue 
> I'm going to try the "Stopping Bus" solution as soon as I can, I hope it will be the
solution.. 
> 
> for my code, it's written in a servlet that is loaded when the application deployed (you
guest it correctly ;) ) 
> 
> Thanks again, I'll feed you back! 
> 
> ----- Original Message ----- 
> From: "Andrew Dinn" <adinn@redhat.com> 
> To: cxf-user@incubator.apache.org 
> Sent: Wednesday, November 21, 2007 12:18:02 PM (GMT+0300) Asia/Kuwait 
> Subject: Re: [Deploy in JBOSS] Address already in use Exception 
> 
> 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) 
> 
> 
> 
> 
> 



Mime
View raw message