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

Erroneous class loading delegation to the application launcher classloader in some cases

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Critical
    • Resolution: Fixed
    • None
    • framework-1.6.0
    • Framework
    • None

    Description

      Here is an example stack trace:

      ProcessStoreImpl-1@50 daemon, priority=5, in group 'main', status: 'RUNNING'
      	  at org.apache.felix.framework.searchpolicy.ModuleImpl.searchDynamicImports(ModuleImpl.java:1,215)
      	  at org.apache.felix.framework.searchpolicy.ModuleImpl.findClassOrResourceByDelegation(ModuleImpl.java:558)
      	  at org.apache.felix.framework.searchpolicy.ModuleImpl.access$100(ModuleImpl.java:59)
      	  at org.apache.felix.framework.searchpolicy.ModuleImpl$ModuleClassLoader.loadClass(ModuleImpl.java:1,382)
      	  at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
      	  at org.apache.felix.framework.searchpolicy.ModuleImpl.getClassByDelegation(ModuleImpl.java:428)
      	  at org.apache.felix.framework.Felix.loadBundleClass(Felix.java:1,341)
      	  at org.apache.felix.framework.BundleImpl.loadClass(BundleImpl.java:737)
      	  at org.springframework.osgi.util.BundleDelegatingClassLoader.findClass(BundleDelegatingClassLoader.java:99)
      	  at org.springframework.osgi.util.BundleDelegatingClassLoader.loadClass(BundleDelegatingClassLoader.java:156)
      	  at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
      	  at org.apache.xbean.classloader.MultiParentClassLoader.loadClass(MultiParentClassLoader.java:184)
      	  at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
      	  at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:374)
      	  at java.lang.ClassLoader.defineClass1(ClassLoader.java:-1)
      	  at java.lang.ClassLoader.defineClass(ClassLoader.java:675)
      	  at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
      	  at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
      	  at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
      	  at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
      	  at java.security.AccessController.doPrivileged(AccessController.java:-1)
      	  at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
      	  at org.apache.xbean.classloader.MultiParentClassLoader.loadClass(MultiParentClassLoader.java:200)
      	  at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
      	  at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:374)
      	  at org.apache.openjpa.util.ProxyMaps.afterEntrySet(ProxyMaps.java:74)
      	  at org.apache.openjpa.util.java$util$HashMap$proxy.entrySet(Unknown Source:-1)
      	  at org.apache.openjpa.util.ProxyMaps.values(ProxyMaps.java:65)
      	  at org.apache.openjpa.util.java$util$HashMap$proxy.values(Unknown Source:-1)
      	  at org.apache.openjpa.kernel.SingleFieldManager.delete(SingleFieldManager.java:335)
      	  at org.apache.openjpa.kernel.SingleFieldManager.delete(SingleFieldManager.java:283)
      	  at org.apache.openjpa.kernel.StateManagerImpl.cascadeDelete(StateManagerImpl.java:2,861)
      	  at org.apache.openjpa.kernel.BrokerImpl.delete(BrokerImpl.java:2,566)
      	  at org.apache.openjpa.kernel.SingleFieldManager.delete(SingleFieldManager.java:387)
      	  at org.apache.openjpa.kernel.SingleFieldManager.delete(SingleFieldManager.java:372)
      	  at org.apache.openjpa.kernel.SingleFieldManager.delete(SingleFieldManager.java:329)
      	  at org.apache.openjpa.kernel.SingleFieldManager.delete(SingleFieldManager.java:283)
      	  at org.apache.openjpa.kernel.StateManagerImpl.cascadeDelete(StateManagerImpl.java:2,861)
      	  at org.apache.openjpa.kernel.BrokerImpl.delete(BrokerImpl.java:2,566)
      	  at org.apache.openjpa.kernel.BrokerImpl.delete(BrokerImpl.java:2,531)
      	  at org.apache.openjpa.kernel.DelegatingBroker.delete(DelegatingBroker.java:1,046)
      	  at org.apache.openjpa.persistence.EntityManagerImpl.remove(EntityManagerImpl.java:659)
      	  at org.apache.ode.store.jpa.JpaObj.delete(JpaObj.java:34)
      	  at org.apache.ode.store.jpa.DeploymentUnitDaoImpl.delete(DeploymentUnitDaoImpl.java:114)
      	  at org.apache.ode.store.ProcessStoreImpl$3.call(ProcessStoreImpl.java:303)
      	  at org.apache.ode.store.ProcessStoreImpl$3.call(ProcessStoreImpl.java:300)
      	  at org.apache.ode.store.ProcessStoreImpl$Callable.call(ProcessStoreImpl.java:701)
      	  at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:269)
      	  at java.util.concurrent.FutureTask.run(FutureTask.java:123)
      	  at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:650)
      	  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:675)
      	  at java.lang.Thread.run(Thread.java:613)
      

      The interesting bit is the following exerpt:

      	  at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
      	  at java.security.AccessController.doPrivileged(AccessController.java:-1)
      	  at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
      

      The current code in ModuleImpl#searchDynamicImports() does not really handle this case. The reason is that the java.net.URLClassLoader$1 class is an anonymous PrivilegedExceptionAction.
      The result is that the loop is aborted too soon and the launcher classloader is used to delegate the call. In my application, it leads to all kinds of LinkageError being thrown.

      Note that this problem mostly happen on macs, which has a weird thing in the classloader, trying to handle some org.apache.crimson / org.apache.xalan / org.apache.xml / org.apache.xpath in some weird way.
      Anyway, I have a patch to support this anonymous classes I will attach now.

      Attachments

        1. FELIX-962.new.patch
          2 kB
          Guillaume Nodet
        2. FELIX-962.newer.patch
          3 kB
          Richard S. Hall
        3. FELIX-962.patch
          1 kB
          Guillaume Nodet
        4. FELIX-962-bis.patch
          1 kB
          Guillaume Nodet
        5. FELIX-962-newerer.patch
          4 kB
          Guillaume Nodet
        6. FELIX-962-quarter.patch
          7 kB
          Guillaume Nodet
        7. FELIX-962-quinquies.patch
          14 kB
          Richard S. Hall
        8. FELIX-962-richard.txt
          3 kB
          Richard S. Hall
        9. FELIX-962-septies.patch
          14 kB
          Richard S. Hall
        10. FELIX-962-sexies.patch
          15 kB
          Guillaume Nodet
        11. FELIX-962-ter.patch
          6 kB
          Guillaume Nodet

        Activity

          People

            rickhall Richard S. Hall
            gnodet Guillaume Nodet
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: