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 divvela <di...@yahoo.com> on 2011/08/29 21:34:42 UTC

Axis2 WebService - Timer threads are accumuating and java.lang.OutOfMemoryError: unable to create new native thread

Hello,
We have a webapplication runnig on glassfish version 2.1 connecting to a
webservice using the piece of the code below. Every day we are having over
1000 calls. For some reason timer threads are getting accumalated day by
day. Couple of days after we are getting java.lang.OutOfMemoryError: unable
to create new native thread ... Which indicates probably some thing wrong
with code or some bug in axis2 which i am not aware of ... Please help ...
This is becoming a BIG BIG production issue for us. Appreciate your help in
this matter.

	public String CallWebService(String webServiceName, OMElement
webServiceRequest) throws Exception
	{
				ConfigurationContext ctx =
ConfigurationContextFactory.createConfigurationContextFromFileSystem("/export/home/test",
"/export/home/test/conf/axis2.xml");
			
				ServiceClient client = new ServiceClient(ctx, null);
				Options options = new Options();
				client.setTargetEPR(new EndpointReference("URL"));
				options.setTo(new EndpointReference("URL"));
				options.setAction("URLACTION"+webServiceName);
				options.setTimeOutInMilliSeconds(90*1000);
				client.setOptions(options);		
		
		        	client.engageModule("addressing");
				client.engageModule("rampart");
				
				OperationClient  sender =
client.createClient(ServiceClient.ANON_OUT_IN_OP);
			    MessageContext mc = new MessageContext();
			    SOAPFactory fac = OMAbstractFactory.getSOAP11Factory();
			    SOAPEnvelope envelope=fac.getDefaultEnvelope();	
		
			    OMNamespace vis = fac.createOMNamespace("URLNAMESPACE", "emp");        
			    envelope.declareNamespace(vis);
		
			    envelope.getBody().addChild(webServiceRequest);
			    mc.setEnvelope(envelope);
			    sender.addMessageContext(mc);
					        
				String webserviceReponse = "";
		        try
		        {
		        	sender.execute(true);	
			        MessageContext responsemsg =
sender.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
					SOAPBody body = responsemsg.getEnvelope().getBody();
					webserviceReponse = body.toString();	

			            client.cleanup();
			            client.cleanupTransport();
			            client.disengageModule("addressing");
			            client.disengageModule("rampart");
			            sender.reset();
				}
				catch(AxisFault e)
				{
					System.out.println("Exception is"+e);
					e.printStackTrace();					
				}	

			return webserviceReponse;
	}


Threads accumulating below ...

Thread "Timer-10" thread-id 125 thread-stateTIMED_WAITINGWaiting on lock:
java.util.TaskQueue@c65650
	 at: java.lang.Object.wait(Native Method)
	 at: java.util.TimerThread.mainLoop(Timer.java:509)
	 at: java.util.TimerThread.run(Timer.java:462)


Thread "Timer-9" thread-id 124 thread-stateTIMED_WAITINGWaiting on lock:
java.util.TaskQueue@14cc383
	 at: java.lang.Object.wait(Native Method)
	 at: java.util.TimerThread.mainLoop(Timer.java:509)
	 at: java.util.TimerThread.run(Timer.java:462)


Thread "Timer-8" thread-id 119 thread-stateTIMED_WAITINGWaiting on lock:
java.util.TaskQueue@b7f935
	 at: java.lang.Object.wait(Native Method)
	 at: java.util.TimerThread.mainLoop(Timer.java:509)
	 at: java.util.TimerThread.run(Timer.java:462)


Thread "Timer-7" thread-id 118 thread-stateTIMED_WAITINGWaiting on lock:
java.util.TaskQueue@4a1861
	 at: java.lang.Object.wait(Native Method)
	 at: java.util.TimerThread.mainLoop(Timer.java:509)
	 at: java.util.TimerThread.run(Timer.java:462)


Thread "MultiThreadedHttpConnectionManager cleanup" thread-id 115
thread-stateWAITINGWaiting on lock: java.lang.ref.ReferenceQueue$Lock@86b79d
	 at: java.lang.Object.wait(Native Method)
	 at: java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:116)
	 at: java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:132)
	 at:
org.apache.commons.httpclient.MultiThreadedHttpConnectionManager$ReferenceQueueThread.run(MultiThreadedHttpConnectionManager.java:1122)


