1 Reply Latest reply on Jul 13, 2010 8:42 PM by Willem Jiang

    Class loading issues

    Stefan Lolowaty Newbie

      I am building an application for TOTEM experiment, which will populate its database with data coming from variety of sources. I am using Fuse ESB 4 as the container and Fuse Mediation Router for implementing Enterprise Integration Patterns.

       

      Currently I am coding a poller, which will ask for new data coming from the LHC Logging API. I created a piece of code, which runs smoothly being launched standalone (just normal Java invocation from command-line), but I tripped over a problem while deploying it into my OSGi container. I have tried many workarounds, but none of them works. While initializing the bundle I constantly get an

      error saying:

       

      12:29:07,071 | DEBUG | xtenderThread-53 | LHCApiPollerImpl                 | op.lhcApiPoller.LHCApiPollerImpl  118 | TOTEM DBPop :: LHC API Poller > Initializing ...

       

      12:29:07,084 | DEBUG | xtenderThread-53 | LHCApiPollerImpl                 | op.lhcApiPoller.LHCApiPollerImpl  378 | Initializing controller for ch.cern.totem.dbpop.lhcApiPoller.LHCApiPollerImpl with __CLIENT_NAME = TOTEM, __APPLICATION_NAME = DBPOP

       

      12:29:07,084 | DEBUG | xtenderThread-53 | LHCApiPollerImpl                 | op.lhcApiPoller.LHCApiPollerImpl  381 | Initializing VariableController

       

      12:29:07,131 | INFO  | xtenderThread-31 | BusApplicationContext            | pport.AbstractApplicationContext  426 | Bean factory for application context : org.springframework.beans.factory.support.DefaultListableBeanFactory@39aff012

       

      12:29:07,207 | DEBUG | xtenderThread-53 | LHCApiPollerImpl                 | op.lhcApiPoller.LHCApiPollerImpl  385 | Initializing FillDataController

       

      12:29:07,209 | DEBUG | xtenderThread-53 | LHCApiPollerImpl                 | op.lhcApiPoller.LHCApiPollerImpl  389 | Initializing HierarchyController

       

      12:29:07,212 | DEBUG | xtenderThread-53 | LHCApiPollerImpl                 | op.lhcApiPoller.LHCApiPollerImpl  393 | Initializing TimeSeriesDataController

       

      12:29:07,267 | INFO  | xtenderThread-53 | DefaultListableBeanFactory       | ort.DefaultSingletonBeanRegistry  421 | Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@71cdecf7: defining beans ; root of factory hierarchy

       

      12:29:07,275 | ERROR | xtenderThread-53 | ContextLoaderListener            | BundleApplicationContextListener   50 | Application context refresh failed (OsgiBundleXmlApplicationContext(bundle=ch.cern.totem.dbpop.lhcApiPoller, config=osgibundle:/META-INF/spring/*.xml))

       

      org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'lhcApiPoller' defined in URL bundleentry://193.fwk1868864324/META-INF/spring/bundle-context.xml: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: org/apache/log4j/Layout

       

              at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1338)

       

              at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:473)

       

              at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)

       

              at java.security.AccessController.doPrivileged(Native Method)

       

              at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)

       

              at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)

       

              at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)

       

              at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)

       

              at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)

       

              at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)

       

              at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:429)

       

              at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:728)

       

              at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.access$1600(AbstractDelegatedExecutionApplicationContext.java:69)

       

              at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext$4.run(AbstractDelegatedExecutionApplicationContext.java:355)

       

              at org.springframework.osgi.util.internal.PrivilegedUtils.executeWithCustomTCCL(PrivilegedUtils.java:85)

       

              at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.completeRefresh(AbstractDelegatedExecutionApplicationContext.java:320)

       

              at org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor$CompleteRefreshTask.run(DependencyWaiterApplicationContextExecutor.java:136)

       

              at java.lang.Thread.run(Thread.java:619)

       

      Caused by: java.lang.NoClassDefFoundError: org/apache/log4j/Layout

       

              at cern.accdm.timeseries.access.client.TimeseriesDataController.(TimeseriesDataController.java:69)

       

              at ch.cern.totem.dbpop.lhcApiPoller.LHCApiPollerImpl.initializeControllers(LHCApiPollerImpl.java:395)

       

              at ch.cern.totem.dbpop.lhcApiPoller.LHCApiPollerImpl.afterPropertiesSet(LHCApiPollerImpl.java:119)

       

              at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1369)

       

              at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1335)

       

              ... 17 more

       

      Caused by: java.lang.ClassNotFoundException: org.apache.log4j.Layout

       

              at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:448)

       

              at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:410)

       

              at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:398)

       

              at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:105)

       

              at java.lang.ClassLoader.loadClass(ClassLoader.java:248)

       

              ... 22 more

       

       

      It seems like a problem with class-loading. What I have done is I created bundles from all of the Jar's that LHC Logging API is dependent on and deployed them smoothly into OSGi container (this API relies on jars like Spring, Log4j, but also on some packages developed inside CERN, like JMXLogger) Then, when they all were in place, I deploy my bundle and it gets this error... I am struggling with this problem for some time. If you have any suggestions, please don't hesitate to reveal any clues.

       

      Can I find any article which describes in detail the class-loading in Fuse ESB 4?

       

      Edited by: pimek123 on Jul 13, 2010 9:55 AM