I get this Gradle error:
> Task :jar
[Class my.MyPortlet is not assignable to specified service com.liferay.portal.kernel.model.Portlet]
... for this minimalist Liferay 7 portlet (a simplification of the official documentation):
package my;
import com.liferay.portal.kernel.model.Portlet;
import com.liferay.portal.kernel.portlet.bridges.mvc.MVCPortlet;
import org.osgi.service.component.annotations.Component;
@Component(
service = Portlet.class
)
public class MyPortlet extends MVCPortlet {
}
Running Gradle in debug mode does not give me more clues:
[aQute.bnd.osgi.Builder] parseClassFile(): path=javax.portlet.PortletRequest resource=:/home/nico/.gradle/caches/modules-2/files-2.1/javax.portlet/portlet-api/2.0/1cd72f2a37fcf8ab9893a9468d7ba71c85fe2653/portlet-api-2.0.jar(javax/portlet/PortletRequest.class):
[aQute.bnd.osgi.Builder] end
[aQute.bnd.osgi.Builder] begin com.liferay.ant.bnd.npm.NpmAnalyzerPlugin@39735dcf
[aQute.bnd.osgi.Builder] end
[aQute.bnd.osgi.Builder] begin com.liferay.ant.bnd.resource.bundle.ResourceBundleLoaderAnalyzerPlugin@4e811a19
[aQute.bnd.osgi.Builder] end
[aQute.bnd.osgi.Builder] parseClassFile(): path=my/MyPortlet.class resource=/home/nico/my/build/classes/java/main/my/MyPortlet.class
[aQute.bnd.osgi.Builder] begin com.liferay.ant.bnd.sass.SassAnalyzerPlugin@526cd630
[aQute.bnd.osgi.Builder] end
[aQute.bnd.osgi.Builder] begin com.liferay.ant.bnd.service.ServiceAnalyzerPlugin@a73dc4
[aQute.bnd.osgi.Builder] end
[aQute.bnd.osgi.Builder] begin com.liferay.ant.bnd.social.SocialAnalyzerPlugin@2399853a
[aQute.bnd.osgi.Builder] end
[aQute.bnd.osgi.Builder] begin aQute.lib.spring.SpringComponent@650e1282
[aQute.bnd.osgi.Builder] end
[aQute.bnd.osgi.Builder] begin com.liferay.ant.bnd.spring.SpringDependencyAnalyzerPlugin@51e79545
[aQute.bnd.osgi.Builder] end
[aQute.bnd.osgi.Builder] parseClassFile(): path=my/MyPortlet.class resource=/home/nico/my/build/classes/java/main/my/MyPortlet.class
[aQute.bnd.osgi.Verifier] Trying pre-plugin com.liferay.ant.bnd.jsp.JspAnalyzerPlugin
[aQute.bnd.osgi.Verifier] Trying pre-plugin com.liferay.ant.bnd.npm.NpmAnalyzerPlugin
[aQute.bnd.osgi.Verifier] Trying pre-plugin com.liferay.ant.bnd.resource.bundle.ResourceBundleLoaderAnalyzerPlugin
[aQute.bnd.osgi.Verifier] Trying pre-plugin com.liferay.ant.bnd.sass.SassAnalyzerPlugin
[aQute.bnd.osgi.Verifier] Trying pre-plugin com.liferay.ant.bnd.service.ServiceAnalyzerPlugin
[aQute.bnd.osgi.Verifier] Trying pre-plugin com.liferay.ant.bnd.social.SocialAnalyzerPlugin
[aQute.bnd.osgi.Verifier] Trying pre-plugin aQute.lib.spring.SpringComponent
[aQute.bnd.osgi.Verifier] Trying pre-plugin com.liferay.ant.bnd.spring.SpringDependencyAnalyzerPlugin
[org.dm.gradle.plugins.bundle.JarBuilder] [Class my.MyPortlet is not assignable to specified service com.liferay.portal.kernel.model.Portlet]
Google has only 9 results for "is not assignable to specified service".
What am I doing wrong?
With your source import:
import com.liferay.portal.kernel.model.Portlet;
and then:
@Component( service = Portlet.class )
You are asserting that your class
MyPortlet
implementscom.liferay.portal.kernel.model.Portlet
. But it does not.com.liferay.portal.kernel.portlet.bridges.mvc.MVCPortlet
implementsjavax.portlet.Portlet
.Change you source import from
com.liferay.portal.kernel.model.Portlet
tojavax.portlet.Portlet
.