Thread "Timer-6" thread-id 114 thread-stateTIMED_WAITINGWaiting on lock:
java.util.TaskQueue@80a6bd
	 at: java.lang.Object.wait(Native Method)
	 at: java.util.TimerThread.mainLoop(Timer.java:509)
	 at: java.util.TimerThread.run(Timer.java:462)


Thread "Timer-5" thread-id 113 thread-stateTIMED_WAITINGWaiting on lock:
java.util.TaskQueue@42d711
	 at: java.lang.Object.wait(Native Method)
	 at: java.util.TimerThread.mainLoop(Timer.java:509)
	 at: java.util.TimerThread.run(Timer.java:462)


-- 
View this message in context: http://old.nabble.com/Axis2-WebService---Timer-threads-are-accumuating-and-java.lang.OutOfMemoryError%3A-unable-to-create-new-native-thread-tp32359532p32359532.html
Sent from the Axis - User mailing list archive at Nabble.com.


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


Re: Axis2 WebService - Timer threads are accumuating and java.lang.OutOfMemoryError: unable to create new native thread

Posted by Amila Suriarachchi <am...@gmail.com>.
On Tue, Aug 30, 2011 at 1:04 AM, divvela <di...@yahoo.com> wrote:

>
> Hello,
> We have a webapplication runnig on glassfish version 2.1 connecting to a
> webservice using the piece of the code below. Every day we are having over
> 1000 calls. For some reason timer threads are getting accumalated day by
> day. Couple of days after we are getting java.lang.OutOfMemoryError: unable
> to create new native thread ... Which indicates probably some thing wrong
> with code or some bug in axis2 which i am not aware of ... Please help ...
> This is becoming a BIG BIG production issue for us. Appreciate your help in
> this matter.
>
>        public String CallWebService(String webServiceName, OMElement
> webServiceRequest) throws Exception
>        {
>                                ConfigurationContext ctx =
>
> ConfigurationContextFactory.createConfigurationContextFromFileSystem("/export/home/test",
> "/export/home/test/conf/axis2.xml");
>

try stopping creating a configuration context per invocation. Try to keep
one configuration context object.

thanks,
Amila.

>
>                                ServiceClient client = new
> ServiceClient(ctx, null);
>                                Options options = new Options();
>                                client.setTargetEPR(new
> EndpointReference("URL"));
>                                options.setTo(new EndpointReference("URL"));
>
>  options.setAction("URLACTION"+webServiceName);
>                                options.setTimeOutInMilliSeconds(90*1000);
>                                client.setOptions(options);
>
>                                client.engageModule("addressing");
>                                client.engageModule("rampart");
>
>                                OperationClient  sender =
> client.createClient(ServiceClient.ANON_OUT_IN_OP);
>                            MessageContext mc = new MessageContext();
>                            SOAPFactory fac =
> OMAbstractFactory.getSOAP11Factory();
>                            SOAPEnvelope envelope=fac.getDefaultEnvelope();
>
>                            OMNamespace vis =
> fac.createOMNamespace("URLNAMESPACE", "emp");
>                            envelope.declareNamespace(vis);
>
>                            envelope.getBody().addChild(webServiceRequest);
>                            mc.setEnvelope(envelope);
>                            sender.addMessageContext(mc);
>
>                                String webserviceReponse = "";
>                        try
>                        {
>                                sender.execute(true);
>                                MessageContext responsemsg =
> sender.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
>                                        SOAPBody body =
> responsemsg.getEnvelope().getBody();
>                                        webserviceReponse = body.toString();
>
>                                    client.cleanup();
>                                    client.cleanupTransport();
>                                    client.disengageModule("addressing");
>                                    client.disengageModule("rampart");
>                                    sender.reset();
>                                }
>                                catch(AxisFault e)
>                                {
>                                        System.out.println("Exception
> is"+e);
>                                        e.printStackTrace();
>                                }
>
>                        return webserviceReponse;
>        }
>
>
> Threads accumulating below ...
>
> Thread "Timer-10" thread-id 125 thread-stateTIMED_WAITINGWaiting on lock:
> java.util.TaskQueue@c65650
>         at: java.lang.Object.wait(Native Method)
>         at: java.util.TimerThread.mainLoop(Timer.java:509)
>         at: java.util.TimerThread.run(Timer.java:462)
>
>
> Thread "Timer-9" thread-id 124 thread-stateTIMED_WAITINGWaiting on lock:
> java.util.TaskQueue@14cc383
>         at: java.lang.Object.wait(Native Method)
>         at: java.util.TimerThread.mainLoop(Timer.java:509)
>         at: java.util.TimerThread.run(Timer.java:462)
>
>
> Thread "Timer-8" thread-id 119 thread-stateTIMED_WAITINGWaiting on lock:
> java.util.TaskQueue@b7f935
>         at: java.lang.Object.wait(Native Method)
>         at: java.util.TimerThread.mainLoop(Timer.java:509)
>         at: java.util.TimerThread.run(Timer.java:462)
>
>
> Thread "Timer-7" thread-id 118 thread-stateTIMED_WAITINGWaiting on lock:
> java.util.TaskQueue@4a1861
>         at: java.lang.Object.wait(Native Method)
>         at: java.util.TimerThread.mainLoop(Timer.java:509)
>         at: java.util.TimerThread.run(Timer.java:462)
>
>
> Thread "MultiThreadedHttpConnectionManager cleanup" thread-id 115
> thread-stateWAITINGWaiting on lock:
> java.lang.ref.ReferenceQueue$Lock@86b79d
>         at: java.lang.Object.wait(Native Method)
>         at: java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:116)
>         at: java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:132)
>         at:
>
> org.apache.commons.httpclient.MultiThreadedHttpConnectionManager$ReferenceQueueThread.run(MultiThreadedHttpConnectionManager.java:1122)
>
>
> Thread "Timer-6" thread-id 114 thread-stateTIMED_WAITINGWaiting on lock:
> java.util.TaskQueue@80a6bd
>         at: java.lang.Object.wait(Native Method)
>         at: java.util.TimerThread.mainLoop(Timer.java:509)
>         at: java.util.TimerThread.run(Timer.java:462)
>
>
> Thread "Timer-5" thread-id 113 thread-stateTIMED_WAITINGWaiting on lock:
> java.util.TaskQueue@42d711
>         at: java.lang.Object.wait(Native Method)
>         at: java.util.TimerThread.mainLoop(Timer.java:509)
>         at: java.util.TimerThread.run(Timer.java:462)
>
>
> --
> View this message in context:
> http://old.nabble.com/Axis2-WebService---Timer-threads-are-accumuating-and-java.lang.OutOfMemoryError%3A-unable-to-create-new-native-thread-tp32359532p32359532.html
> Sent from the Axis - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@axis.apache.org
> For additional commands, e-mail: java-user-help@axis.apache.org
>
>


