This can happen when running Magnolia on Unix (including OSX) with File Based database like Derby or when using FileBasedDBPersistenceManager.
The cause of the problem is limit in total amount of file descriptors allowed to be open on any given system.
You can also solve this issue by getting rid of Derby and switching to database supported persistence.
This can vary depending on what was happening when the limit was hit
It can be refusal when trying ot open socket:
Failure to create a file:
Or even SQLException:
On some of the systems you get a "
Too many open files" message on others there is no such clue provided.
Check your system limits:
Each of the commands above should give you the limit value for files descriptors. I've seen the error on systems where this limit was set to 250 000 or less. Please note that this number is sum of all open files on given system (sockets are treated as files on *nix so they contribute to the total number as well).
To check the number of file descriptors used by any given process use
or use the lsof (LiSt Open Files) command
or (my favourite)
non of the above were sufficient under Ubuntu. Please run
1024 is too few. Note that ulimit is built into bash, not a program of its own. If you use something else, type bash to change the shell for the ulimit command. Please apply both steps of the following solution
System wide limit change
Change limit by editing
/etc/sysctl.conf and set
fs.file-max to 5000
to apply your changes to your system. In some cases (saw that for on system using kernel 2.6.28) this might still not be enough and you need to restart complete system before change is applied even tho using commands above it appears that the change was applied!
If this is still not enough you might want to increase the number even further. This can happen on server systems running more applications that use file system extensively (e.g. anything that uses derby DB, or any FS based indexing services)
The above changes the system wide file descriptor limit. Check the documentation for your system to find out if there are other limits that need to be changed. For example OSX Leopard seems to be setting limit of 1000 file descriptors per user. On other systems limits are set per process.
Per user/process limit change
For Linux systems running PAM (that is e.g. Ubuntu) you will need to adjust
/etc/security/limits.conf The format of this file is
<username> <limit type> <item> <value>.
E.g. to set the limit for the user
tomcatservice the following line would be used:
In other systems it might be the
/etc/limits file that needs to be modified. To do the equivalent of PAM setting add following line:
This latest command will only affect the current user in the current session, and only root is allowed to change the ulimit so you would need to run magnolia as root.
This call does not really work on my computers with Ubuntu. I was only be able to reduce the number of open files. Increasing was prohibited. Under ubuntu please verify with the last proposed step (ulimit -n).