留言板

I can't create a journalArticle (Liferay DXP)

Alejandro Núñez,修改在7 年前。

I can't create a journalArticle (Liferay DXP)

New Member 帖子: 4 加入日期: 16-9-28 最近的帖子
Greetings to all,

I'm working in Liferay DXP (trial version) with Wildfly 10.0.0 using sdk plugins from liferay 7 ga1 and i'm trying to create a journalArticle programatically. I think the issue is that i haven't the corresponding jars of this entity, but i'm not sure.

Before this, I wanted to create a structure programatically with the DDMStructureLocalServiceUtil but didn't work. I was examining the api Liferay 7 too much and I realized that the DDMStructureLocalServiceUtil class was replaced by DDMStructureManagerUtil class, and so does with DDMSTemplateManagerUtil instead of DDMTemplateLocalServiceUtil. Using this new classes it worked fine.

And now i'm trying to create a journalArticle but i don't know how to do that without the JournalArticleLocalServiceUtil class beacuse the jars are missed or removed in this version, i don't know.
I tried to import the JournalArticle jars in Eclipse but it didn't work, because by using the JournalArticleLocalServiceUtil to create a journalArticle like:

JournalArticleLocalServiceUtil.addArticle(userId, groupId, parentFolderId, titleMap,
descriptionMap, content, ddmStructure.getStructureKey(),
ddmTemplate.getTemplateKey(), serviceContext);


i get an error like this:

java.lang.ClassCastException: com.sun.proxy.$Proxy489 cannot be cast to com.liferay.journal.service.JournalArticleLocalService

Also i got the same failure when i used the DDMStructureLocalServiceUtil and DDMTemplateLocalServiceUtil classes, but i managed to fix it replacing them by the new services commented above.

I'd like to know what i'm doing wrong.

Thanks in advance!
thumbnail
David H Nebinger,修改在7 年前。

RE: I can't create a journalArticle (Liferay DXP)

Liferay Legend 帖子: 14918 加入日期: 06-9-2 最近的帖子
A one line exception message is not going to lead to a reasonable response. I can't even tell what point in the code you may be in...

When posting errors, be sure to include the complete stack trace...
chris jasso,修改在7 年前。

RE: I can't create a journalArticle (Liferay DXP)

New Member 帖子: 4 加入日期: 16-10-24 最近的帖子
I'm having the exact same error when trying to get web content inside a portlet
here is the complete stack trace


java.lang.ClassCastException: com.sun.proxy.$Proxy466 cannot be cast to com.liferay.journal.service.JournalArticleService
	at com.liferay.journal.service.JournalArticleServiceUtil.getService(JournalArticleServiceUtil.java:1992)
	at com.liferay.journal.service.JournalArticleServiceUtil.getArticlesByStructureId(JournalArticleServiceUtil.java:694)
	at com.thomsonreuters.biva.NewsSlider.doView(NewsSlider.java:48)
	at com.liferay.portal.kernel.portlet.LiferayPortlet.doDispatch(LiferayPortlet.java:302)
	at com.liferay.portal.kernel.portlet.bridges.mvc.MVCPortlet.doDispatch(MVCPortlet.java:471)
	at javax.portlet.GenericPortlet.render(GenericPortlet.java:262)
	at com.liferay.portal.kernel.portlet.bridges.mvc.MVCPortlet.render(MVCPortlet.java:291)
	at com.liferay.portlet.FilterChainImpl.doFilter(FilterChainImpl.java:103)
	at com.liferay.portlet.ScriptDataPortletFilter.doFilter(ScriptDataPortletFilter.java:57)
	at com.liferay.portlet.FilterChainImpl.doFilter(FilterChainImpl.java:100)
	at com.liferay.portlet.ScriptDataPortletFilter.doFilter(ScriptDataPortletFilter.java:57)
	at com.liferay.portlet.FilterChainImpl.doFilter(FilterChainImpl.java:100)
	at com.liferay.portlet.ScriptDataPortletFilter.doFilter(ScriptDataPortletFilter.java:57)
	at com.liferay.portlet.FilterChainImpl.doFilter(FilterChainImpl.java:100)
	at com.liferay.portlet.ScriptDataPortletFilter.doFilter(ScriptDataPortletFilter.java:57)
	at com.liferay.portlet.FilterChainImpl.doFilter(FilterChainImpl.java:100)
	at com.liferay.portlet.ScriptDataPortletFilter.doFilter(ScriptDataPortletFilter.java:57)
	at com.liferay.portlet.FilterChainImpl.doFilter(FilterChainImpl.java:100)
	at com.liferay.portlet.ScriptDataPortletFilter.doFilter(ScriptDataPortletFilter.java:57)
	at com.liferay.portlet.FilterChainImpl.doFilter(FilterChainImpl.java:100)
thumbnail
Gustavo Oliveira,修改在7 年前。

RE: I can't create a journalArticle (Liferay DXP)

Junior Member 帖子: 98 加入日期: 15-9-23 最近的帖子
Im trying to use JournalArticleLocalServiceUtil on a WAB portlet (Maven).

pom.xml:

		<dependency>
		    <groupid>com.liferay</groupid>
		    <artifactid>com.liferay.journal.api</artifactid>
		    <version>2.0.0</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>
<br><br>Tried somethins simple as:<br><pre><code> JournalArticle article = JournalArticleLocalServiceUtil.getArticle(34002); System.out.println(article); </code></pre><br><br>Got the same error:<br><strong>java.lang.ClassCastException: com.sun.proxy.$Proxy464 cannot be cast to com.liferay.journal.service.JournalArticleLocalService</strong>
chris jasso,修改在7 年前。

RE: I can't create a journalArticle (Liferay DXP)

New Member 帖子: 4 加入日期: 16-10-24 最近的帖子
i found a solution, in this link https://dev.liferay.com/develop/tutorials/-/knowledge_base/7-0/adapting-to-liferay-7s-api-with-the-code-upgrade-tool, the problem was that portal already had JournalArticle api and the jar inside portlet was causing the problem, the solution is excluding the jar in liferay-plugin-package.properties add this at the end:

deploy-excludes=\
**/WEB-INF/lib/com.liferay.journal.api-2.2.1.jar

sorry for bad english
Ashish Bijlwan,修改在7 年前。

RE: I can't create a journalArticle (Liferay DXP)

New Member 帖子: 7 加入日期: 17-1-6 最近的帖子
chris jasso:
i found a solution, in this link https://dev.liferay.com/develop/tutorials/-/knowledge_base/7-0/adapting-to-liferay-7s-api-with-the-code-upgrade-tool, the problem was that portal already had JournalArticle api and the jar inside portlet was causing the problem, the solution is excluding the jar in liferay-plugin-package.properties add this at the end:

deploy-excludes=\
**/WEB-INF/lib/com.liferay.journal.api-2.2.1.jar

sorry for bad english



yes....this is the best solution for this type of problem........
thumbnail
Megesh Damre,修改在6 年前。

RE: I can't create a journalArticle (Liferay DXP)

New Member 帖子: 24 加入日期: 17-4-27 最近的帖子
chris jasso:
i found a solution, in this link https://dev.liferay.com/develop/tutorials/-/knowledge_base/7-0/adapting-to-liferay-7s-api-with-the-code-upgrade-tool, the problem was that portal already had JournalArticle api and the jar inside portlet was causing the problem, the solution is excluding the jar in liferay-plugin-package.properties add this at the end:

deploy-excludes=\
**/WEB-INF/lib/com.liferay.journal.api-2.2.1.jar

sorry for bad english




Thanks chris for share solution
This is way to use liferay.journal.api and achieve the functionality emoticon