Many of you are certainly getting the warning “No theme found for specified theme id … Returning the default theme” when using a theme in Liferay 6.1 CE GA2. The reason lies on the HookDeployer of Liferay and Tomcat 7.
First of all some quick workarounds:
- You can either open the theme context xml file (context.xml in the themes deployment folder <Liferay Base dir>/tomcat-7.0.27/webapps /<Theme folder>/META-INF/context.xml) and remove the property antiJarLocking and set antiResourceLocking to false
- Add the META-INF/context.xml into your themes source with antiResourceLocking set to true
- Or, if you don’t need it, delete the hook from you theme, liferay-hook.xml and in it referenced files, and deploy it again
Now the reason:
antiJARLocking and more generally antiResourceLocking can be set to true to avoid file locking within the web application. They are helpful especially when the web application wars are big. When antiResourceLocking is set to true, tomcat will copy the web application folder into its temp folder and will append a version number to its name. However, Liferay is not yet aware it. Liferay is associating each organization Id with its corresponding theme Id which is constructed from the string concatenation <name> _WAR_<name>theme
. When Loading the CSS from the theme context (from the theme context in the temp folder of tomcat, see DynamicCSSUtil._getTheme), liferay regenerates the theme id from the context name. This will return the wrong theme id since the result will be something like <Version-Number><name> _WAR_< Version-Number><name>
(ThemeLocalServiceImpl.getTheme)