Message Boards

Exception - Liferay Portlet3 Requires 3.0 opt-in

Filipe Santana, modified 4 Years ago.

Exception - Liferay Portlet3 Requires 3.0 opt-in

New Member Posts: 4 Join Date: 12/3/19 Recent Posts
Hi everyone.I'm trying to enable portlet 3.0 in my app, using Liferay 7.2 CE.
I've already configure my Portlet class like this

@Component(
        immediate = true,
        property = {
                "com.liferay.portlet.display-category=category.hidden",
                "com.liferay.portlet.scopeable=true",
                "javax.portlet.display-name=Guestbooks",
                "javax.portlet.expiration-cache=0",
                "javax.portlet.init-param.portlet-title-based-navigation=true",
                "javax.portlet.init-param.template-path=/",
                "javax.portlet.init-param.view-template=/guestbook_admin/view.jsp",
                "javax.portlet.name=" + GuestbookPortletKeys.GUESTBOOK_ADMIN,
                "javax.portlet.resource-bundle=content.Language",
                "javax.portlet.security-role-ref=administrator",
                "javax.portlet.supports.mime-type=text/html",
                "com.liferay.portlet.add-default-resource=true",
                "javax.portlet.version=3.0"
        },
        service = javax.portlet.Portlet.class
)


However I still getting the following exception:
2019-12-03 15:23:09.182 ERROR [http-nio-8080-exec-4][IncludeTag:128] Current URL /web/guest/home/-/asset_publisher/P3UE1H5OERI4/guestbook/id/33615?_com_liferay_asset_publisher_web_portlet_AssetPublisherPortlet_INSTANCE_P3UE1H5OERI4_redirect=http%3A%2F%2Flocalhost%3A8080%2Fweb%2Fguest%2Fhome%3Fp_p_id%3Dcom_liferay_asset_publisher_web_portlet_AssetPublisherPortlet_INSTANCE_P3UE1H5OERI4%26p_p_lifecycle%3D0%26p_p_state%3Dnormal%26p_p_mode%3Dview%26_com_liferay_asset_publisher_web_portlet_AssetPublisherPortlet_INSTANCE_P3UE1H5OERI4_cur%3D0%26p_r_p_resetCur%3Dfalse%26_com_liferay_asset_publisher_web_portlet_AssetPublisherPortlet_INSTANCE_P3UE1H5OERI4_assetEntryId%3D33615 generates exception: java.lang.UnsupportedOperationException: Requires 3.0 opt-in
java.lang.UnsupportedOperationException: Requires 3.0 opt-in
    at com.liferay.portlet.internal.PortletRequestImpl.getRenderParameters(PortletRequestImpl.java:522)
    at com.liferay.portlet.internal.PortletURLImpl._initMutableRenderParameters(PortletURLImpl.java:1607)