-- 
Amila Suriarachchi
WSO2 Inc.
blog: http://amilachinthaka.blogspot.com/

AW: Axis2 WebService - Timer threads are accumuating and java.lang.OutOfMemoryError: unable to create new native thread

Posted by Stadelmann Josef <jo...@axa-winterthur.ch>.
You expect to know:"it is a timer thread." 
May I ask you very kindly to tell us if you expect your timer thread 
to be on the service or the client side of the pond?
A minimum of information we need to maybe help you!
Josef

-----Ursprüngliche Nachricht-----
Von: divvela [mailto:divvela1@yahoo.com] 
Gesendet: Montag, 29. August 2011 21:35
An: axis-user@ws.apache.org
Betreff: Axis2 WebService - Timer threads are accumuating and java.lang.OutOfMemoryError: unable to create new native thread


Hello,
We have a webapplication runnig on glassfish version 2.1 connecting to a
webservice using the piece of the code below. Every day we are having over
1000 calls. For some reason timer threads are getting accumalated day by
day. Couple of days after we are getting java.lang.OutOfMemoryError: unable
to create new native thread ... Which indicates probably some thing wrong
with code or some bug in axis2 which i am not aware of ... Please help ...
This is becoming a BIG BIG production issue for us. Appreciate your help in
this matter.

	public String CallWebService(String webServiceName, OMElement
webServiceRequest) throws Exception
	{
				ConfigurationContext ctx =
ConfigurationContextFactory.createConfigurationContextFromFileSystem("/export/home/test",
"/export/home/test/conf/axis2.xml");
			
				ServiceClient client = new ServiceClient(ctx, null);
				Options options = new Options();
				client.setTargetEPR(new EndpointReference("URL"));
				options.setTo(new EndpointReference("URL"));
				options.setAction("URLACTION"+webServiceName);
				options.setTimeOutInMilliSeconds(90*1000);
				client.setOptions(options);		
		
		        	client.engageModule("addressing");
				client.engageModule("rampart");
				
				OperationClient  sender =
client.createClient(ServiceClient.ANON_OUT_IN_OP);
			    MessageContext mc = new MessageContext();
			    SOAPFactory fac = OMAbstractFactory.getSOAP11Factory();
			    SOAPEnvelope envelope=fac.getDefaultEnvelope();	
		
			    OMNamespace vis = fac.createOMNamespace("URLNAMESPACE", "emp");        
			    envelope.declareNamespace(vis);
		
			    envelope.getBody().addChild(webServiceRequest);
			    mc.setEnvelope(envelope);
			    sender.addMessageContext(mc);
					        
				String webserviceReponse = "";
		        try
		        {
		        	sender.execute(true);	
			        MessageContext responsemsg =
sender.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
					SOAPBody body = responsemsg.getEnvelope().getBody();
					webserviceReponse = body.toString();	

			            client.cleanup();
			            client.cleanupTransport();
			            client.disengageModule("addressing");
			            client.disengageModule("rampart");
			            sender.reset();
				}
				catch(AxisFault e)
				{
					System.out.println("Exception is"+e);
					e.printStackTrace();					
				}	

			return webserviceReponse;
	}


