Forums de discussion

WAB JSF Portlet - How to acess Liferay APIs?

thumbnail
Gustavo Oliveira, modifié il y a 7 années.

WAB JSF Portlet - How to acess Liferay APIs?

Junior Member Publications: 98 Date d'inscription: 23/09/15 Publications récentes
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
Juan Gonzalez, modifié il y a 7 années.

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

Liferay Legend Publications: 3089 Date d'inscription: 28/10/08 Publications récentes
thumbnail
Gustavo Oliveira, modifié il y a 7 années.

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

Junior Member Publications: 98 Date d'inscription: 23/09/15 Publications récentes
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
Juan Gonzalez, modifié il y a 7 années.

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

Liferay Legend Publications: 3089 Date d'inscription: 28/10/08 Publications récentes
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
Gustavo Oliveira, modifié il y a 7 années.

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

Junior Member Publications: 98 Date d'inscription: 23/09/15 Publications récentes
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
Juan Gonzalez, modifié il y a 7 années.

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

Liferay Legend Publications: 3089 Date d'inscription: 28/10/08 Publications récentes
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
Gustavo Oliveira, modifié il y a 7 années.

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

Junior Member Publications: 98 Date d'inscription: 23/09/15 Publications récentes
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
Juan Gonzalez, modifié il y a 7 années.

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

Liferay Legend Publications: 3089 Date d'inscription: 28/10/08 Publications récentes
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 ;-).