&nbsp;&nbsp; &nbsp;at com.liferay.portlet.internal.PortletURLImpl.<init>(PortletURLImpl.java:1280)
&nbsp;&nbsp; &nbsp;at com.liferay.portlet.internal.PortletURLImpl.<init>(PortletURLImpl.java:119)
&nbsp;&nbsp; &nbsp;at com.liferay.portlet.internal.RenderURLImpl.<init>(RenderURLImpl.java:43)
&nbsp;&nbsp; &nbsp;at com.liferay.portlet.internal.PortletURLFactoryImpl._create(PortletURLFactoryImpl.java:236)
&nbsp;&nbsp; &nbsp;at com.liferay.portlet.internal.PortletURLFactoryImpl._create(PortletURLFactoryImpl.java:248)
&nbsp;&nbsp; &nbsp;at com.liferay.portlet.internal.PortletURLFactoryImpl.create(PortletURLFactoryImpl.java:173)
&nbsp;&nbsp; &nbsp;at com.liferay.portal.kernel.portlet.PortletURLFactoryUtil.create(PortletURLFactoryUtil.java:115)
&nbsp;&nbsp; &nbsp;at com.liferay.docs.guestbook.web.internal.asset.GuestbookAssetRenderer.getURLViewInContext(GuestbookAssetRenderer.java:149)
&nbsp;&nbsp; &nbsp;at org.apache.jsp.view_005fasset_005fentry_005ffull_005fcontent_jsp._jspService(view_005fasset_005fentry_005ffull_005fcontent_jsp:348)
&nbsp;&nbsp; &nbsp;at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:111)
&nbsp;&nbsp; &nbsp;at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
&nbsp;&nbsp; &nbsp;at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:411)
&nbsp;&nbsp; &nbsp;at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:473)
&nbsp;&nbsp; &nbsp;at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:377)
&nbsp;&nbsp; &nbsp;at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
&nbsp;&nbsp; &nbsp;at com.liferay.portal.osgi.web.servlet.jsp.compiler.internal.JspServlet.service(JspServlet.java:369)
&nbsp;&nbsp; &nbsp;at com.liferay.portal.osgi.web.servlet.jsp.compiler.internal.JspServlet.service(JspServlet.java:381)
&nbsp;&nbsp; &nbsp;at org.eclipse.equinox.http.servlet.internal.registration.EndpointRegistration.service(EndpointRegistration.java:153)
</init></init></init>

Could anyone help me, please?
ThanksFilipe Santana
thumbnail
Jamie Sammons, modified 4 Years ago.

RE: Exception - Liferay Portlet3 Requires 3.0 opt-in

Expert Posts: 301 Join Date: 9/5/14 Recent Posts
Hi Filipe,

It looks like you may need to set an addtional property to enable portlet 3.0: https://portal.liferay.dev/docs/7-1/reference/-/knowledge_base/r/breaking-changes#upgrade-considerations
Filipe Santana, modified 4 Years ago.

RE: Exception - Liferay Portlet3 Requires 3.0 opt-in

New Member Posts: 4 Join Date: 12/3/19 Recent Posts
Hello Jamie,I could not found any other property to set.Do you know which one is missing from my configuration?
Thank you
thumbnail
Jamie Sammons, modified 4 Years ago.

RE: Exception - Liferay Portlet3 Requires 3.0 opt-in

Expert Posts: 301 Join Date: 9/5/14 Recent Posts
Hi Filipe,
My apologies I missed the fact that you already had javax.portlet.version=3.0 set in the app.  What's strange is it appears to be the Asset Publisher that is displaying the error.
Filipe Santana, modified 4 Years ago.

RE: Exception - Liferay Portlet3 Requires 3.0 opt-in

New Member Posts: 4 Join Date: 12/3/19 Recent Posts
Hi Jamie. That's fine. Same impression here... Thanks.
thumbnail
Aldo De Vleeschauwer, modified 4 Years ago.

RE: Exception - Liferay Portlet3 Requires 3.0 opt-in

Junior Member Posts: 35 Join Date: 3/9/11 Recent Posts
We have the same issue, it looks like the Request object that is passed to the AssetRenderer is not 3.0.
thumbnail
Aldo De Vleeschauwer, modified 4 Years ago.

RE: Exception - Liferay Portlet3 Requires 3.0 opt-in

Junior Member Posts: 35 Join Date: 3/9/11 Recent Posts
None of the Liferay portlets have "javax.portlet.version=3.0" set, so no help in using the Liferay code as an example.The issues happens typically when using PortletURLFactoryUtil because the PortletURLImpl.java code checks the portlet(ID) version and decides that _portletSpecMajorVersion == 3. So it sets up the PortletURLImpl as a 3.0 version. BUT the request that gets passed around is _portletSpecMajorVersion < 3 (because the request is from on of the Liferay portlets) so this throws an exception down the line.
Mirko Romstadt, modified 3 Years ago.

RE: Exception - Liferay Portlet3 Requires 3.0 opt-in

New Member Posts: 17 Join Date: 7/23/14 Recent Posts
How did you fix the problem? Not using "javax.portlet.version=3.0" at all?