How to delete apache axis tmp files without restarting

11,018

Solution 1

If you know the temp directory path, You may run rm -rf /path/to/temp/* every 6 , 12 ..etc through cron.

Or you may write bashscript of you are running on linux system to empty this directory if it reaches a specific size. And put it also in crontab.

Solution 2

We found a programmatic way to avoid generation of those files - which sounds like a better way to do the housekeeping. I posted that in the comments of AXIS2-3919 issue, but will copy it here just in case:


Actually, the files are deployed to the temp folder each time AXIS configuration context is created. Also, it appears that the generated Stub can accept existing configuration object via the constructor. So, the following Spring configuration helped us to solve the issue (irrelevant bean and class names dropped):

<bean id="....Stub" factory-bean="...." factory-method="...." scope="request">
    <!-- this next element effects the proxying of the surrounding bean, 
        needed because .... will try to set the stub out of request scope -->
    <aop:scoped-proxy/>
    <constructor-arg index="0" >
        <!-- The WS stub is created here, and passed to the factory-method of ... as a parameter -->
        <bean class="com......ws.....Stub" scope="prototype">
            <constructor-arg ref="axisConfigContext" />
        </bean>
    </constructor-arg>
</bean>

<!-- Exists to avoid deployment of axis jar into temp dir for each request. See     AXIS2-3919 for more details. -->
<bean id="axisConfigContext" 
        class="org.apache.axis2.context.ConfigurationContextFactory" 
        factory-method="createConfigurationContextFromFileSystem">
    <constructor-arg index="0"><null /></constructor-arg>
    <constructor-arg index="1"><null /></constructor-arg>
</bean>

Solution 3

Temp files are created whenever a new ConfigurationContext is created. So create a ConfigurationContext only once in a static block and use it in all the subsequent calls.

private static ConfigurationContext configContext;

static {
     configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(null, null);
}

public callService() {
    Stub stub = new Stub(configContext, END_POINT_URL);
    //code
}

If you don't pass a context, axis2 will create a new context on each call.

Solution 4

I tried the solution (provided by proudandhonour) of creating static block and it works great. It only creates temp files for the first request. I also update uilimit on Linux server to 16000. Now I don't need to delete temp files.

private static ConfigurationContext configContext; 
static{   
   configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(null, null);  
}

Solution 5

I've been looking at the same problem, and it looks like it might be fixed in version 1.7.0:

https://issues.apache.org/jira/browse/AXIS2-3919

I haven't tried it yet, but I'll update this comment once I do.

Share:
11,018
Programming Guy
Author by

Programming Guy

Updated on June 07, 2022

Comments

  • Programming Guy
    Programming Guy almost 2 years

    We're using apache axis to talk to a web service. It works fine, but over the course of a day we're generating 1GB of temp files. These files are deleted if we restart the service, but needing to restart the service every day so we don't run out of disk space seems a bit silly.

    Is there an easy fix for this?