Uploaded image for project: 'Felix'
  1. Felix
  2. FELIX-6067

ClassLoading and getService can fail unpredictably due to interrupts

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: framework-6.0.2
    • Fix Version/s: framework-6.0.3
    • Component/s: Framework
    • Labels:
      None

      Description

      I noticed an intermittent issue with our Felix-based app (Apache Sling). The flows seems to be the following:

      (thread 1)

      • component C is started
      • component C invokes method on class K1
      • class K1 is first accessed now and runs class initializers
      • K1 static initializer calls method from class K2
      • class K2 loading is triggered

      (thread 2)

      • component C is stopped ( I think due to configuration coming in )

      (thread 1)

      • during class loading of K2 a RuntimeException is thrown, resulting in all calls to K1 leading to NoClassDefFoundError

      At this point although the error should be transient the component is unusable since one of the classes it uses is not available.

      For the record, the stack trace which causes this is

      21.02.2019 14:50:50.292 *ERROR* [Apache Sling Repository Startup Thread #1] org.apache.sling.jcr.oak.server.internal.OakSlingRepositoryManager start: Uncaught Throwable trying to access Repository, calling stopRepository()
      java.lang.ExceptionInInitializerError: null
              at org.apache.sling.jcr.oak.server.internal.OakSlingRepositoryManager.acquireRepository(OakSlingRepositoryManager.java:144) [org.apache.sling.jcr.oak.server:1.2.0]
              at org.apache.sling.jcr.base.AbstractSlingRepositoryManager.initializeAndRegisterRepositoryService(AbstractSlingRepositoryManager.java:481) [org.apache.sling.jcr.base:3.0.6]
              at org.apache.sling.jcr.base.AbstractSlingRepositoryManager.access$300(AbstractSlingRepositoryManager.java:86) [org.apache.sling.jcr.base:3.0.6]
              at org.apache.sling.jcr.base.AbstractSlingRepositoryManager$4.run(AbstractSlingRepositoryManager.java:462) [org.apache.sling.jcr.base:3.0.6]
      Caused by: java.lang.RuntimeException: java.lang.InterruptedException
              at org.apache.felix.framework.ServiceRegistry.getService(ServiceRegistry.java:369)
              at org.apache.felix.framework.Felix.getService(Felix.java:3954)
              at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.transformClass(BundleWiringImpl.java:2383)
              at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.findClass(BundleWiringImpl.java:2081)
              at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1565)
              at org.apache.felix.framework.BundleWiringImpl.access$300(BundleWiringImpl.java:79)
              at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:1982)
              at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
              at org.apache.jackrabbit.oak.plugins.tree.factories.RootFactory.createSystemRoot(RootFactory.java:80) [org.apache.jackrabbit.oak-core:1.8.8]
              at org.apache.jackrabbit.oak.InitialContent.initialize(InitialContent.java:134) [org.apache.jackrabbit.oak-core:1.8.8]
              at org.apache.jackrabbit.oak.InitialContent.createInitialContent(InitialContent.java:74) [org.apache.jackrabbit.oak-core:1.8.8]
              at org.apache.jackrabbit.oak.InitialContent.<clinit>(InitialContent.java:70) [org.apache.jackrabbit.oak-core:1.8.8]
              ... 4 common frames omitted
      Caused by: java.lang.InterruptedException: null
              at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireSharedInterruptibly(AbstractQueuedSynchronizer.java:1302)
              at java.util.concurrent.CountDownLatch.await(CountDownLatch.java:231)
              at org.apache.felix.framework.ServiceRegistry.getService(ServiceRegistry.java:365)
              ... 15 common frames omitted
      

      (source code for all classes is available if needed)

      Starting the component C at any later time fails with

      21.02.2019 14:50:50.310 *ERROR* [Apache Sling Repository Startup Thread #2] org.apache.sling.jcr.oak.server.internal.OakSlingRepositoryManager start: Uncaught Throwable trying to access Repository, calling stopRepository()
      java.lang.NoClassDefFoundError: Could not initialize class org.apache.jackrabbit.oak.InitialContent
              at org.apache.sling.jcr.oak.server.internal.OakSlingRepositoryManager.acquireRepository(OakSlingRepositoryManager.java:144) [org.apache.sling.jcr.oak.server:1.2.0]
              at org.apache.sling.jcr.base.AbstractSlingRepositoryManager.initializeAndRegisterRepositoryService(AbstractSlingRepositoryManager.java:481) [org.apache.sling.jcr.base:3.0.6]
              at org.apache.sling.jcr.base.AbstractSlingRepositoryManager.access$300(AbstractSlingRepositoryManager.java:86) [org.apache.sling.jcr.base:3.0.6]
              at org.apache.sling.jcr.base.AbstractSlingRepositoryManager$4.run(AbstractSlingRepositoryManager.java:462) [org.apache.sling.jcr.base:3.0.6]
      

        Attachments

          Activity

            People

            • Assignee:
              karlpauls Karl Pauls
              Reporter:
              rombert Robert Munteanu
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: