Thursday, 3 September 2009

Java Cache Profile Size Problems

EDIT:  see my later post on this subject for more tips on managing roaming profile sizes

Been having this for a while, off and on with various clients, particularly on Citrix/Terminal servers, user calls up unable to log off because their profile exceeds the size limit.

9 times out of 10, this is due to the Java cache with the other 10% being Adobe update files. These programs incorrectly store temporary data in the roaming part of the user profile rather than the local part where it should be. The Adobe issue is rarer and easily dealt with by deleting the update file, but the Java cache keeps coming back.

The solution is to move the Java temporary files cache which can be easily done from the Java Control Panel applet. Unfortunately on a typical locked down terminal server, users do not have access to the Control Panel to change this and it is a per user setting, so changing it as the administrator doesn't help.

After much intensive Googling I finally found how to change this in the background, without having to give the user admin rights and log on as them (which is even more of a pain the more users you have). All that needs to be done is to add a line to the Java deployment.properties file to set the deployment.user.cache property.

This file is located in the user profile, so normally,
C:\Documents and Settings\_username_\Application Data\Sun\Java\Deployment\deployment.properties

By default (with the deployment.user.cache property not present), Java cache files are stored in
C:\Documents and Settings\_username_\Application Data\Sun\Java\Deployment\cache

And this is the problem, that should be \Local Settings\Application Data..... in order for those temp files to be kept locally to the machine and not copied around as part of the roaming profile.



Now setting this to a different location is easy, just add to the deployment.properties file, say

deployment.user.cache=C\:\\Temp

*note the escaped characters !

However, the user in question needs write access to this location (which they shouldn't have if the server is even marginally locked down), so the best bet is to just dump it into the Local Settings part of the profile. Trouble is, the deployment.properties file does not support system environment variables so you need to hard code the full path, which is a problem if you are trying to script this setting for all users.

Luckily the file does recognise some Java environment variables one of which can be inelegantly kludged to point into the correct location:

deployment.user.cache=$USER_HOME\\..\\..\\..\\Local Settings\\Application Data\\Sun\\Java\\Deployment\\cache

* NOTE - this is all one line.


This can easily be added to logon scripts, e.g.

echo
deployment.user.cache=$USER_HOME\\..\\..\\..\\Local Settings\\Application Data\\Sun\\Java\\Deployment\\cache >> %APPDATA%\Sun\Java\Deployment\deployment.properties

* NOTE - this is all one line too.


The Java client seems to read and rewrite this file on a pretty frequent basis so it will clean up any additional lines that are put in.

An even better method is to use a machine wide deployment.properties file.


You will need to create the following two files:

C:\Windows\Sun\Java\Deployment\Deployment.config

deployment.system.config=file\:C\:/WINDOWS/Sun/Java/Deployment/deployment.properties

* NOTE - this is all one line

C:\Windows\Sun\Java\Deployment\Deployment.properties

deployment.user.cachedir=$USER_HOME\\..\\..\\..\\..\\Local Settings\\Application Data\\Sun\\Java\\Deployment\\cache

deployment.user.cachedir.locked=

* NOTE - this is two lines.

The last line locks the setting so that users cannot change it, so you may or may not want this.


Lastly, if you are running on a Windows 2008 Server you don't need to worry about any of this.  On 2008 the default location is in the LocalLow part of the profile which doesn't roam - at last!

No comments:

Post a Comment