Tuesday, March 9, 2010

Axis2 temp files

Axis2 supports archive based deployment for both services (.aar) and modules (.mar). These files can internally have 'lib' folders to contain the third party libraries of those services.
From Axis2 1.5, when Axis2 creates Configuration Context object which happens when the server starts up or service client invocation, it creates a separate folder under the temp folder to store the temp files. This temp folder is taken from the "java.io.tmpdir" system property.
For an example if Axis2 1.5 is deployed under tomcat 6.0.24, it creates the following two files under $CATALINA_TMPDIR.

Axis2 creates .lck files as a temp file which deletes on a jvm exits.

File lockFile = new File(tmpDirName, tmpDir.getName() + ".lck");

Therefore when the tomcat goes down this .lck file should also be deleted. But the .tmp folder remains. At the next start up time Axis2 searches for .tmp file folders which does not have a corresponding .lck files and deletes them. So there can not be any grow of temp files.

One important thing to remember is that Axis2 copies the repository files (.aar and .mar) when ever it creates a configuration context object. Therefore the tmp folder can be grown while in the server running. Obviously this can be stopped by using one configuration context object for all the service invocations.

But there are some instances where .lck file is not properly deleted when the jvm exits. For those situations the temp folder can be deleted within the server starts up shell script. For tomcat this can be done adding code to catalina.sh.


xvrbx said...

Hi Amila,

I apologize for contacting you through your personal blog. I bookmarked some time ago your article "Auto scaling web services on Amazon EC2", but it seems it's no longer availabe (I get a Permission Denied error when trying to access it).

Do you have any copy of your article posted somewhere else?

Kind regards,

Anonymous said...

Hi Amila, This is a very informative blog. Thanks for sharing.

I have one peculiar situation at my work.

I am using Axis2 Client. This is a stand alone application. When I access the web-service on the server for the very first time I see it takes around 10 seconds to retrieve. However subsiquent calls take only around 200 milli secs. However, sometimes again the time taken shoots up but comes down subsequently. would you have come across such situations.


Amila Suriarachchi said...

The first request may create the configuration context object and other calls can use it. And also some times class loading may cause delays for first request.

May be due to garbadge collections.

Anonymous said...

Hi Amila,

I am having the issue you discuss on this blog. Basically I have created one ConfigurationContext object for the whole application, howevere eveytime the service is invoked it keeps on copying about 20 jars and the mar files to a temporary folder "_axis2".

I am not able to delete these files until I stop the service I have created for this application... Basically when I stop the application.

Is there a way this files get deleted automatically without having to stop the application or the service?

My question is how can I overcome this issue of not being able to delete the files since it is taking up heaps of space on my hard drive? Is there a cleanup call or something?

Also, do the wsdl2java generated clases have to do anything with this? I wouldnt think so hey?

Anonymous said...

Is there any solution found for solving the temp directory full of jar/mar issue? Please tell me guys..... I really break my head

munmun said...
This comment has been removed by the author.
munmun said...

Hi Amila,

I am using axis2 client.
Whenever I am starting and stopping the tomcat.
These files are getting automatically genetrated _axis2 folder but the old files are not getting deleted automatically:-

because of these files are getting accumulated i am facing "LowActivePartitionAvailableDiskSpace" alert.


On this link this issue "AXIS2-3919" seems familiar to my problem. In this issue in the last blog by "shivendra tripathi" saying that this issue is fixed in axis2 1.5 is fixed.
But when i visit to above link is is still showing unresolved.
Just wanted to know that fix for this problem is present in axis2 in axis2 1.5?
I am using axis2 1.4, is there any work around available for this problem in axis2 1.4 in case we don't want to upgrade to
axis2 1.5.
In my case these .lck files are not getting generated.


Anonymous said...

If I am using Axis2 client in a command line program, it doesn't seem that these temp files are created. However, if the same code are wrapped within say a tomcat servlet, then all the temp files shows up in temp folder. How does Axis2 "smart" enough to know which environment it is running within? Why should it care? Am i missing something here? This to me is clearly a bug.

Anonymous said...

To answer the last post, actually it does generate the temp file as well. It is stored in windows under Users//AppData/Local/...

Anonymous said...


Do we have a fix for the solution, even our application uses axis2 to invoke web service and this tmp folder gets filled up with these jars. Have any one figured it out?

vinkal vishnoi said...

You have written lot of stuff on web services. I am new to web service. There is requirement to have the return type of java.util.HashMap. I searched over the internet but was not able to find out the possible solution. Would you Please help me, how can we have return type of util.HashMap.
Temporarly i made a wrapper where i returned a class HashMap1
{String key;String value;
It is working fine. But util.HashMap is not working..

Vinkal Vishnoi

vinkal vishnoi said...

There is one more requirement of throwing a Custom Exception. But when i use custom exception class then in the client side it does not show the custom message,instead it shows the CustomException Class name. Is there any way around to solve this.

If i throw AxisFault(with some msg) from server,it is working properly.

Please tell me if the solution is possible.

Anonymous said...

I found the large amount of AXIS Module Archive (MAR) files exist in C:\WINDOWS\TEMP

How to clean up this and
axis2-tmp-xxxxxxxxxx.tmp and .lck files

Rajveer said...

Hi Amila,
I am facing the same issue for increasing size of temp folder inside the CATALINA_HOME\temp, Can I configure the temp folder any where else by Apache Axis2.

Your response is appreciated.
Ram Ji Soni

Anonymous said...

Hi Amila

In my project we are using axis2 of version 1.3, as the project uses web-services. Currently we are in need of replacing commons-httpclient-1.3.1.jar with the httpclient-4.0.3.jar file version.

I am not sure whether the recent version of AXIS2, that is 1.6.2 supports httpclient-4.0.3.jar file version. Can you please confirm the same. Or can you please let me know the steps to upgrade httpclient.jar

Thanks in advance,

Unknown said...

how to use a single configuration object for multiple invocations? can you please expalin with an example?


Vartika Gupta said...

Great article, well explained !!