Classloading issues with Sling Models IT
I am experiencing a weird bug in Sling Models IT. It seems that both Models API 1.1.1-SNAPSHOT and Models Impl 1.1.1-SNAPSHOT are part of the Sling Launchpad 8-SNAPSHOT. If I now run the Sling Models IT and deploy my own versions of those bundles, the API bundle is replaced by the newer version (which is correct), but both bundles are still available in Felix (due to class loading caching issues I guess). The following happens: 1.) Sling Launchpad starts up with its own version of Models API (has bundle id 108) 2.) Models IT deploys its own version of Models API (gets bundle id 110) 3.) Now the web console only exposes the bundle 110 and no longer bundle 108. When I try to execute some test now I get the following exception: Caused by: java.lang.ClassNotFoundException: org.apache.sling.models.factory.ModelClassException not found by org.apache.sling.models.api [108] at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1556) at org.apache.felix.framework.BundleWiringImpl.access$400(BundleWiringImpl.java:77) at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:1993) at java.lang.ClassLoader.loadClass(ClassLoader.java:358) at org.apache.felix.framework.BundleWiringImpl.getClassByDelegation(BundleWiringImpl.java:1397) at org.apache.felix.framework.BundleWiringImpl.searchImports(BundleWiringImpl.java:1577) at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1507) at org.apache.felix.framework.BundleWiringImpl.access$400(BundleWiringImpl.java:77) at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:1993) at java.lang.ClassLoader.loadClass(ClassLoader.java:358) ... 79 common frames omitted This is due to the fact that the Models Impl is bound to the two different version of Models API at the same time: This is the import package section of the Models Impl Bundle: == javax.annotation,version=0.0.0.1_007_JavaSE from org.apache.felix.framework (0) http://localhost:58498/system/console/bundles/0 javax.inject,version=0.0.0 from org.apache.sling.models.api (110) http://localhost:58498/system/console/bundles/110 javax.servlet,version=2.6.0 from org.apache.felix.http.servlet-api (24) http://localhost:58498/system/console/bundles/24 javax.servlet,version=3.0.0 from org.apache.felix.http.servlet-api (24) http://localhost:58498/system/console/bundles/24 javax.servlet.http,version=2.6.0 from org.apache.felix.http.servlet-api (24) http://localhost:58498/system/console/bundles/24 javax.servlet.http,version=3.0.0 from org.apache.felix.http.servlet-api (24) http://localhost:58498/system/console/bundles/24 org.apache.commons.collections.comparators,version=3.2.1 from org.apache.commons.collections (60) http://localhost:58498/system/console/bundles/60 org.apache.commons.collections.keyvalue,version=3.2.1 from org.apache.commons.collections (60) http://localhost:58498/system/console/bundles/60 org.apache.commons.collections.list,version=3.2.1 from org.apache.commons.collections (60) http://localhost:58498/system/console/bundles/60 org.apache.commons.collections.set,version=3.2.1 from org.apache.commons.collections (60) http://localhost:58498/system/console/bundles/60 org.apache.commons.lang,version=2.6.0 from org.apache.commons.lang (64) http://localhost:58498/system/console/bundles/64 org.apache.commons.logging,version=1.1.1 from jcl.over.slf4j (1) http://localhost:58498/system/console/bundles/1 org.apache.sling.api,version=2.3.0 from org.apache.sling.api (71) http://localhost:58498/system/console/bundles/71 org.apache.sling.api.adapter,version=2.2.0 from org.apache.sling.api (71) http://localhost:58498/system/console/bundles/71 org.apache.sling.api.resource,version=2.6.0 from org.apache.sling.api (71) http://localhost:58498/system/console/bundles/71 org.apache.sling.api.scripting,version=2.1.0 from org.apache.sling.api (71) http://localhost:58498/system/console/bundles/71 org.apache.sling.commons.osgi,version=2.2.0 from org.apache.sling.commons.osgi (78) http://localhost:58498/system/console/bundles/78 org.apache.sling.models.annotations,version=1.2.0 from org.apache.sling.models.api (110) http://localhost:58498/system/console/bundles/110 org.apache.sling.models.annotations.injectorspecific,version=1.1.0 from org.apache.sling.models.api (110) http://localhost:58498/system/console/bundles/110 org.apache.sling.models.factory,version=1.0.0 from org.apache.sling.models.api (108) http://localhost:58498/system/console/bundles/108 org.apache.sling.models.spi,version=1.0.2 from org.apache.sling.models.api (108) http://localhost:58498/system/console/bundles/108 org.apache.sling.models.spi.injectorspecific,version=1.1.0 from org.apache.sling.models.api (110) http://localhost:58498/system/console/bundles/110
Re: Classloading issues with Sling Models IT
It does work, if I I modify org.apache.sling.testing.tools.sling.BundlesInstaller to not uninstall the previous SNAPSHOT bundle before installing the new version (comment out line 80). What was the reason for first uninstalling the bundle? Usually an upgrade works much smoother (at least if the version is not downgraded). So what about the following change: Uninstall only if the previously installed versionis higher than the version which is about to be installed. Otherwise we might easily run into the same problems for other bundles, which cannot easily be uninstalled. On 07 Dec 2014, at 14:34, Konrad Windszus konra...@gmx.de wrote: I am experiencing a weird bug in Sling Models IT. It seems that both Models API 1.1.1-SNAPSHOT and Models Impl 1.1.1-SNAPSHOT are part of the Sling Launchpad 8-SNAPSHOT. If I now run the Sling Models IT and deploy my own versions of those bundles, the API bundle is replaced by the newer version (which is correct), but both bundles are still available in Felix (due to class loading caching issues I guess). The following happens: 1.) Sling Launchpad starts up with its own version of Models API (has bundle id 108) 2.) Models IT deploys its own version of Models API (gets bundle id 110) 3.) Now the web console only exposes the bundle 110 and no longer bundle 108. When I try to execute some test now I get the following exception: Caused by: java.lang.ClassNotFoundException: org.apache.sling.models.factory.ModelClassException not found by org.apache.sling.models.api [108] at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1556) at org.apache.felix.framework.BundleWiringImpl.access$400(BundleWiringImpl.java:77) at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:1993) at java.lang.ClassLoader.loadClass(ClassLoader.java:358) at org.apache.felix.framework.BundleWiringImpl.getClassByDelegation(BundleWiringImpl.java:1397) at org.apache.felix.framework.BundleWiringImpl.searchImports(BundleWiringImpl.java:1577) at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1507) at org.apache.felix.framework.BundleWiringImpl.access$400(BundleWiringImpl.java:77) at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:1993) at java.lang.ClassLoader.loadClass(ClassLoader.java:358) ... 79 common frames omitted This is due to the fact that the Models Impl is bound to the two different version of Models API at the same time: This is the import package section of the Models Impl Bundle: == javax.annotation,version=0.0.0.1_007_JavaSE from org.apache.felix.framework (0) http://localhost:58498/system/console/bundles/0 javax.inject,version=0.0.0 from org.apache.sling.models.api (110) http://localhost:58498/system/console/bundles/110 javax.servlet,version=2.6.0 from org.apache.felix.http.servlet-api (24) http://localhost:58498/system/console/bundles/24 javax.servlet,version=3.0.0 from org.apache.felix.http.servlet-api (24) http://localhost:58498/system/console/bundles/24 javax.servlet.http,version=2.6.0 from org.apache.felix.http.servlet-api (24) http://localhost:58498/system/console/bundles/24 javax.servlet.http,version=3.0.0 from org.apache.felix.http.servlet-api (24) http://localhost:58498/system/console/bundles/24 org.apache.commons.collections.comparators,version=3.2.1 from org.apache.commons.collections (60) http://localhost:58498/system/console/bundles/60 org.apache.commons.collections.keyvalue,version=3.2.1 from org.apache.commons.collections (60) http://localhost:58498/system/console/bundles/60 org.apache.commons.collections.list,version=3.2.1 from org.apache.commons.collections (60) http://localhost:58498/system/console/bundles/60 org.apache.commons.collections.set,version=3.2.1 from org.apache.commons.collections (60) http://localhost:58498/system/console/bundles/60 org.apache.commons.lang,version=2.6.0 from org.apache.commons.lang (64) http://localhost:58498/system/console/bundles/64 org.apache.commons.logging,version=1.1.1 from jcl.over.slf4j (1) http://localhost:58498/system/console/bundles/1 org.apache.sling.api,version=2.3.0 from org.apache.sling.api (71) http://localhost:58498/system/console/bundles/71 org.apache.sling.api.adapter,version=2.2.0 from org.apache.sling.api (71) http://localhost:58498/system/console/bundles/71 org.apache.sling.api.resource,version=2.6.0 from org.apache.sling.api (71) http://localhost:58498/system/console/bundles/71 org.apache.sling.api.scripting,version=2.1.0 from org.apache.sling.api (71) http://localhost:58498/system/console/bundles/71 org.apache.sling.commons.osgi,version=2.2.0 from org.apache.sling.commons.osgi (78) http://localhost:58498/system/console/bundles/78
Re: Classloading issues with Sling Models IT
Ok, that modification did not solve everything. With that change the integration tests are executed too fast (before the actual upgrade of the bundle took place). I guess the waitForBundlesInstalled method needs to be changed as well. On 07 Dec 2014, at 15:17, Konrad Windszus konra...@gmx.de wrote: It does work, if I I modify org.apache.sling.testing.tools.sling.BundlesInstaller to not uninstall the previous SNAPSHOT bundle before installing the new version (comment out line 80). What was the reason for first uninstalling the bundle? Usually an upgrade works much smoother (at least if the version is not downgraded). So what about the following change: Uninstall only if the previously installed versionis higher than the version which is about to be installed. Otherwise we might easily run into the same problems for other bundles, which cannot easily be uninstalled. On 07 Dec 2014, at 14:34, Konrad Windszus konra...@gmx.de wrote: I am experiencing a weird bug in Sling Models IT. It seems that both Models API 1.1.1-SNAPSHOT and Models Impl 1.1.1-SNAPSHOT are part of the Sling Launchpad 8-SNAPSHOT. If I now run the Sling Models IT and deploy my own versions of those bundles, the API bundle is replaced by the newer version (which is correct), but both bundles are still available in Felix (due to class loading caching issues I guess). The following happens: 1.) Sling Launchpad starts up with its own version of Models API (has bundle id 108) 2.) Models IT deploys its own version of Models API (gets bundle id 110) 3.) Now the web console only exposes the bundle 110 and no longer bundle 108. When I try to execute some test now I get the following exception: Caused by: java.lang.ClassNotFoundException: org.apache.sling.models.factory.ModelClassException not found by org.apache.sling.models.api [108] at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1556) at org.apache.felix.framework.BundleWiringImpl.access$400(BundleWiringImpl.java:77) at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:1993) at java.lang.ClassLoader.loadClass(ClassLoader.java:358) at org.apache.felix.framework.BundleWiringImpl.getClassByDelegation(BundleWiringImpl.java:1397) at org.apache.felix.framework.BundleWiringImpl.searchImports(BundleWiringImpl.java:1577) at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1507) at org.apache.felix.framework.BundleWiringImpl.access$400(BundleWiringImpl.java:77) at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:1993) at java.lang.ClassLoader.loadClass(ClassLoader.java:358) ... 79 common frames omitted This is due to the fact that the Models Impl is bound to the two different version of Models API at the same time: This is the import package section of the Models Impl Bundle: == javax.annotation,version=0.0.0.1_007_JavaSE from org.apache.felix.framework (0) http://localhost:58498/system/console/bundles/0 javax.inject,version=0.0.0 from org.apache.sling.models.api (110) http://localhost:58498/system/console/bundles/110 javax.servlet,version=2.6.0 from org.apache.felix.http.servlet-api (24) http://localhost:58498/system/console/bundles/24 javax.servlet,version=3.0.0 from org.apache.felix.http.servlet-api (24) http://localhost:58498/system/console/bundles/24 javax.servlet.http,version=2.6.0 from org.apache.felix.http.servlet-api (24) http://localhost:58498/system/console/bundles/24 javax.servlet.http,version=3.0.0 from org.apache.felix.http.servlet-api (24) http://localhost:58498/system/console/bundles/24 org.apache.commons.collections.comparators,version=3.2.1 from org.apache.commons.collections (60) http://localhost:58498/system/console/bundles/60 org.apache.commons.collections.keyvalue,version=3.2.1 from org.apache.commons.collections (60) http://localhost:58498/system/console/bundles/60 org.apache.commons.collections.list,version=3.2.1 from org.apache.commons.collections (60) http://localhost:58498/system/console/bundles/60 org.apache.commons.collections.set,version=3.2.1 from org.apache.commons.collections (60) http://localhost:58498/system/console/bundles/60 org.apache.commons.lang,version=2.6.0 from org.apache.commons.lang (64) http://localhost:58498/system/console/bundles/64 org.apache.commons.logging,version=1.1.1 from jcl.over.slf4j (1) http://localhost:58498/system/console/bundles/1 org.apache.sling.api,version=2.3.0 from org.apache.sling.api (71) http://localhost:58498/system/console/bundles/71 org.apache.sling.api.adapter,version=2.2.0 from org.apache.sling.api (71) http://localhost:58498/system/console/bundles/71 org.apache.sling.api.resource,version=2.6.0 from org.apache.sling.api (71)