Threads accumulating below ...

Thread "Timer-10" thread-id 125 thread-stateTIMED_WAITINGWaiting on lock:
java.util.TaskQueue@c65650
	 at: java.lang.Object.wait(Native Method)
	 at: java.util.TimerThread.mainLoop(Timer.java:509)
	 at: java.util.TimerThread.run(Timer.java:462)


Thread "Timer-9" thread-id 124 thread-stateTIMED_WAITINGWaiting on lock:
java.util.TaskQueue@14cc383
	 at: java.lang.Object.wait(Native Method)
	 at: java.util.TimerThread.mainLoop(Timer.java:509)
	 at: java.util.TimerThread.run(Timer.java:462)


Thread "Timer-8" thread-id 119 thread-stateTIMED_WAITINGWaiting on lock:
java.util.TaskQueue@b7f935
	 at: java.lang.Object.wait(Native Method)
	 at: java.util.TimerThread.mainLoop(Timer.java:509)
	 at: java.util.TimerThread.run(Timer.java:462)


Thread "Timer-7" thread-id 118 thread-stateTIMED_WAITINGWaiting on lock:
java.util.TaskQueue@4a1861
	 at: java.lang.Object.wait(Native Method)
	 at: java.util.TimerThread.mainLoop(Timer.java:509)
	 at: java.util.TimerThread.run(Timer.java:462)


Thread "MultiThreadedHttpConnectionManager cleanup" thread-id 115
thread-stateWAITINGWaiting on lock: java.lang.ref.ReferenceQueue$Lock@86b79d
	 at: java.lang.Object.wait(Native Method)
	 at: java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:116)
	 at: java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:132)
	 at:
org.apache.commons.httpclient.MultiThreadedHttpConnectionManager$ReferenceQueueThread.run(MultiThreadedHttpConnectionManager.java:1122)


Thread "Timer-6" thread-id 114 thread-stateTIMED_WAITINGWaiting on lock:
java.util.TaskQueue@80a6bd
	 at: java.lang.Object.wait(Native Method)
	 at: java.util.TimerThread.mainLoop(Timer.java:509)
	 at: java.util.TimerThread.run(Timer.java:462)


Thread "Timer-5" thread-id 113 thread-stateTIMED_WAITINGWaiting on lock:
java.util.TaskQueue@42d711
	 at: java.lang.Object.wait(Native Method)
	 at: java.util.TimerThread.mainLoop(Timer.java:509)
	 at: java.util.TimerThread.run(Timer.java:462)


-- 
View this message in context: http://old.nabble.com/Axis2-WebService---Timer-threads-are-accumuating-and-java.lang.OutOfMemoryError%3A-unable-to-create-new-native-thread-tp32359532p32359532.html
Sent from the Axis - User mailing list archive at Nabble.com.


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


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