[jboss-jira] [JBoss JIRA] (WFLY-3511) Invalid class load of embedded interface despite defined dependency

David Lloyd (JIRA) issues at jboss.org
Tue Jun 17 10:26:25 EDT 2014


    [ https://issues.jboss.org/browse/WFLY-3511?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12977053#comment-12977053 ] 

David Lloyd commented on WFLY-3511:
-----------------------------------

What does the JMX mbean say about this module's path set?  You should be able to examine it in detail.

Are you sure there are not other JARs containing this path?

> Invalid class load of embedded interface despite defined dependency
> -------------------------------------------------------------------
>
>                 Key: WFLY-3511
>                 URL: https://issues.jboss.org/browse/WFLY-3511
>             Project: WildFly
>          Issue Type: Bug
>      Security Level: Public(Everyone can see) 
>          Components: Class Loading
>    Affects Versions: 8.1.0.Final
>            Reporter: Thomas Diesler
>            Assignee: David Lloyd
>
> It is common that OSGi jars contain the interfaces of the services they implement. The wildfly modules hierarchy contains an implementation bundle for the HttpService with a dependency on org.osgi.enterprise which contains the org.osgi.service.http.HttpService interface. Client modules are expected to define a dependency on org.osgi.enterprise
> I would expect that org.osgi.service.http.HttpService is always loaded from org.osgi.enterprise and never from the impl bundle that also contains this interface.
> Module org.jboss.gravia contains the impl of the HttpService and a dependency on org.osgi.enterprise
> {code}
> <module xmlns="urn:jboss:module:1.1" name="org.jboss.gravia">
>     <properties>
>         <property name="jboss.api" value="private"/>
>     </properties>
>     <resources>
>         <resource-root path="gravia-provision-1.1.0.Beta30.jar"/>
>         <resource-root path="gravia-repository-1.1.0.Beta30.jar"/>
>         <resource-root path="gravia-resolver-1.1.0.Beta30.jar"/>
>         <resource-root path="gravia-resource-1.1.0.Beta30.jar"/>
>         <resource-root path="gravia-runtime-api-1.1.0.Beta30.jar"/>
>         <resource-root path="gravia-runtime-embedded-1.1.0.Beta30.jar"/>
>         <resource-root path="org.apache.felix.configadmin-1.8.0.jar"/>
>         <resource-root path="org.apache.felix.http.bridge-2.2.1.jar"/>
>         <resource-root path="org.apache.felix.log-1.0.1.jar"/>
>         <resource-root path="org.apache.felix.metatype-1.0.8.jar"/>
>         <resource-root path="org.apache.felix.scr-1.6.2.jar"/>
>     </resources>
>     <exports>
>         <include path="org/jboss/gravia/process"/>
>         <include path="org/jboss/gravia/provision"/>
>         <include path="org/jboss/gravia/resource"/>
>         <include path="org/jboss/gravia/resolver"/>
>         <include path="org/jboss/gravia/repository"/>
>         <include path="org/jboss/gravia/runtime"/>
>     </exports>
>     
>     <dependencies>
>         <module name="javax.api"/>
>         <module name="javax.servlet.api"/>
>         <module name="org.osgi.core"/>
>         <module name="org.osgi.enterprise"/>
>         <module name="org.slf4j"/>
>     </dependencies>
> </module>
> {code}
> When I use this code in a webapp  
> {code}
>             ModuleClassLoader classLoader = (ModuleClassLoader) getClass().getClassLoader();
>             org.jboss.modules.Module graviaModule = loadModule(ModuleIdentifier.create("org.jboss.gravia"));
>             org.jboss.modules.Module osgiModule = loadModule(ModuleIdentifier.create("org.osgi.enterprise"));
>             Class<?> interfClass = loadClass(null, osgiModule.getClassLoader(), "org.osgi.service.http.HttpService");
>             Class<?> implClass = loadClass(null, graviaModule.getClassLoader(), "org.apache.felix.http.base.internal.service.HttpServiceImpl");
>             if (!interfClass.isAssignableFrom(implClass)) {
>                 System.out.println("NOT ASSIGNABLE: " + interfClass + " <= " + implClass);
>             }
> {code}
> I get
> {code}
> 10:47:13,264 INFO  [stdout] (MSC service thread 1-7) LOADED: interface org.osgi.service.http.HttpService
> 10:47:13,265 INFO  [stdout] (MSC service thread 1-7)    using null from ModuleClassLoader for Module "org.osgi.enterprise:main" from local module loader @10fdc382 (finder: local module finder @42e9485 (roots: /Users/tdiesler/git/fabric8poc/itests/smoke/wildfly/target/wildfly-8.1.0.Final/modules,/Users/tdiesler/git/fabric8poc/itests/smoke/wildfly/target/wildfly-8.1.0.Final/modules/system/layers/base))
> 10:47:13,266 INFO  [stdout] (MSC service thread 1-7)    loaded from => ModuleClassLoader for Module "org.osgi.enterprise:main" from local module loader @10fdc382 (finder: local module finder @42e9485 (roots: /Users/tdiesler/git/fabric8poc/itests/smoke/wildfly/target/wildfly-8.1.0.Final/modules,/Users/tdiesler/git/fabric8poc/itests/smoke/wildfly/target/wildfly-8.1.0.Final/modules/system/layers/base))
> 10:47:13,268 INFO  [stdout] (MSC service thread 1-7) LOADED: class org.apache.felix.http.base.internal.service.HttpServiceImpl
> 10:47:13,268 INFO  [stdout] (MSC service thread 1-7)    using null from ModuleClassLoader for Module "org.jboss.gravia:main" from local module loader @10fdc382 (finder: local module finder @42e9485 (roots: /Users/tdiesler/git/fabric8poc/itests/smoke/wildfly/target/wildfly-8.1.0.Final/modules,/Users/tdiesler/git/fabric8poc/itests/smoke/wildfly/target/wildfly-8.1.0.Final/modules/system/layers/base))
> 10:47:13,268 INFO  [stdout] (MSC service thread 1-7)    loaded from => ModuleClassLoader for Module "org.jboss.gravia:main" from local module loader @10fdc382 (finder: local module finder @42e9485 (roots: /Users/tdiesler/git/fabric8poc/itests/smoke/wildfly/target/wildfly-8.1.0.Final/modules,/Users/tdiesler/git/fabric8poc/itests/smoke/wildfly/target/wildfly-8.1.0.Final/modules/system/layers/base))
> 10:47:13,269 INFO  [stdout] (MSC service thread 1-7) NOT ASSIGNABLE: interface org.osgi.service.http.HttpService <= class org.apache.felix.http.base.internal.service.HttpServiceImpl
> {code}
> The resulting application error is 
> {code}
> 10:47:13,503 WARN  [org.jboss.gravia.runtime] (MSC service thread 1-7) Error while firing service event REGISTERED for: ServiceState{service.id=54, objectClass=[org.osgi.service.http.HttpService, org.apache.felix.http.api.ExtHttpService]}: java.lang.ClassCastException: org.apache.felix.http.base.internal.service.HttpServiceImpl cannot be cast to org.osgi.service.http.HttpService
> 	at org.jolokia.osgi.JolokiaActivator$HttpServiceCustomizer.addingService(JolokiaActivator.java:207)
> 	at org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:932) [org.osgi.core-5.0.0.jar:]
> 	at org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:864) [org.osgi.core-5.0.0.jar:]
> 	at org.osgi.util.tracker.AbstractTracked.trackAdding(AbstractTracked.java:256) [org.osgi.core-5.0.0.jar:]
> 	at org.osgi.util.tracker.AbstractTracked.track(AbstractTracked.java:229) [org.osgi.core-5.0.0.jar:]
> 	at org.osgi.util.tracker.ServiceTracker$Tracked.serviceChanged(ServiceTracker.java:894) [org.osgi.core-5.0.0.jar:]
> 	at org.jboss.gravia.runtime.embedded.spi.BundleContextAdaptor$ServiceListenerAdaptor.serviceChanged(BundleContextAdaptor.java:323) [gravia-runtime-embedded-1.1.0.Beta30.jar:]
> {code}



--
This message was sent by Atlassian JIRA
(v6.2.6#6264)


More information about the jboss-jira mailing list