掲示板

WAB JSF Portlet - How to acess Liferay APIs?

thumbnail
7年前 に Gustavo Oliveira によって更新されました。

WAB JSF Portlet - How to acess Liferay APIs?

Junior Member 投稿: 98 参加年月日: 15/09/23 最新の投稿
Im trying to use JournalArticleLocalServiceUtil to migrate data.

pom.xml

		<dependency>
		    <groupid>com.liferay</groupid>
		    <artifactid>com.liferay.journal.api</artifactid>
		    <version>2.2.1</version>
		    <scope>provided</scope>
		</dependency>
		<dependency>
		    <groupid>com.liferay.portal</groupid>
		    <artifactid>com.liferay.portal.kernel</artifactid>
		    <version>2.0.0</version>
		    <scope>provided</scope>
		</dependency>


Tried a simple test getting an article by Id:

			JournalArticle article = JournalArticleLocalServiceUtil.getArticle(34002);
			System.out.println("Obj: "+article);


Got this error:
java.lang.ClassCastException: com.sun.proxy.$Proxy464 cannot be cast to com.liferay.journal.service.JournalArticleLocalService

How are you guys doing on JSF Portlets to access Liferay API Utils?

Thanks
thumbnail
7年前 に Juan Gonzalez によって更新されました。

RE: WAB JSF Portlet - How to acess Liferay APIs?

Liferay Legend 投稿: 3089 参加年月日: 08/10/28 最新の投稿
thumbnail
7年前 に Gustavo Oliveira によって更新されました。

RE: WAB JSF Portlet - How to acess Liferay APIs?

Junior Member 投稿: 98 参加年月日: 15/09/23 最新の投稿
Thanks for the fast reply.

Im using the one that came with developer studio and I patched it.

liferay-dxp-digital-enterprise-7.0-ga1

I probably need to add more dependencies, added this one (com.liferay.faces.portal) and now changed the error :

java.lang.NoClassDefFoundError: Lcom/liferay/portal/model/User

pom.xml

<dependency>
<groupId>com.liferay</groupId>
<artifactId>com.liferay.journal.api</artifactId>
<version>2.2.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.liferay.portal</groupId>
<artifactId>com.liferay.portal.kernel</artifactId>
<version>2.0.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.liferay.faces</groupId>
<artifactId>com.liferay.faces.portal</artifactId>
<version>2.0.0</version>
</dependency>

thumbnail
7年前 に Juan Gonzalez によって更新されました。

RE: WAB JSF Portlet - How to acess Liferay APIs?

Liferay Legend 投稿: 3089 参加年月日: 08/10/28 最新の投稿
Gustavo Oliveira:

java.lang.NoClassDefFoundError: Lcom/liferay/portal/model/User


There had been a major refactor of classes and many of them had been moved to com.liferay.portal.kernel.*, so just try: com.liferay.portal.kernel.model.User;
thumbnail
7年前 に Gustavo Oliveira によって更新されました。

RE: WAB JSF Portlet - How to acess Liferay APIs?

Junior Member 投稿: 98 参加年月日: 15/09/23 最新の投稿
When I run a fix pack on Liferay Portal it will update the kernel? (This is the last one liferay-fix-pack-de-7-7010.zip)

Thats exactly the problem. Im referring to the new api kernel on pom.xml but my Liferay uses the old one.
thumbnail
7年前 に Juan Gonzalez によって更新されました。

RE: WAB JSF Portlet - How to acess Liferay APIs?

Liferay Legend 投稿: 3089 参加年月日: 08/10/28 最新の投稿
Gustavo Oliveira:
When I run a fix pack on Liferay Portal it will update the kernel? (This is the last one liferay-fix-pack-de-7-7010.zip)

Thats exactly the problem. Im referring to the new api kernel on pom.xml but my Liferay uses the old one.


Yes, it's possible to be changing kernel classes, but those should be Liferay DXP backwards compatible.

The change I mentioned in previous post affects Liferay 6.x to Liferay 7 updates.
thumbnail
7年前 に Gustavo Oliveira によって更新されました。

RE: WAB JSF Portlet - How to acess Liferay APIs?

Junior Member 投稿: 98 参加年月日: 15/09/23 最新の投稿
Ive created a new JSF Portlet and copied everything, the only thing that I changed was moving the JournalArticleServiceUtil to an action method instead of invoking it on @PostConstruct method.

It worked emoticon

I will paste my pom.xml for anyone that gets the same problem:


	<dependencies>
		<dependency>
			<groupid>commons-fileupload</groupid>
			<artifactid>commons-fileupload</artifactid>
			<version>1.3.1</version>
			<optional>true</optional>
		</dependency>
		<dependency>
			<groupid>commons-io</groupid>
			<artifactid>commons-io</artifactid>
			<version>2.4</version>
			<optional>true</optional>
		</dependency>
		<dependency>
			<groupid>javax.faces</groupid>
			<artifactid>javax.faces-api</artifactid>
			<version>${faces.api.version}</version>
			<scope>provided</scope>
		</dependency>
		<dependency>
			<groupid>org.glassfish</groupid>
			<artifactid>javax.faces</artifactid>
			<version>${mojarra.version}</version>
			<scope>runtime</scope>
		</dependency>
		<dependency>
			<groupid>com.liferay.faces</groupid>
			<artifactid>com.liferay.faces.bridge.ext</artifactid>
			<version>${liferay.faces.bridge.ext.version}</version>
		</dependency>
		<dependency>
			<groupid>com.liferay.faces</groupid>
			<artifactid>com.liferay.faces.bridge.impl</artifactid>
			<version>${liferay.faces.bridge.version}</version>
		</dependency>
		<dependency>
			<groupid>log4j</groupid>
			<artifactid>log4j</artifactid>
			<version>1.2.14</version>
		</dependency>
		<dependency>
			<groupid>org.primefaces</groupid>
			<artifactid>primefaces</artifactid>
			<version>6.0</version>
		</dependency>
		<dependency>
			<groupid>com.liferay.faces</groupid>
			<artifactid>com.liferay.faces.alloy</artifactid>
			<version>3.0.0</version>
		</dependency>		
		<dependency>
			<groupid>mysql</groupid>
			<artifactid>mysql-connector-java</artifactid>
			<version>5.1.40</version>
		</dependency>
		<dependency>
			<groupid>com.liferay</groupid>
			<artifactid>com.liferay.journal.api</artifactid>
			<version>2.0.1</version>
			<scope>provided</scope>
		</dependency>
		<dependency>
			<groupid>com.liferay.portal</groupid>
			<artifactid>com.liferay.portal.kernel</artifactid>
			<version>2.0.0</version>
			<scope>provided</scope>
		</dependency>		
	</dependencies>
thumbnail
7年前 に Juan Gonzalez によって更新されました。

RE: WAB JSF Portlet - How to acess Liferay APIs?

Liferay Legend 投稿: 3089 参加年月日: 08/10/28 最新の投稿
Gustavo Oliveira:
Ive created a new JSF Portlet and copied everything, the only thing that I changed was moving the JournalArticleServiceUtil to an action method instead of invoking it on @PostConstruct method.

It worked emoticon


Glad you got it working Gustavo.

We are here for any suggestion/issue you encounter in Liferay Faces and Liferay 7.

Thanks for using Liferay Faces ;-).