Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
RE: Is deleting the osgi/state folder a bad practice?
there are times where while developing, the liferay server can come to a state, in which something is working wrong, but we don't know whan it is. Restarting the server resolves the problem in many cases, but not always. In liferay 6.2 we stoped the server, deleted work and temp folders and then started the server again. Even more, we could delete our plugins from the webapps folder. This "clean" restart was more succesful. In liferay 7 (or 7.1) we can delete the same folders, but there is also the osgi/state folder. This folder contains all the modules/bundles that are deployed in the osgi container.
If we install all our modules/bundles through the deploy folder as jars, is it a good practice the delete also the state fodler together with work and temp to accieve a clean restart?
Thank you in advance,
Harry
If the directory doesn't exist, OSGi will rebuild it all at restart.
In general though you don't want to delete it as it will affect your startup times.
I typically will only delete it when something is not acting right. This happens to me mostly when my bundle modifications change the meta information that OSGi has not updated osgi/state correctly.
so, there are cases as you noticed, where deleting the state folder makes sense.
Looking into the state folder, under the org.eclipse.osgi subfolder, there are all bundle ids as folders and in those a subfolder with a number that contains mostly the jar in the form of a file named bundleFile.
Do you know what this number means?
The number is the numeric ID of the bundle. You can use it for example in the gogo shell, to reference a bundle with a short number instead of its long symbolic name.
When you enter lb (list bundle) in the shell you can see the ID for each bundle.
If you delete the state folder, each bundle will get a new ID - which is usually no problem, because the IDs are only used during runtime and inside the state folder.
Hi Tobias,
you are right. Only I wanted to know the following number (I didn't explained it well):
/osgi/state/org.eclipse.osgi/[bundleId]/[unknownNumber]/bundleFile
So, unknownNumber
is the number I was asking about.
Checking it out, I saw the values 0 (moslty), but also 1,2,4 or 7.
The second number is just the "version" of the bundle (the number starts by 0 and is increased every time the bundle is redeployed). This ensures that even open files of previous versions don't prevent deployment of a new version of a bundle.
Most often you have only the last version of a bundle - and as most of the bundles are never redeployed, the usual number is "0".
But for those of your WAB bundles which contain further third party libraries, you will often find more than one version directory with all the previous versions containing all these libraries and a file ".delete" indicating that this directory may be deleted.
Thanks a lot Tobias for the info!
Powered by Liferay™