RE: Add more details to the fatal FlatJSPackage error message

Jan Tošovský, modified 11 Months ago. Liferay Master Posts: 576 Join Date: 7/22/10 Recent Posts

Recently I had to recover the server from a backup after clearing the /osgi/state, because I was getting "A JS module with the same name already exists" exception when the server was restarted. There are over 100 custom modules in my instance and it was unclear which one is faulty. The issue was fatal as I couldn't even show the login page.

Later I was able to detect the problematic module by tweaking the relevant code, which now prints the given module details:
https://github.com/liferay/liferay-portal/blob/master/modules/apps/frontend-js/frontend-js-loader-modules-extender/src/main/java/com/liferay/frontend/js/loader/modules/extender/internal/npm/flat/FlatJSPackage.java

if (_jsModules.putIfAbsent(jsModule.getName(), jsModule) != null) {
	throw new IllegalStateException(
		"A JS module with the same name " + jsModule.getName() + " (" + getId() + ") already exists in " + _jsModules.get(jsModule.getName()).getJSPackage().getId());
}

It would be nice to have something like this directly in the LR code. After removing that module (a JSP override containing a main.js file) the server restarted successfully. Once that module was redeployed, no similar exception was thrown anymore (it will be thrown next time the /osgi/state/ is cleared).

 

thumbnail
Jamie Sammons, modified 10 Months ago. Expert Posts: 367 Join Date: 9/5/14 Recent Posts

Feature Request Created: https://liferay.atlassian.net/browse/LPD-42483