November 21, 2012

Eclipse : JS validator error on minified javascript files

Eclipse was giving me errors on minified javascript files located in my theme plugin.
There's a configuration in the Windows / Preferences / Validator menu to exclude some files from the validator scope, but it's not that natural, so I'll write it down here 

You'll have to go to this menu



Then click on the settings button in the last column.


From there you can add an exclude group, and then add some exclusion rules





The thing here is that I was working with Liferay plugin SDK, so my javascript file to exclude was located outside of my workspace.

But even if the Browse button doesn't seem to work when you try to pick a resource outside of your eclipse workspace, you can put a relative path in the text field.

Hope this help.

November 20, 2012

Liferay classloader issue when overriding a Liferay service class under tomcat

I had to override the ThemeDisplay class, located in the service area of Liferay.

To do so, I created an ext plugin and put my overridden implementation of the class into the right package.

On my local server, everything goes smooth, as well as on several other servers.

On another server though, I hit a NoSuchMethodException on the one method I added to the new class, as if the overridden class wasn't loaded. And indeed it wasn't picked up by the classloader

As someone very wise said on this thread
"The problem is related to a class loading issue with the app server / servlet container. The order of loading files usually depends on the jvm, filesystem, OS and the weather."
So depending on your configuration, it looks like your ext service jar will be picked up before the real service jar... or not.

The easiest way to fix the problem

The overriden class of the service jar get bundled in a TOMCAT_HOME/lib/ext/ext-myPlugin-service.jar

So put yourself in the TOMCAT_HOME/lib directory, which jar files are loaded before liferay lib/ext directory, and create a symbolic link from this directory to the ext service jar :
$ cd [TOMCAT_HOME]/lib
$ ln -s ext/ext-myPlugin-service.jar




And voila, your service ext jar is loaded first and you can use your overridden class.

That solution came from Alex Weirig here

Hope this help.