Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Pernes Panta
Display content with JournalContentUtil in JSF with Liferay 7?
November 20, 2017 5:59 AM
Answer

Pernes Panta

Rank: New Member

Posts: 6

Join Date: November 7, 2017

Recent Posts

Please how can i display my content in Liferay 7?
In Liferay 6 I proceeded like this:
 1
 2@ApplicationScoped
 3@ManagedBean
 4public class ContentUtil {
 5...
 6 public static String readArticleByTitleOld(final String articleTitle) {
 7     .....
 8   journalArticle = JournalArticleLocalServiceUtil .getArticleByUrlTitle(groupId, articleTitle);
 9
10  return JournalContentUtil.getContent(themeDisplay.getScopeGroupId(),
11    journalArticle.getArticleId(), null, locale.toString(),  themeDisplay);
12  } catch (){}
13  return "Article '" + articleTitle + "' not found.";
14 }


JSF
1
2<h:outputText
3  value="#{contentUtil.readArticleByTitle(myBean.getArticleId())}"
4  escape="false" />

But the
JournalContentUtil class
was be removed in Liferay 7 and i don't find the equivalent class the new Liferay 7.
please someone can help?
Kyle Joseph Stiemann
RE: Display content with JournalContentUtil in JSF with Liferay 7?
November 20, 2017 6:20 AM
Answer

Kyle Joseph Stiemann

LIFERAY STAFF

Rank: Liferay Master

Posts: 583

Join Date: January 14, 2013

Recent Posts

Hi Pernes,
Can you call JournalArticle.getContentByLocale() instead?

Otherwise take a look at one of the JournalArticleLocalServiceUtil.getArticleContent() methods.

- Kyle
Pernes Panta
RE: Display content with JournalContentUtil in JSF with Liferay 7?
November 21, 2017 2:36 AM
Answer

Pernes Panta

Rank: New Member

Posts: 6

Join Date: November 7, 2017

Recent Posts

Hi Kyle
Thanks for the response
I have this error when i try to get JournalArticle from JournalArticleServiceUtil:
Code:
1
2 final JournalArticle article = JournalArticleLocalServiceUtil.getArticleByUrlTitle(groupId,  articleTitle);


Error:
 1
 2Caused by: java.lang.NoClassDefFoundError: com/liferay/portal/kernel/service/PersistedResourcedModelLocalService
 3    at java.lang.ClassLoader.defineClass1(Native Method)
 4    at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
 5    at org.eclipse.osgi.internal.loader.ModuleClassLoader.defineClass(ModuleClassLoader.java:272)
 6    at org.eclipse.osgi.internal.loader.classpath.ClasspathManager.defineClass(ClasspathManager.java:632)
 7    at org.eclipse.osgi.internal.loader.classpath.ClasspathManager.findClassImpl(ClasspathManager.java:588)
 8    at org.eclipse.osgi.internal.loader.classpath.ClasspathManager.findLocalClassImpl(ClasspathManager.java:540)
 9    at org.eclipse.osgi.internal.loader.classpath.ClasspathManager.findLocalClass(ClasspathManager.java:527)
10    at org.eclipse.osgi.internal.loader.ModuleClassLoader.findLocalClass(ModuleClassLoader.java:324)
11    at org.eclipse.osgi.internal.loader.BundleLoader.findLocalClass(BundleLoader.java:330)
12    at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:407)
13    at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:357)
14    at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:349)
15    at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:160)
16    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
17    at com.liferay.journal.service.JournalArticleLocalServiceUtil.<clinit>(JournalArticleLocalServiceUtil.java:4047)
18    at mytudo.view.util.ContentUtil.readArticleByTitle(ContentUtil.java:71)
19    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
20    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
21    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
22    at java.lang.reflect.Method.invoke(Method.java:498)
23    at javax.el.ELUtil.invokeMethod(ELUtil.java:332)
24    ... 234 more


Permes
Kyle Joseph Stiemann
RE: Display content with JournalContentUtil in JSF with Liferay 7?
November 21, 2017 6:00 AM
Answer

Kyle Joseph Stiemann

LIFERAY STAFF

Rank: Liferay Master

Posts: 583

Join Date: January 14, 2013

Recent Posts

Hi Pernes,
Can you paste your pom.xml's or build.gradle's (or ivy.xml's) dependencies section? It seems like you might have some Liferay 6.2 dependencies in your war.

- Kyle
Pernes Panta
RE: Display content with JournalContentUtil in JSF with Liferay 7?
November 21, 2017 7:24 AM
Answer

Pernes Panta

Rank: New Member

Posts: 6

Join Date: November 7, 2017

Recent Posts

Hi Kyle,
thanks for the idear.
I work with many projects (4) projects with many pom.xml files .
I would firstly checked all project librarie dependencies .
If i don't find any Liferay 6.2 dependencies inside, i will post all project dependencies here.

Thanks

Pernes
Kyle Joseph Stiemann
RE: Display content with JournalContentUtil in JSF with Liferay 7?
November 21, 2017 12:53 PM
Answer

Kyle Joseph Stiemann

LIFERAY STAFF

Rank: Liferay Master

Posts: 583

Join Date: January 14, 2013

Recent Posts

Sounds good Pernes. Let us know what you find out. You may also want to take a look at our Resolving ClassNotFoundException and NoClassDefFoundError in OSGi Bundles documentation.

- Kyle
Pernes Panta
RE: Display content with JournalContentUtil in JSF with Liferay 7?
November 27, 2017 4:10 AM
Answer

Pernes Panta

Rank: New Member

Posts: 6

Join Date: November 7, 2017

Recent Posts

Hi Kyle,
I don't found any Liferay 6 dependency im my pom.xml.
I attached my dependencies file to the post.

How can i use bnd.bnd file with JSF Portlet in liferay 7?

Best regards
Attachments: my_dependencies.xml (4.6k)
Kyle Joseph Stiemann
RE: Display content with JournalContentUtil in JSF with Liferay 7?
November 27, 2017 9:41 AM
Answer

Kyle Joseph Stiemann

LIFERAY STAFF

Rank: Liferay Master

Posts: 583

Join Date: January 14, 2013

Recent Posts

Hi Pernes,
You need to change the Journal API dependency to <scope>provided</scope> so it is not included in your portlet's WEB-INF/lib since Liferay provides it:

<dependency>
<groupId>com.liferay</groupId>
<artifactId>com.liferay.journal.api</artifactId>
<version>2.11.0</version>
<scope>provided</scope>
</dependency>


You should also upgrade to JSF 2.2 since that is the only supported version of JSF in Liferay 7.0. liferayfaces.org can show you the recommended dependencies for Liferay 7.0.

- Kyle
Pernes Panta
RE: Display content with JournalContentUtil in JSF with Liferay 7?
December 6, 2017 12:54 AM
Answer

Pernes Panta

Rank: New Member

Posts: 6

Join Date: November 7, 2017

Recent Posts

hi Kyle,
Thousand thanks for your help.
Now all work perfectly.
Thank you very much
I love liferay 7
Pernes
Kyle Joseph Stiemann
RE: Display content with JournalContentUtil in JSF with Liferay 7?
December 6, 2017 6:10 AM
Answer

Kyle Joseph Stiemann

LIFERAY STAFF

Rank: Liferay Master

Posts: 583

Join Date: January 14, 2013

Recent Posts

Glad to hear it! Thanks for using Liferay Faces!

- Kyle

Participate in the State of Liferay Community 2017. Help the community and even win some prizes!