Announcement Announcement Module
Collapse
No announcement yet.
Exporting Properties Packages - Rome RSS Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Exporting Properties Packages - Rome RSS

    For some reason when using Rome, it can't load its own properties file. I've posted the exception, code and my MANIFEST.MF below. Let me know if you need anything else to help me out.

    Thanks!

    Code:
    	SyndFeedInput input = new SyndFeedInput();
    			InputStream stream = get(feed.getUrl());
    			InputStreamReader reader = new InputStreamReader(stream);
    			SyndFeed syndFeed = input.build(reader);
    			List<SyndEntry> entries = syndFeed.getEntries();
    
    Manifest-Version: 1.0
    Export-Package: com.monkily.rssexplorer.model;version="1.0.0";uses:="javax.persistence",
     com.monkily.rssexplorer.service;version="1.0.0"
    Import-Library: org.hibernate.ejb;version="[3.3.2.GA,3.4.0)",
     org.springframework.spring
    Bundle-Name: Monkily RssExplorer
    Import-Bundle:  com.monkily.user;version="[1.0.0,1.0.0]",
     com.monkily.content;version="[1.0.0,1.0.0]",
     com.springsource.org.jdom;version="[1.0.0,1.0.0]",
     com.springsource.com.sun.syndication;version="[1.0.0,1.0.0]",
     com.springsource.org.apache.commons.httpclient;version="[3.1.0,4.0.0)",
     com.springsource.com.sun.syndication;version="[1.0.0,2.0.0)"
    Bundle-Vendor: Monkily
    Application-TraceLevels: *=info,com.monkily.*=debug
    Bundle-Version: 1.0.0
    Bundle-ManifestVersion: 2
    Import-Package: com.monkily.content.model,
     com.monkily.content.service,
     com.monkily.utils,
     com.mysql.jdbc.jdbc2.optional,
     javax.persistence,
     javax.sql,
     org.apache.commons.logging,
     org.hibernate.ejb,
     org.springframework.beans.factory.annotation,
     org.springframework.beans.factory.config,
     org.springframework.orm.jpa,
     org.springframework.orm.jpa.vendor,
     org.springframework.osgi.context.event,
     org.springframework.stereotype,
     org.springframework.transaction.annotation
    Bundle-SymbolicName: com.monkily.rssexplorer
    
    
    
    java.lang.ExceptionInInitializerError
    	at com.sun.syndication.io.SyndFeedInput.build(SyndFeedInput.java:122)
    	at com.monkily.rssexplorer.internal.service.impl.RssServiceImpl.checkFeed(RssServiceImpl.java:68)
    	at com.monkily.rssexplorer.internal.service.impl.RssServiceImpl.checkAll(RssServiceImpl.java:58)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    	at java.lang.reflect.Method.invoke(Method.java:597)
    	at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)
    	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:198)
    	at $Proxy138.checkAll(Unknown Source)
    	at com.monkily.rssexplorer.internal.scheduler.RssExplorerScheduler.start(RssExplorerScheduler.java:54)
    	at com.monkily.rssexplorer.internal.scheduler.RssExplorerScheduler.onOsgiApplicationEvent(RssExplorerScheduler.java:43)
    	at sun.reflect.GeneratedMethodAccessor10.invoke(Unknown Source)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    	at java.lang.reflect.Method.invoke(Method.java:597)
    	at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)
    	at org.springframework.osgi.service.importer.support.internal.aop.ServiceInvoker.doInvoke(ServiceInvoker.java:58)
    	at org.springframework.osgi.service.importer.support.internal.aop.ServiceInvoker.invoke(ServiceInvoker.java:62)
    	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
    	at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131)
    	at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119)
    	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
    	at org.springframework.osgi.service.util.internal.aop.ServiceTCCLInterceptor.invoke(ServiceTCCLInterceptor.java:36)
    	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
    	at org.springframework.osgi.service.importer.support.LocalBundleContextAdvice.invoke(LocalBundleContextAdvice.java:59)
    	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
    	at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131)
    	at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119)
    	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
    	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
    	at $Proxy3.onOsgiApplicationEvent(Unknown Source)
    	at org.springframework.osgi.extender.internal.activator.ListListenerAdapter.onOsgiApplicationEvent(ListListenerAdapter.java:52)
    	at org.springframework.osgi.context.event.ApplicationListenerAdapter.onApplicationEvent(ApplicationListenerAdapter.java:45)
    	at org.springframework.context.event.SimpleApplicationEventMulticaster$1.run(SimpleApplicationEventMulticaster.java:78)
    	at org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:49)
    	at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:76)
    	at org.springframework.osgi.context.event.OsgiBundleApplicationContextEventMulticasterAdapter.multicastEvent(OsgiBundleApplicationContextEventMulticasterAdapter.java:63)
    	at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.sendRefreshedEvent(AbstractDelegatedExecutionApplicationContext.java:370)
    	at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.completeRefresh(AbstractDelegatedExecutionApplicationContext.java:294)
    	at org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor$CompleteRefreshTask.run(DependencyWaiterApplicationContextExecutor.java:145)
    	at com.springsource.server.kernel.dm.ContextPropagatingTaskExecutor$2.run(ContextPropagatingTaskExecutor.java:82)
    	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    	at java.lang.Thread.run(Thread.java:619)
    Caused by: java.lang.NullPointerException
    	at java.util.Properties$LineReader.readLine(Properties.java:418)
    	at java.util.Properties.load0(Properties.java:337)
    	at java.util.Properties.load(Properties.java:325)
    	at com.sun.syndication.io.impl.PropertiesLoader.<init>(PropertiesLoader.java:74)
    	at com.sun.syndication.io.impl.PropertiesLoader.getPropertiesLoader(PropertiesLoader.java:46)
    	at com.sun.syndication.io.impl.PluginManager.<init>(PluginManager.java:54)
    	at com.sun.syndication.io.impl.PluginManager.<init>(PluginManager.java:46)
    	at com.sun.syndication.feed.synd.impl.Converters.<init>(Converters.java:40)
    	at com.sun.syndication.feed.synd.SyndFeedImpl.<clinit>(SyndFeedImpl.java:56)
    	... 44 more

  • #2
    have you found a workaround?

    Comment


    • #3
      Moving this thread to the dm Server forum...

      Comment


      • #4
        Rome appears to use the thread context class loader when it's looking for its Properties file. Unfortunately it doesn't check for getResourceAsStream returning null, hence the NullPointerException.

        If possible, I'd add some debug immediately before you call into Rome to see what the thread context class loader is. If you post back with that information it should be possible to figure out what the problem is.

        Comment


        • #5
          For what I can understand, the fault comes from Rome com.sun.syndication.io.impl.PropertiesLoader. This class have the responsibility of parsing the properties files specifying implementations of various IO components.

          The code stores the properties, alongside the class loader in which to retrieve the implementation classes. The class loader used is Thread.currentThread().getContextClassLoader().

          Code:
                      
          PropertiesLoader loader = (PropertiesLoader)
                          clMap.get(Thread.currentThread().getContextClassLoader());
          if (loader == null) {
              try {
                  loader = new PropertiesLoader(MASTER_PLUGIN_FILE, EXTRA_PLUGIN_FILE);
                  clMap.put(Thread.currentThread().getContextClassLoader(), loader);
              } catch (IOException ex) {
                  throw new RuntimeException(ex);
              }
          }
          
          return loader;
          Is this the information you were looking for? I don't understand OSGi class loading issues very well.

          Comment


          • #6
            Almost I was hoping to learn what the thread context class loader is before the call into Rome that fails is made. So, for example, for the code that generated the stack trace listed above the debug code would be added prior to calling SyndFeedInput.build:

            Code:
            ClassLoader tccl = Thread.currentThread().getContextClassLoader();
            debug("Calling Rome with tccl " + tccl);
            SyndFeedInput.build();
            An alternative would be to place a breakpoint in Rome and use a debugger to look at the classloader that it's trying to use.

            Comment


            • #7
              I think I partially* figured out what went wrong here. To put you guys in context, I'm using Rome inside a JAX-RS resource class so I can convert RSS -> ATOM and vice-versa. Now, I inspected what was the classloader that caused me all this trouble: Thread.currentThread().getContextClassLoader(). The answer was:

              [Apache ServiceMix CXF Transport for OSGi (org.apache.servicemix.cxf.transport.osgi)]

              ... which obviously isn't what is needed here since rome.properties/plugins impl are in the Rome bundle, and in an OSGi runtime each bundle has its own private class loader. Now, to obtain the correct CL, I think I have to specify:

              <rome_class>.getClass().getClassLoader()

              Resulting in: [211.0]

              ... which is Rome bundle ID in my smx4 runtime. And now it's working, plugins gets loaded correctly.

              When I look into Rome source code, there are about 10 places in which the currentThreadClassLoader is invoked (instead of the bundle CL). I guess the easy solution would be to replace these calls and then see if something breaks in the unit tests. At this point I'm not sure if such a fix has an impact on how Rome is working internally.


              * When I said partially I meant that I don't fully understand why the CXF transport bundle (JAX-RS impl) is my currentThread CL.

              Comment


              • #8
                I blogged about this. The post provides more info:

                http://js.jipiju.com/2009/08/04/osgi...soading-hoops/

                Feel free to comment.

                Comment


                • #9
                  We had same problem with ROME with camel-rss. We created rome bundle in ServiceMix repository which contains fix for this bug.

                  If you're interest please review:
                  https://issues.apache.org/activemq/browse/SMX4-510

                  Comment

                  Working...
                  X