Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Thomas C
[RESOLVED] Develop portlet using RSSUtil and rome.jar classes
September 7, 2012 8:58 AM
Answer

Thomas C

Rank: New Member

Posts: 11

Join Date: January 25, 2012

Recent Posts

Hi,

I try to developp a portlet using RSSUtil and rome.jar classes on Liferay 6.1.0.

1
2SyndFeed feed = null;
3final String className= "com.liferay.portlet.rss.util.RSSUtil";
4MethodKey mKey = new MethodKey(className, "getFeed", String.class);
5ObjectValuePair ovp = (ObjectValuePair)PortalClassInvoker.invoke(true, mKey , url);
6feed = (SyndFeed)ovp.getValue();

The RSSUtil class is located in portal-impl. So I use PortalClassInvoker to use it.
When I use my code, I get the exception :

1
2Caused by: java.lang.NoClassDefFoundError: Could not initialize class com.sun.syndication.feed.synd.SyndFeedImpl
3    at com.sun.syndication.io.SyndFeedInput.build(SyndFeedInput.java:123)
4    at com.liferay.portlet.rss.util.RSSWebCacheItem.convert(RSSWebCacheItem.java:83)
5    at com.liferay.portal.webcache.WebCachePoolImpl.get(WebCachePoolImpl.java:44)
6    at com.liferay.portal.kernel.webcache.WebCachePoolUtil.get(WebCachePoolUtil.java:27)
7    at com.liferay.portlet.rss.util.RSSUtil.getFeed(RSSUtil.java:34)


I think to a classLoader problem?
Any helps?

Regards
Thomas
Vilmos Papp
RE: Develop portlet using RSSUtil and rome.jar classes
August 23, 2012 5:19 AM
Answer

Vilmos Papp

LIFERAY STAFF

Rank: Liferay Master

Posts: 522

Join Date: October 21, 2010

Recent Posts

Hi,

It seems to be related to classloading. My first guess it to add rome.jar to the portal-depenecy-jars section of your liferay-plugin-package.properties file.

If it doesn't help you can check Activities portelt's RSSAction class to see how could you implement it by your own. Please note, that there are two RSSUtil classes one in util-java which has the export(SyndFeed) method.

Regards,
Vilmos
Thomas C
RE: Develop portlet using RSSUtil and rome.jar classes
August 23, 2012 6:04 AM
Answer

Thomas C

Rank: New Member

Posts: 11

Join Date: January 25, 2012

Recent Posts

Hi,

I was thinking that too. Unfortunately adding rome.jar in portal-depenecy-jars section of liferay-plugin-package.properties file does'nt work.

This post :
http://osgi.dzone.com/articles/osgi-jumping-through
shows that it's related to classLoader...
Thomas C
RE: Develop portlet using RSSUtil and rome.jar classes
August 23, 2012 6:22 AM
Answer

Thomas C

Rank: New Member

Posts: 11

Join Date: January 25, 2012

Recent Posts

In adding rome.jar in portal-depenecy-jars section of liferay-plugin-package.properties,
I have this exception now :
1
2java.lang.ClassCastException: com.sun.syndication.feed.synd.SyndFeedImpl cannot be cast to com.sun.syndication.feed.synd.SyndFeed
Vilmos Papp
RE: Develop portlet using RSSUtil and rome.jar classes
August 27, 2012 12:28 AM
Answer

Vilmos Papp

LIFERAY STAFF

Rank: Liferay Master

Posts: 522

Join Date: October 21, 2010

Recent Posts

Hi,

That's wierd. I haven't tried to add RSS to plugins before, just built in portlets. If I have some time I'll check it what could be the problem, but it would be great if you could attach a sample code from plugins SDK what generates that error for you.

Regards,
Vilmos
Harish Kumar
RE: Develop portlet using RSSUtil and rome.jar classes
August 27, 2012 12:55 AM
Answer

Harish Kumar

Rank: Expert

Posts: 474

Join Date: July 31, 2010

Recent Posts

Thomas C:
In adding rome.jar in portal-depenecy-jars section of liferay-plugin-package.properties,
I have this exception now :
1
2java.lang.ClassCastException: com.sun.syndication.feed.synd.SyndFeedImpl cannot be cast to com.sun.syndication.feed.synd.SyndFeed


Place the jar in \lib\ext and then try.

Regards,
Thomas C
RE: Develop portlet using RSSUtil and rome.jar classes
September 4, 2012 5:31 AM
Answer

Thomas C

Rank: New Member

Posts: 11

Join Date: January 25, 2012

Recent Posts

Hi,

This is my code in a portlet file :
 1
 2SyndFeedImpl feed = null;
 3final String _CLASS_NAME = "com.liferay.portlet.rss.util.RSSUtil";
 4MethodKey _CONSTRUCTOR = new MethodKey(_CLASS_NAME, "getFeed", String.class);
 5try {
 6
 7    ObjectValuePair ovp = (ObjectValuePair)PortalClassInvoker.invoke(true, _CONSTRUCTOR, url);
 8    PortalClassLoaderUtil.getClassLoader().loadClass("com.sun.syndication.feed.synd.SyndFeedImpl");
 9    feed = (SyndFeedImpl)ovp.getValue();
10    if (Validator.isNull(title)) {
11        title = feed.getTitle();
12    }
13}
14catch (Exception e) {
15}


As explain above, the RSSUtil class is located in portal-impl. So I use PortalClassInvoker to use it.
Moreover I added rome.jar to the portal-depenecy-jars section of my liferay-plugin-package.properties file.

And I got that error :

1
2java.lang.ClassCastException: com.sun.syndication.feed.synd.SyndFeedImpl cannot be cast to com.sun.syndication.feed.synd.SyndFeedImpl
3    at org.apache.jsp.WEB_002dINF.jsp.flux_002drss.view_jsp._jspService(view_jsp.java:422)
4    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
5    at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)


I think for a classloader problem :
1SyndFeedImpl feed = null;
is loaded in the portlet classloader
and
1ovp.getValue();
is invoked with the portal classloader...

Thanks for your help
Thomas C
RE: Develop portlet using RSSUtil and rome.jar classes
September 7, 2012 8:57 AM
Answer

Thomas C

Rank: New Member

Posts: 11

Join Date: January 25, 2012

Recent Posts

It was a ClassLoader problem.
In one hand, the portlet uses classes from "rome.jar" to show RSS streams.
In the other hand, the jar is loaded by the portal...

I resolve the problem by deleting the jar from the portal AND portlet libraries.
Then adding it to the extern tomcat libraries...

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