You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Michele Mazzucco <Mi...@ncl.ac.uk> on 2008/01/24 15:38:47 UTC

[axis2] issues in using custom configuration context

Hi all,


I'm struggling to get my client working with a custom configuration  
context (the configuration file is attached):
- The interaction is asynchronous (i.e. a callback object is in  
charge to receive responses)
- If the service client is created by using the default (empty)  
constructor then the message is received by the server
- It the service client is created by using the
  new ServiceClient(confCtx, null)
constructor, messages are not received by the server  (on the server  
I have a custom handler configured to run as first into the handler's  
chain, and it's not invoked), even if it looks that the message has  
been sent -- and no error occurs.

I've noticed that if the interaction is synchronous (in-out)  
everything works fine.



The custom configuration context is created the following way
URL url = AbstractClient.class.getResource("axis2.xml");
if (url == null) {
	throw new IllegalStateException("The URL for the axis2 config. file  
is NULL");
}
configurationContext =  
ConfigurationContextFactory.createConfigurationContextFromFileSystem 
(axis2Home
				.concat("/repository"), url.getPath());

connectionManager = new MultiThreadedHttpConnectionManager();
HttpConnectionManagerParams connectionManagerParams = new  
HttpConnectionManagerParams();
// 10 seconds
connectionManagerParams.setConnectionTimeout(10000);
connectionManagerParams.setMaxConnectionsPerHost(	 
HostConfiguration.ANY_HOST_CONFIGURATION, 30);
connectionManagerParams.setDefaultMaxConnectionsPerHost(30);
connectionManagerParams.setMaxTotalConnections(200);
connectionManagerParams.setTcpNoDelay(true);
connectionManagerParams.setStaleCheckingEnabled(true);
connectionManagerParams.setLinger(-1);

HttpClient httpClient = new HttpClient(connectionManager);

try {
	configurationContext.setThreadPool(new ThreadPool(1, 5));
} catch (AxisFault e) {
	System.err.println("Unable to set the thread pool");
}

configurationContext.setProperty(HTTPConstants.REUSE_HTTP_CLIENT,  
Boolean.TRUE);
configurationContext.setProperty(HTTPConstants.CACHED_HTTP_CLIENT,  
httpClient);





I would like to stress out that the two "implementations" differ only  
in the way the ServiceClient object is created. Furthermore, since  
I'm using the same ServiceClient to execute several MEPs, I cannot  
use the default constructor because of the following problems:
1 - A BindException occurs after some messages have been sent (even  
if I call ServiceClient.cleanupTransport() after each  
sendReceiveNonBlocking() invocation)
[java] ERROR 14:14:14,824  
(DefaultConnectionListenerFailureHandler.java:102) - Terminating  
connection listener  
org.apache.axis2.transport.http.server.DefaultConnectionListener@147e60  
after 10retries in 0 seconds.
      [java] java.net.BindException: Address already in use
      [java]     at java.net.PlainSocketImpl.socketBind(Native Method)
      [java]     at java.net.PlainSocketImpl.bind 
(PlainSocketImpl.java:359)
      [java]     at java.net.ServerSocket.bind(ServerSocket.java:319)
      [java]     at java.net.ServerSocket.<init>(ServerSocket.java:185)
      [java]     at java.net.ServerSocket.<init>(ServerSocket.java:97)
      [java]     at  
org.apache.axis2.transport.http.server.DefaultConnectionListener.run 
(DefaultConnectionListener.java:72)
      [java]     at  
edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor 
$Worker.runTask(ThreadPoolExecutor.java:665)
      [java]     at  
edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor 
$Worker.run(ThreadPoolExecutor.java:690)
      [java]     at java.lang.Thread.run(Thread.java:613)

2 - I need to share the same configuration context between different  
ServiceClient instances, where each instance is driven by a different  
thread.


The ServiceClient is created using the following code

sender = new ServiceClient();//getParams().configurationContext, null);
synchronized (ENGAGE_MODULE_LOCK) {
		sender.engageModule(Constants.MODULE_ADDRESSING);
}

// creates the header containing the cookie
OMElement cookieElement = factory.createOMElement 
(SOAPConstants.COOKIE, omNs);
cookieElement.setText(String.valueOf(cookie));

// set the stream into the header. All following sender.send(...)
// will include the cookie into the SOAP header
sender.addHeader(cookieElement);
sender.setOptions(getOptions());


where the options are created using the following chunk of code:

protected Options getOptions() {
	Options options = new Options();

	options.setTo(getTargetEpr());
	options.setAction(getSoapAction());

	// The boolean flag informs the axis2 engine to use two separate
	// transport connection
	// to retrieve the response.
	options.setUseSeparateListener(true);
	options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
	options.setSoapVersionURI(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI);
	options.setProperty(HTTPConstants.CHUNKED, Boolean.FALSE);
	options.setProperty(HTTPConstants.SO_TIMEOUT, TIMEOUT);
	options.setProperty(HTTPConstants.CONNECTION_TIMEOUT, TIMEOUT);
	options.setCallTransportCleanup(true);

	return options;
}




Any clue?
Michele



Re: [axis2] issues in using custom configuration context

Posted by Deepal Jayasinghe <de...@opensource.lk>.
> Deepal,
>
> the only change I've made was the port for the http listener. The
> axis2.xml was attached to my first email -- I'm including it to this
> email too.
May be something else is running on port 6061 , why don't you try to
change that and see

Thanks
Deepal
>
>
> ------------------------------------------------------------------------
>
>
>
>
>
> Michele
>
>
>
> On 25 Jan 2008, at 10:12, Deepal jayasinghe wrote:
>
>
>
>> Hi Michele , Have you done any changes to your client side axis2.xml
>> , if so what are they ? Thanks Deepal
>>> Deepal, apart from that I made no changes at all. Here is my code.
>>> try {     sender = new ServiceClient(getConfiguration(), null); }
>>> catch (Exception e) {     throw new RuntimeException(e); }
>>> synchronized (ENGAGE_MODULE_LOCK) {    
>>> sender.engageModule(Constants.MODULE_ADDRESSING); } private
>>> ConfigurationContext getConfiguration() throws Exception {        
>>> ConfigurationContext configurationContext =
>>> ConfigurationContextFactory                
>>> .createConfigurationContextFromFileSystem(null, null);        
>>> HttpConnectionManager connectionManager = new
>>> MultiThreadedHttpConnectionManager();        
>>> HttpConnectionManagerParams connectionManagerParams = new
>>> HttpConnectionManagerParams();         // 10 seconds        
>>> connectionManagerParams.setConnectionTimeout(10000);        
>>> connectionManagerParams.setMaxConnectionsPerHost(            
>>> HostConfiguration.ANY_HOST_CONFIGURATION, 30);        
>>> connectionManagerParams.setDefaultMaxConnectionsPerHost(30);        
>>> connectionManagerParams.setMaxTotalConnections(200);        
>>> connectionManagerParams.setTcpNoDelay(true);        
>>> connectionManagerParams.setStaleCheckingEnabled(true);        
>>> connectionManagerParams.setLinger(-1);         HttpClient httpClient
>>> = new HttpClient(connectionManager);        
>>> configurationContext.setThreadPool(new ThreadPool(1, 5));        
>>> configurationContext.setProperty(HTTPConstants.REUSE_HTTP_CLIENT,
>>>             Boolean.TRUE);
>>> configurationContext.setProperty(HTTPConstants.CACHED_HTTP_CLIENT,
>>>             httpClient);         return configurationContext; }
>>> However using this set up I've noticed that after some time I get a
>>> BindException -- I think it's because I use only one AxisCallback
>>> object to receive many responses. Michele On 25 Jan 2008, at 10:02,
>>> Deepal Jayasinghe wrote:
>>>> hmm ,if that is the case there should be something wrong with your
>>>> axis2.xml . So what are the additional changes that you have made ?
>>>> Thanks Deepal
>>>>> Hi again, some more details. If the configuration context is
>>>>> created using the following statement ConfigurationContext
>>>>> configurationContext = ConfigurationContextFactory                
>>>>> .createConfigurationContextFromFileSystem(null, null); and then
>>>>> the customization is made as before (i.e.
>>>>> MultiThreadedHttpConnectionManager and cached HttpClient) the
>>>>> system seems to work fine. Michele
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org For
>>>>> additional commands, e-mail: axis-user-help@ws.apache.org 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org For
>> additional commands, e-mail: axis-user-help@ws.apache.org 
>
>
>   




---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


Re: [axis2] issues in using custom configuration context

Posted by Michele Mazzucco <Mi...@ncl.ac.uk>.
Deepal,

the only change I've made was the port for the http listener. The  
axis2.xml was attached to my first email -- I'm including it to this  
email too.



Re: [axis2] issues in using custom configuration context

Posted by Deepal jayasinghe <de...@gmail.com>.
Hi Michele ,
Have you done any changes to your client side axis2.xml , if so what are
they ?

Thanks
Deepal
> Deepal,
>
> apart from that I made no changes at all. Here is my code.
>
> try {
>     sender = new ServiceClient(getConfiguration(), null);
> } catch (Exception e) {
>     throw new RuntimeException(e);
> }
>
> synchronized (ENGAGE_MODULE_LOCK) {
>     sender.engageModule(Constants.MODULE_ADDRESSING);
> }
>
>
>
> private ConfigurationContext getConfiguration() throws Exception {
>         ConfigurationContext configurationContext =
> ConfigurationContextFactory
>                 .createConfigurationContextFromFileSystem(null, null);
>
>         HttpConnectionManager connectionManager = new
> MultiThreadedHttpConnectionManager();
>         HttpConnectionManagerParams connectionManagerParams = new
> HttpConnectionManagerParams();
>         // 10 seconds
>         connectionManagerParams.setConnectionTimeout(10000);
>         connectionManagerParams.setMaxConnectionsPerHost(
>             HostConfiguration.ANY_HOST_CONFIGURATION, 30);
>         connectionManagerParams.setDefaultMaxConnectionsPerHost(30);
>         connectionManagerParams.setMaxTotalConnections(200);
>         connectionManagerParams.setTcpNoDelay(true);
>         connectionManagerParams.setStaleCheckingEnabled(true);
>         connectionManagerParams.setLinger(-1);
>
>         HttpClient httpClient = new HttpClient(connectionManager);
>
>         configurationContext.setThreadPool(new ThreadPool(1, 5));
>
>         configurationContext.setProperty(HTTPConstants.REUSE_HTTP_CLIENT,
>             Boolean.TRUE);
>        
> configurationContext.setProperty(HTTPConstants.CACHED_HTTP_CLIENT,
>             httpClient);
>
>         return configurationContext;
> }
>
>
> However using this set up I've noticed that after some time I get a
> BindException -- I think it's because I use only one AxisCallback
> object to receive many responses.
>
>
> Michele
>
> On 25 Jan 2008, at 10:02, Deepal Jayasinghe wrote:
>
>> hmm ,if that is the case there should be something wrong with your
>> axis2.xml . So what are the additional changes that you have made ?
>>
>> Thanks
>> Deepal
>>> Hi again,
>>>
>>>
>>> some more details. If the configuration context is created using the
>>> following statement
>>>
>>> ConfigurationContext configurationContext = ConfigurationContextFactory
>>>                 .createConfigurationContextFromFileSystem(null, null);
>>>
>>> and then the customization is made as before (i.e.
>>> MultiThreadedHttpConnectionManager and cached HttpClient) the system
>>> seems to work fine.
>>>
>>>
>>>
>>> Michele
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
>>> For additional commands, e-mail: axis-user-help@ws.apache.org
>>>
>>>
>>>
>>
>>
>>


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


Re: [axis2] issues in using custom configuration context

Posted by Michele Mazzucco <Mi...@ncl.ac.uk>.
Deepal,

apart from that I made no changes at all. Here is my code.

try {
	sender = new ServiceClient(getConfiguration(), null);
} catch (Exception e) {
	throw new RuntimeException(e);
}

synchronized (ENGAGE_MODULE_LOCK) {
	sender.engageModule(Constants.MODULE_ADDRESSING);
}



private ConfigurationContext getConfiguration() throws Exception {
		ConfigurationContext configurationContext =  
ConfigurationContextFactory
				.createConfigurationContextFromFileSystem(null, null);

		HttpConnectionManager connectionManager = new  
MultiThreadedHttpConnectionManager();
		HttpConnectionManagerParams connectionManagerParams = new  
HttpConnectionManagerParams();
		// 10 seconds
		connectionManagerParams.setConnectionTimeout(10000);
		connectionManagerParams.setMaxConnectionsPerHost(
			HostConfiguration.ANY_HOST_CONFIGURATION, 30);
		connectionManagerParams.setDefaultMaxConnectionsPerHost(30);
		connectionManagerParams.setMaxTotalConnections(200);
		connectionManagerParams.setTcpNoDelay(true);
		connectionManagerParams.setStaleCheckingEnabled(true);
		connectionManagerParams.setLinger(-1);

		HttpClient httpClient = new HttpClient(connectionManager);

		configurationContext.setThreadPool(new ThreadPool(1, 5));

		configurationContext.setProperty(HTTPConstants.REUSE_HTTP_CLIENT,
			Boolean.TRUE);
		configurationContext.setProperty(HTTPConstants.CACHED_HTTP_CLIENT,
			httpClient);

		return configurationContext;
}


However using this set up I've noticed that after some time I get a  
BindException -- I think it's because I use only one AxisCallback  
object to receive many responses.


Michele

On 25 Jan 2008, at 10:02, Deepal Jayasinghe wrote:

> hmm ,if that is the case there should be something wrong with your
> axis2.xml . So what are the additional changes that you have made ?
>
> Thanks
> Deepal
>> Hi again,
>>
>>
>> some more details. If the configuration context is created using the
>> following statement
>>
>> ConfigurationContext configurationContext =  
>> ConfigurationContextFactory
>>                 .createConfigurationContextFromFileSystem(null,  
>> null);
>>
>> and then the customization is made as before (i.e.
>> MultiThreadedHttpConnectionManager and cached HttpClient) the system
>> seems to work fine.
>>
>>
>>
>> Michele
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
>> For additional commands, e-mail: axis-user-help@ws.apache.org
>>
>>
>>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-user-help@ws.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


Re: [axis2] issues in using custom configuration context

Posted by Deepal Jayasinghe <de...@opensource.lk>.
hmm ,if that is the case there should be something wrong with your
axis2.xml . So what are the additional changes that you have made ?

Thanks
Deepal
> Hi again,
>
>
> some more details. If the configuration context is created using the
> following statement
>
> ConfigurationContext configurationContext = ConfigurationContextFactory
>                 .createConfigurationContextFromFileSystem(null, null);
>
> and then the customization is made as before (i.e.
> MultiThreadedHttpConnectionManager and cached HttpClient) the system
> seems to work fine.
>
>
>
> Michele
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-user-help@ws.apache.org
>
>
>



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


Re: [axis2] issues in using custom configuration context

Posted by Michele Mazzucco <Mi...@ncl.ac.uk>.
Hi again,


some more details. If the configuration context is created using the  
following statement

ConfigurationContext configurationContext = ConfigurationContextFactory
				.createConfigurationContextFromFileSystem(null, null);

and then the customization is made as before (i.e.  
MultiThreadedHttpConnectionManager and cached HttpClient) the system  
seems to work fine.



Michele


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org