2015-01-12 9 views
0

내가 던진 예외는 ... 사용 RSSUtil는 RSS 피드를 읽어하지만 난 클래스 로더에 문제에 직면하고있어을 Liferay RSSUtil + rome.jar

싶습니다 :

com.sun.syndication.feed.synd.SyndFeedImpl cannot be cast to com.sun.syndication.feed.synd.SyndFeedImpl 

내 코드 :

 SyndFeedImpl feed = null; 
     final String _CLASS_NAME = "com.liferay.portlet.rss.util.RSSUtil"; 
     MethodKey _CONSTRUCTOR = new MethodKey(_CLASS_NAME, "getFeed", String.class); 

     ObjectValuePair ovp = (ObjectValuePair) PortalClassInvoker.invoke(true, _CONSTRUCTOR, url); 
     Class<SyndFeed> clazz = (Class<SyndFeed>) PortalClassLoaderUtil.getClassLoader().loadClass(
       "com.sun.syndication.feed.synd.SyndFeedImpl"); 

     feed = (SyndFeedImpl) ovp.getValue(); 

문제는 https://www.liferay.com/fr/community/forums/-/message_boards/message/15812507에도 설명되어 있습니다. 저도 같은 일을하려고하지만 ... 당신의 도움에 미리

감사합니다 ...

UPDATE를 작동하지 않습니다

: 나는 아래의 코드 (RSSUtil없이 다른 솔루션)를 사용하는 경우
 URL feedUrl = new URL(url); 
     HttpURLConnection httpcon = (HttpURLConnection) feedUrl.openConnection(); 

     SyndFeedInput input = new SyndFeedInput(); 
     XmlReader reader = new XmlReader(httpcon); 
     SyndFeed feed = input.build(reader); 

던져 예외입니다 :

java.lang.ClassCastException: com.sun.syndication.feed.synd.impl.ConverterForAtom10 cannot be cast to com.sun.syndication.feed.synd.Converter 

답변

0

내가 같은 문제에 직면했습니다. 나는 tomcatxxx이

당신이 얻을 첫 번째 오류는/내선 lib 디렉토리/인/liferayroot하는 liferayroot/tomcatxxx/웹 어플리케이션/ROOT/WEB-INF/lib 디렉토리에서 두 개의 항아리 (dom4j.jar 및 rome.jar)를 복사 결국했습니다 클래스가 다른 클래스 로더 (포털 클래스 로더 및 포틀릿 클래스 로더)에 의해로드되기 때문입니다.

항아리 복사 시도