Monday, September 29, 2014

Liberty or death

I was working on an application which was working fine on WebSphere server (as war and Eclipse Project). Deploy on Liberty through WAR was also working fine.

Like any other good developer wanted to shift to WAS Liberty for faster development but on trying to deploy on Liberty through Eclipse project, "js, gif, css" files were not getting loaded in the web page. Because of this the page was looking distorted and most of the functionality was lost. For all the mentioned files (js etc) I got 500 (Internal Server Error). There were no console errors and the server log was also clean.
I tried both loose config and 'from workspace' settings + lots of other workarounds but nothing.
Only helpful hint I found was, there were some spring initialization errors in server log. But Spring code was in a jar which was developed by another team so could not debug. 

After weeks of hard work found the issue which was not even a mile close to the problem I was facing. 

Due to wrong code for REST implementation, the base path was set as root application path “/”, instead of something like "/rest/*" . So whenever the first link to the application was getting clicked, REST API classes were getting instantiated before application was fully initialized. And this REST code was making calls to few Spring instantiated beans. But at this point the Spring listeners had not fired, hence the appcontext was empty. Some of the base application object were getting initialized with empty beans and hence spring security context and related classes were failing to serve the application content properly. 

The thing that makes it more irritating is : The same problematic code is working fine on Websphere full profile and Weblogic and even on Liberty if we deploy as WAR. Not sure what classloading difference is causing difference in behavior. I checked the difference between WAS full profile and liberty profile but nothing specific. 

Good thing is, now I am on Liberty, happily coding, looking forward to solve similar irritating issues in lesser time :)

No comments:

Post a Comment