留言板

UI error: absolute uri: http://java.sun.com/portlet_2_0 cannot be resolved

Olga S,修改在6 年前。

UI error: absolute uri: http://java.sun.com/portlet_2_0 cannot be resolved

Junior Member 帖子: 26 加入日期: 17-4-17 最近的帖子
Hi everyone!
I am facing the following issue:
I have created the Liferay module and deployed it in osgi/module with the following changes.
My view.jsp:
<%@ include file="/init.jsp" %>

<%
    long g = Long.valueOf((Long) renderRequest.getAttribute("g"));
%>
<p>
	<b></b></p><p><b>Hello ${g}!</b></p>
<p></p>


My portlet class:
package com.businesswire.org.portlet;

import com.liferay.portal.kernel.portlet.bridges.mvc.MVCPortlet;

import java.io.IOException;
import javax.portlet.Portlet;
import javax.portlet.ActionRequest;
import javax.portlet.ActionResponse;
import javax.portlet.PortletException;

import org.osgi.service.component.annotations.Component;

@Component(
	immediate = true,
	property = {
		"com.liferay.portlet.display-category=category.sample",
		"com.liferay.portlet.instanceable=true",
		"javax.portlet.display-name=greetMe-portlet Portlet",
		"javax.portlet.init-param.template-path=/",
		"javax.portlet.init-param.view-template=/view.jsp",
		"javax.portlet.resource-bundle=content.Language",
		"javax.portlet.security-role-ref=power-user,user"
	},
	service = Portlet.class
)
public class MyPortlet extends MVCPortlet {
	
	public void greetMe(ActionRequest actionRequest,
			ActionResponse actionResponse) throws IOException, PortletException {
		String g = "greeting";
		
		actionResponse.setRenderParameter("g",g);
	}
	
	
}

And my pox.xml is:
<!--?xml version="1.0" encoding="UTF-8"?-->

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemalocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelversion>4.0.0</modelversion>
	<artifactid>greetMe-portlet</artifactid>
	<packaging>jar</packaging>
	<dependencies>
		<dependency>
		    <groupid>javax.portlet</groupid>
		    <artifactid>portlet-api</artifactid>
		    <version>2.0</version>
		</dependency>
		<dependency>
		    <groupid>org.osgi</groupid>
		    <artifactid>org.osgi.service.component.annotations</artifactid>
		    <version>1.3.0</version>
		</dependency>
		<dependency>
		    <groupid>com.liferay.portal</groupid>
		    <artifactid>com.liferay.portal.kernel</artifactid>
		    <version>2.40.0</version>
		</dependency>
		<dependency>
		    <groupid>javax.servlet</groupid>
		    <artifactid>jstl</artifactid>
		    <version>1.2</version>
		</dependency>
	</dependencies>
</project>

Those changes are minimal but then I try to add this module on hte page I am getting the error:
Unable to dispatch request: /view.jsp(1,1) /init.jsp(3,66) PWC6188: The absolute uri: http://java.sun.com/portlet_2_0 cannot be resolved in either web.xml or the jar files deployed with this application
22:40:55,508 ERROR [http-nio-8080-exec-1][PortletServlet:112] javax.portlet.PortletException: org.apache.jasper.JasperException: /view.jsp(1,1) /init.jsp(3,66) PWC6188: The absolute uri: http://java.sun.com/portlet_2_0 cannot be resolved in either web.xml or the jar files deployed with this application
javax.portlet.PortletException: org.apache.jasper.JasperException: /view.jsp(1,1) /init.jsp(3,66) PWC6188: The absolute uri: http://java.sun.com/portlet_2_0 cannot be resolved in either web.xml or the jar files deployed with this application

Is anyone had the same error? How did you fix it?
thumbnail
David H Nebinger,修改在6 年前。

RE: UI error: absolute uri: http://java.sun.com/portlet_2_0 cannot be resol

Liferay Legend 帖子: 14919 加入日期: 06-9-2 最近的帖子
Olga S:
Is anyone had the same error? How did you fix it?


Change the portlet spec jar to provided scope. As is, you're including it in your module and are suffering from a class loader clash.









Come meet me at Devcon 2017 or 2017 LSNA!
Olga S,修改在6 年前。

RE: UI error: absolute uri: http://java.sun.com/portlet_2_0 cannot be resol

Junior Member 帖子: 26 加入日期: 17-4-17 最近的帖子
Hello David!
Thank you for your help!
In my pom.xml I have changed:
<dependency>
		    <groupid>javax.portlet</groupid>
		    <artifactid>portlet-api</artifactid>
		    <version>2.0</version>
		</dependency>

to
<dependency>
		    <groupid>javax.portlet</groupid>
		    <artifactid>portlet-api</artifactid>
		    <version>2.0</version>
		    <scope>provided</scope>
		</dependency>

but the error is still there.
thumbnail
David H Nebinger,修改在6 年前。

RE: UI error: absolute uri: http://java.sun.com/portlet_2_0 cannot be resol (答复)

Liferay Legend 帖子: 14919 加入日期: 06-9-2 最近的帖子
Well, the portlet jars in the blade examples, https://github.com/liferay/liferay-blade-samples/tree/master/maven/apps/jsp-portlet, uses the portlet tag library w/o this kind of error.

Have you compared to see what might be different between the blade sample and your own?









Come meet me at Devcon 2017 or 2017 LSNA!
Olga S,修改在6 年前。

RE: UI error: absolute uri: http://java.sun.com/portlet_2_0 cannot be resol

Junior Member 帖子: 26 加入日期: 17-4-17 最近的帖子
Awesome!
My automatically generated bnd.bnd file was missing the following:
-jsp: *.jsp,*.jspf
-plugin.bundle: com.liferay.ant.bnd.resource.bundle.ResourceBundleLoaderAnalyzerPlugin
-plugin.jsp: com.liferay.ant.bnd.jsp.JspAnalyzerPlugin
-plugin.sass: com.liferay.ant.bnd.sass.SassAnalyzerPlugin
-sass: *
-sources: true

After I added those, it worked!
Since it was automatically generated I though it should be fine so I didn't check its content.