Wednesday, December 14, 2016

Liferay 7 Portlet Deployment FrameworkEvent ERROR

So I'm learning Liferay 7 and at one point I slammed into this error when deploying a new portlet:

[Framework Event Dispatcher: Equinox Container: 80bc0073-27c2-0016-1b3f-f18a52a8a071][com_liferay_portal_osgi_web_servlet_context_helper:97] FrameworkEvent ERROR
org.osgi.framework.ServiceException: Exception in com.liferay.portal.osgi.web.servlet.context.helper.internal.ServletContextHelperRegistrationServiceFactory.getService()

Multiple attempts to search the web for some insights failed, so here we are, a new post at last!

The issue is actually fairly simple.  In my pom.xml file I had, among others, the following dependency:

   
   
<dependency>
     
<groupId>com.liferay.portal</groupId>
     
<artifactId>com.liferay.portal.kernel</artifactId>
     
<version>2.17.0</version>
   
</dependency>

This was actually colliding with the .jar already loaded into Tomcat.  The fix was simple:

   
    <dependency>
     
<groupId>com.liferay.portal</groupId>
     
<artifactId>com.liferay.portal.kernel</artifactId>
     
<scope>provided</scope>
     
<version>2.17.0</version>
   
</dependency>

By marking the dependency entry as 'provided' the jar won't be bundles into the .war file upon deployment.

So it would be good to go through and determine whether the version of this .jar in the dependency is different from the one in the portal instance.  (I presume it is.)  Either way it should have been listed as 'provided' in the first place.