9 Replies Latest reply on Sep 22, 2011 5:44 AM by mreasy

    ClassCastException: MyFilter cannot be cast to javax.servlet.Filter

    mreasy

      Hi,

      Having a Web-app, that uses a ServletFilter fails deploying with:

      DEBUG [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/CompSystemInfo]] (MSC service thread 1-11)  Starting filter 'GZIPFilter'
      ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/CompSystemInfo]] (MSC service thread 1-11) Exception starting filter GZIPFilter: java.lang.ClassCastException: com.companyname.util.servlet.filter.compression.GZIPFilter cannot be cast to javax.servlet.Filter
       at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:441) [jbossweb-7.0.1.Final.jar:7.1.0.Alpha1-SNAPSHOT]
       at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:3245) [jbossweb-7.0.1.Final.jar:7.1.0.Alpha1-SNAPSHOT]
       at org.apache.catalina.core.StandardContext.start(StandardContext.java:3836) [jbossweb-7.0.1.Final.jar:7.1.0.Alpha1-SNAPSHOT]
       at org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:70) [jboss-as-web-7.1.0.Alpha1-SNAPSHOT.jar:7.1.0.Alpha1-SNAPSHOT]
      

       

      Full log attached.

      In particular the class "com.companyname.util.servlet.filter.compression.GZIPFilter" is contained in an OSGi-bundle, which gets referenced by the WAR via:

      Dependencies: deployment.com.companyname.CompUtil:0.0.1
      

      which obvisouly works, since the class itself is found, but seems the class-loaders are not able to make the connection.

       

      The class-loader for javax.servlet.Filter is

      ModuleClassLoader for Module "javax.servlet.api:main" from local module loader @17094d48 (roots: D:\test\jboss-as-7.1.0.Alpha1-2011-09-15\modules)
      

      Was unable todetermine the class-loader of the GZIPFilter class, but I assume it is loaded in the OSGi-bundle-class-loader, which seems to be isolated from the module class-loader.

      Adding explicite dependencies to javaee.api did not make any difference.

       

      Configuration:

      - domain-preview

      - Win7

       

      Any hints, how to make the WAR load its filter in a way so it ends-up in the 'right' context?

        • 1. Re: ClassCastException: MyFilter cannot be cast to javax.servlet.Filter
          mreasy

          Versions tested with:

          - jboss-as-7.1.0.Alpha1 as of 2011-09-15

          - jboss-as-7.1.0.Alpha2 as of 2011-09-19

          • 2. Re: ClassCastException: MyFilter cannot be cast to javax.servlet.Filter
            mreasy

            Possibly related to https://issues.jboss.org/browse/AS7-202 ?

            Adding OSGi-meta-data to the WAR maybe would resolve the class-loader issue, but is not deploying due to https://issues.jboss.org/browse/AS7-1601 / https://issues.jboss.org/browse/AS7-1551

            • 3. Re: ClassCastException: MyFilter cannot be cast to javax.servlet.Filter
              thomas.diesler

              The CCE is most likely due to the bundle containing the filter not using the same exporter for package 'javax.servlet' as the web container. Assuming that the web container loads that class from module javaee.api you could verify that the bundle has an import for that package and that it is indeed imported from module javaee.api. If the bundle loads javax.servlet.Filter from any where else you would you'd get that that CCE. Setting the log level to DEBUG should show you where javax.servlet gets wired to.

               

              When you're positive that the imports are setup correctly, please create a little sample project that isolates the issue and reference it from a jira you create for it. Cheers.

              1 of 1 people found this helpful
              • 4. Re: ClassCastException: MyFilter cannot be cast to javax.servlet.Filter
                mreasy

                Hi Thomas, thanks for your reply.

                Mabe you (and others) can have a look at the following log, where I annoted the loading of the OSGi-bundle and the WAR, which depends upon it. Maybe most interesting are the 2 lines loading the Filter-classes:

                 

                Loading class com.companyname.util.servlet.filter.compression.GZIPFilter locally from Module "deployment.com.companyname.common.CompUtil:0.0.1.SNAPSHOT" from Service Module Loader
                Found previously loaded interface javax.servlet.Filter from Module "deployment.jboss-osgi-http:1.0.3" from Service Module Loader
                

                 

                For me this looks like both are loaded by (the same?) "Service Module Loader".

                Here comes the whole log, see especially the lines annoted with '###' - also attached as attachment for convenience:

                 

                ...### Start-up
                TRACE [org.jboss.modules] (Controller Boot Thread) Finding class javax.servlet.Filter from Module "org.jboss.weld.core:main" from local module loader @12b7eea (roots: D:\test\jboss-as-7.1.0.Alpha2-2011-09-19\modules)
                TRACE [org.jboss.modules] (MSC service thread 1-9) Defined class org.omg.PortableServer.ServantRetentionPolicyOperations in Module "org.jacorb:main" from local module loader @12b7eea (roots: D:\test\jboss-as-7.1.0.Alpha2-2011-09-19\modules)
                TRACE [org.jboss.modules] (Controller Boot Thread) Finding local class javax.servlet.Filter from Module "javax.servlet.api:main" from local module loader @12b7eea (roots: D:\test\jboss-as-7.1.0.Alpha2-2011-09-19\modules)
                TRACE [org.jboss.modules] (MSC service thread 1-9) Defined class org.omg.PortableServer.ServantRetentionPolicy in Module "org.jacorb:main" from local module loader @12b7eea (roots: D:\test\jboss-as-7.1.0.Alpha2-2011-09-19\modules)
                TRACE [org.jboss.modules] (Controller Boot Thread) Loading class javax.servlet.Filter locally from Module "javax.servlet.api:main" from local module loader @12b7eea (roots: D:\test\jboss-as-7.1.0.Alpha2-2011-09-19\modules)
                TRACE [org.jboss.modules] (MSC service thread 1-9) Finding class org.omg.PortableServer.RequestProcessingPolicy from Module "org.jacorb:main" from local module loader @12b7eea (roots: D:\test\jboss-as-7.1.0.Alpha2-2011-09-19\modules)
                TRACE [org.jboss.modules] (MSC service thread 1-2) Defined class org.jboss.jca.core.connectionmanager.AbstractConnectionManager in Module "org.jboss.ironjacamar.impl:main" from local module loader @12b7eea (roots: D:\test\jboss-as-7.1.0.Alpha2-2011-09-19\modules)
                TRACE [org.jboss.modules] (Controller Boot Thread) Attempting to define class javax.servlet.Filter in Module "javax.servlet.api:main" from local module loader @12b7eea (roots: D:\test\jboss-as-7.1.0.Alpha2-2011-09-19\modules)
                TRACE [org.jboss.modules] (MSC service thread 1-9) Finding local class org.omg.PortableServer.RequestProcessingPolicy from Module "org.jacorb:main" from local module loader @12b7eea (roots: D:\test\jboss-as-7.1.0.Alpha2-2011-09-19\modules)
                TRACE [org.jboss.modules] (MSC service thread 1-2) Finding class org.jboss.jca.core.connectionmanager.tx.TxConnectionManagerImpl from Module "org.jboss.ironjacamar.impl:main" from local module loader @12b7eea (roots: D:\test\jboss-as-7.1.0.Alpha2-2011-09-19\modules)
                TRACE [org.jboss.modules] (Controller Boot Thread) Defined class javax.servlet.Filter in Module "javax.servlet.api:main" from local module loader @12b7eea (roots: D:\test\jboss-as-7.1.0.Alpha2-2011-09-19\modules)
                ...
                TRACE [org.jboss.modules] (Controller Boot Thread) Finding class javax.servlet.Filter from Module "org.jboss.resteasy.resteasy-jaxrs:main" from local module loader @12b7eea (roots: D:\test\jboss-as-7.1.0.Alpha2-2011-09-19\modules)
                TRACE [org.jboss.modules] (Controller Boot Thread) Finding local class javax.servlet.Filter from Module "javax.servlet.api:main" from local module loader @12b7eea (roots: D:\test\jboss-as-7.1.0.Alpha2-2011-09-19\modules)
                TRACE [org.jboss.modules] (MSC service thread 1-15) Attempting to define class org.hornetq.core.message.impl.MessageInternal in Module "org.hornetq:main" from local module loader @12b7eea (roots: D:\test\jboss-as-7.1.0.Alpha2-2011-09-19\modules)
                TRACE [org.jboss.modules] (Controller Boot Thread) Found previously loaded interface javax.servlet.Filter from Module "javax.servlet.api:main" from local module loader @12b7eea (roots: D:\test\jboss-as-7.1.0.Alpha2-2011-09-19\modules)
                ...
                TRACE [org.jboss.modules] (MSC service thread 1-9) Finding class javax.servlet.Filter from Module "deployment.jboss-osgi-http:1.0.3" from Service Module Loader
                TRACE [org.jboss.modules] (MSC service thread 1-9) Finding local class javax.servlet.Filter from Module "deployment.jboss-osgi-http:1.0.3" from Service Module Loader
                TRACE [org.jboss.modules] (MSC service thread 1-9) Loading class javax.servlet.Filter locally from Module "deployment.jboss-osgi-http:1.0.3" from Service Module Loader
                TRACE [org.jboss.modules] (MSC service thread 1-9) Attempting to define class javax.servlet.Filter in Module "deployment.jboss-osgi-http:1.0.3" from Service Module Loader
                TRACE [org.jboss.modules] (MSC service thread 1-9) Defined class javax.servlet.Filter in Module "deployment.jboss-osgi-http:1.0.3" from Service Module Loader
                ...
                TRACE [org.jboss.modules] (MSC service thread 1-9) Finding class javax.servlet.FilterChain from Module "deployment.jboss-osgi-http:1.0.3" from Service Module Loader
                TRACE [org.jboss.modules] (MSC service thread 1-9) Finding local class javax.servlet.FilterChain from Module "deployment.jboss-osgi-http:1.0.3" from Service Module Loader
                TRACE [org.jboss.modules] (MSC service thread 1-9) Loading class javax.servlet.FilterChain locally from Module "deployment.jboss-osgi-http:1.0.3" from Service Module Loader
                TRACE [org.jboss.modules] (MSC service thread 1-9) Attempting to define class javax.servlet.FilterChain in Module "deployment.jboss-osgi-http:1.0.3" from Service Module Loader
                TRACE [org.jboss.modules] (MSC service thread 1-9) Defined class javax.servlet.FilterChain in Module "deployment.jboss-osgi-http:1.0.3" from Service Module Loader
                
                ... ### This is the OSGi-bundle deploying with export of the required Filter-class:
                
                INFO  [org.jboss.osgi.framework.internal.BundleManager] (MSC service thread 1-15) Install bundle: com.companyname.common.CompUtil:0.0.1.SNAPSHOT
                TRACE [org.jboss.osgi.framework.internal.AbstractBundleState] (MSC service thread 1-15) changeState: com.companyname.common.CompUtil:0.0.1.SNAPSHOT -> INSTALLED
                TRACE [org.jboss.osgi.deployment.interceptor.AbstractLifecycleInterceptorService] (MSC service thread 1-15) Invoke: [org.jboss.osgi.framework.internal.WebXMLVerifierInterceptor$1,order=1000] with state INSTALLED on CompUtil.jar
                TRACE [org.jboss.osgi.resolver.spi.AbstractResolver] (MSC service thread 1-15)
                AbstractModule: [com.companyname.common.CompUtil:0.0.1.SNAPSHOT]
                Capabilities
                 Bundle[com.companyname.common.CompUtil:0.0.1.SNAPSHOT]
                ...
                 Export-Package[com.companyname.util.servlet.filter.compression:0.0.1.SNAPSHOT]
                
                ... ### Here comes the WAR with dependency to Bundle[com.companyname.common.CompUtil:0.0.1.SNAPSHOT] for loading class com.companyname.util.servlet.filter.compression.GZIPFilter
                
                DEBUG [org.jboss.as.ee.component.deployers.EEModuleConfigurationProcessor] (MSC service thread 1-8) Configuring component class: com.companyname.util.servlet.filter.compression.GZIPFilter named com.companyname.util.servlet.filter.compression.GZIPFilter
                TRACE [org.jboss.modules] (MSC service thread 1-8) Finding class com.companyname.util.servlet.filter.compression.GZIPFilter from Module "deployment.CompSystemInfo.war:main" from Service Module Loader
                TRACE [org.jboss.modules] (MSC service thread 1-8) Finding local class com.companyname.util.servlet.filter.compression.GZIPFilter from Module "deployment.com.companyname.common.CompUtil:0.0.1.SNAPSHOT" from Service Module Loader
                TRACE [org.jboss.modules] (MSC service thread 1-8) Loading class com.companyname.util.servlet.filter.compression.GZIPFilter locally from Module "deployment.com.companyname.common.CompUtil:0.0.1.SNAPSHOT" from Service Module Loader
                TRACE [org.jboss.modules] (MSC service thread 1-8) Attempting to define class com.companyname.util.servlet.filter.compression.GZIPFilter in Module "deployment.com.companyname.common.CompUtil:0.0.1.SNAPSHOT" from Service Module Loader
                TRACE [org.jboss.modules] (MSC service thread 1-8) Attempting to define package com.companyname.util.servlet.filter.compression in Module "deployment.com.companyname.common.CompUtil:0.0.1.SNAPSHOT" from Service Module Loader
                TRACE [org.jboss.modules] (MSC service thread 1-8) Defined package com.companyname.util.servlet.filter.compression in Module "deployment.com.companyname.common.CompUtil:0.0.1.SNAPSHOT" from Service Module Loader
                TRACE [org.jboss.modules] (MSC service thread 1-8) Finding class javax.servlet.Filter from Module "deployment.com.companyname.common.CompUtil:0.0.1.SNAPSHOT" from Service Module Loader
                TRACE [org.jboss.modules] (MSC service thread 1-8) Finding local class javax.servlet.Filter from Module "deployment.jboss-osgi-http:1.0.3" from Service Module Loader
                TRACE [org.jboss.modules] (MSC service thread 1-8) Found previously loaded interface javax.servlet.Filter from Module "deployment.jboss-osgi-http:1.0.3" from Service Module Loader
                TRACE [org.jboss.modules] (MSC service thread 1-8) Defined class com.companyname.util.servlet.filter.compression.GZIPFilter in Module "deployment.com.companyname.common.CompUtil:0.0.1.SNAPSHOT" from Service Module Loader
                DEBUG [org.jboss.as.ee.component.deployers.EEClassConfigurationProcessor] (MSC service thread 1-8) Configuring EE module class: class com.companyname.util.servlet.filter.compression.GZIPFilter
                ...
                TRACE [org.jboss.as.ee.component.deployers.ComponentInstallProcessor] (MSC service thread 1-8) Installing component com.companyname.util.servlet.filter.compression.GZIPFilter
                ...
                DEBUG [org.apache.catalina.core.StandardContext] (MSC service thread 1-12) Starting /CompSystemInfo
                ...
                DEBUG [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/CompSystemInfo]] (MSC service thread 1-12)  Starting filter 'GZIPFilter'
                ...
                TRACE [org.jboss.modules] (MSC service thread 1-12) Finding local class javax.servlet.Filter from Module "javax.servlet.api:main" from local module loader @12b7eea (roots: D:\test\jboss-as-7.1.0.Alpha2-2011-09-19\modules)
                TRACE [org.jboss.modules] (MSC service thread 1-12) Found previously loaded interface javax.servlet.Filter from Module "javax.servlet.api:main" from local module loader @12b7eea (roots: D:\test\jboss-as-7.1.0.Alpha2-2011-09-19\modules)
                ...
                ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/CompSystemInfo]] (MSC service thread 1-12) Exception starting filter GZIPFilter: java.lang.ClassCastException: com.companyname.util.servlet.filter.compression.GZIPFilter cannot be cast to javax.servlet.Filter
                 at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:441) [jbossweb-7.0.1.Final.jar:7.1.0.Alpha2-SNAPSHOT]
                 at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:3245) [jbossweb-7.0.1.Final.jar:7.1.0.Alpha2-SNAPSHOT]
                 at org.apache.catalina.core.StandardContext.start(StandardContext.java:3836) [jbossweb-7.0.1.Final.jar:7.1.0.Alpha2-SNAPSHOT]
                 at org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:70) [jboss-as-web-7.1.0.Alpha2-SNAPSHOT.jar:7.1.0.Alpha2-SNAPSHOT]
                 at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1824)
                 at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1759)
                 at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [:1.6.0_25]
                 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [:1.6.0_25]
                 at java.lang.Thread.run(Thread.java:662) [:1.6.0_25]
                
                
                • 5. Re: ClassCastException: MyFilter cannot be cast to javax.servlet.Filter
                  wolfc

                  This doesn't look right to me.

                   

                  TRACE [org.jboss.modules] (Controller Boot Thread) Loading class javax.servlet.Filter locally from Module "javax.servlet.api:main" from local module loader @12b7eea (roots: D:\test\jboss-as-7.1.0.Alpha2-2011-09-19\modules)
                  ...
                  TRACE [org.jboss.modules] (MSC service thread 1-9) Loading class javax.servlet.Filter locally from Module "deployment.jboss-osgi-http:1.0.3" from Service Module Loader
                  
                  
                  1 of 1 people found this helpful
                  • 6. Re: ClassCastException: MyFilter cannot be cast to javax.servlet.Filter
                    wolfc

                    jboss-osgi-http-1.0.3.jar contains pax-web-jetty-bundle-1.0.3.jar which contains javax.servlet.Filer (among others).

                    • 7. Re: ClassCastException: MyFilter cannot be cast to javax.servlet.Filter
                      mreasy

                      Great observation Carlo, thanks.

                      I edited the manifest of jboss-osgi-http-1.0.3.jar and removed the Export-Package entries for javax.servlet.*, and tada everything works.

                      The only place javax.servlet.Filter now is loaded from is this one:

                       

                      Loading class javax.servlet.Filter locally from Module "javax.servlet.api:main" from local module loader @12b7eea (roots: D:\test\jboss-as-7.1.0.Alpha2-2011-09-19\modules)
                      

                      which looks correct.

                       

                      As far as I can see, in jboss-osgi-http's pom.xml this would mean to remove the line with javax.servlet* from the _exportcontents of the maven-bundle-plugin:

                      <_exportcontents>
                        javax.servlet*;version=2.5,
                        org.ops4j.pax.web.service;version=${version.ops4j.pax.web}
                      </_exportcontents>
                      
                      

                       

                      Any idea why this is in there; should I open a bug for it?

                      • 8. Re: ClassCastException: MyFilter cannot be cast to javax.servlet.Filter
                        thomas.diesler

                        The jboss-osgi-http bundle is the provider of the HttpService and must among other packages import/export javax.servlet. In OSGi it is perfectly valid to have more than one exporter of the same package in the system. It is the job of the resolver to generate the wirings such that all the class spaces are consistent.

                         

                        In your case, one exporter of javax.servlet is the javaee.api module - another is jboss-osgi-http. Your webapp is not an OSGi bundle and hence can only wire to javax.servlet available from the javaee.api module.

                         

                        10:11:15,747 INFO  [org.jboss.osgi.framework.internal.BundleManager] (MSC service thread 1-2) Install bundle: javaee.api:0.0.0
                        10:11:15,757 TRACE [org.jboss.osgi.framework.internal.AbstractBundleState] (MSC service thread 1-2) changeState: javaee.api:0.0.0 -> INSTALLED
                        10:11:15,757 TRACE [org.jboss.osgi.deployment.interceptor.AbstractLifecycleInterceptorService] (MSC service thread 1-2) Invoke: [org.jboss.osgi.framework.internal.WebXMLVerifierInterceptor$1,order=1000] with state INSTALLED on javaee.api:main
                        10:11:15,760 TRACE [org.jboss.osgi.resolver.spi.AbstractResolver] (MSC service thread 1-2) 
                        AbstractModule: [javaee.api:0.0.0]
                        Capabilities
                         Bundle[javaee.api:0.0.0]
                         Export-Package[com.sun.activation:0.0.0]
                         Export-Package[javax.enterprise:0.0.0]
                         Export-Package[javax.enterprise.deploy.spi.factories:0.0.0]
                         Export-Package[javax.persistence.spi:0.0.0]
                         Export-Package[javax.tools:0.0.0]
                         Export-Package[javax.xml.bind:0.0.0]
                         Export-Package[javax.print.attribute.standard:0.0.0]
                         Export-Package[javax.ejb.embeddable:0.0.0]
                         Export-Package[javax.xml.rpc.handler:0.0.0]
                         Export-Package[javax.management.remote.rmi:0.0.0]
                         Export-Package[javax.xml.crypto.dsig.keyinfo:0.0.0]
                         Export-Package[javax.jws:0.0.0]
                         Export-Package[javax.xml.stream:0.0.0]
                         Export-Package[javax.enterprise.context.spi:0.0.0]
                         Export-Package[javax.xml.ws.soap:0.0.0]
                         Export-Package[javax.mail.util:0.0.0]
                         Export-Package[javax.swing:0.0.0]
                         Export-Package[javax.swing.text.html.parser:0.0.0]
                         Export-Package[javax.xml.ws.spi.http:0.0.0]
                         Export-Package[javax.enterprise.deploy.spi.exceptions:0.0.0]
                         Export-Package[javax.xml.crypto:0.0.0]
                         Export-Package[javax.enterprise.deploy.shared:0.0.0]
                         Export-Package[org.jcp.xml.dsig:0.0.0]
                         Export-Package[javax.enterprise.context:0.0.0]
                         Export-Package[javax.mail.search:0.0.0]
                         Export-Package[org.apache.xml.security.keys.content:0.0.0]
                         Export-Package[org.apache.xml.security.keys.keyresolver.implementations:0.0.0]
                         Export-Package[javax.el:0.0.0]
                         Export-Package[javax.imageio.plugins.bmp:0.0.0]
                         Export-Package[javax.lang.model.element:0.0.0]
                         Export-Package[javax.swing.undo:0.0.0]
                         Export-Package[org.apache.xml.security.resource:0.0.0]
                         Export-Package[org.w3c.dom.css:0.0.0]
                         Export-Package[javax.security.auth.spi:0.0.0]
                         Export-Package[javax.xml:0.0.0]
                         Export-Package[javax.xml.ws.http:0.0.0]
                         Export-Package[javax.swing.plaf.basic:0.0.0]
                         Export-Package[javax.ws.rs.ext:0.0.0]
                         Export-Package[javax.naming.spi:0.0.0]
                         Export-Package[javax.xml.crypto.dom:0.0.0]
                         Export-Package[javax.xml.transform.dom:0.0.0]
                         Export-Package[javax.imageio.stream:0.0.0]
                         Export-Package[javax.xml.rpc.encoding:0.0.0]
                         Export-Package[javax.xml.soap:0.0.0]
                         Export-Package[javax.validation.spi:0.0.0]
                         Export-Package[com.sun.mail.imap.protocol:0.0.0]
                         Export-Package[org.apache.xml:0.0.0]
                         Export-Package[javax.xml.transform.sax:0.0.0]
                         Export-Package[org.w3c.dom.events:0.0.0]
                         Export-Package[javax.resource.spi.security:0.0.0]
                         Export-Package[javax.validation.constraints:0.0.0]
                         Export-Package[javax.lang.model.util:0.0.0]
                         Export-Package[javax.xml.bind.helpers:0.0.0]
                         Export-Package[javax.crypto.spec:0.0.0]
                         Export-Package[javax.print:0.0.0]
                         Export-Package[javax.servlet:0.0.0]
                         Export-Package[javax.jws.soap:0.0.0]
                         Export-Package[javax.crypto.interfaces:0.0.0]
                         Export-Package[javax.sound.midi.spi:0.0.0]
                         Export-Package[javax.imageio.metadata:0.0.0]
                         Export-Package[javax.servlet.descriptor:0.0.0]
                         Export-Package[javax.imageio.spi:0.0.0]
                         Export-Package[org.apache.xml.security.transforms.implementations:0.0.0]
                         Export-Package[javax.mail.event:0.0.0]
                         Export-Package[javax.ws.rs:0.0.0]
                         Export-Package[javax.security.auth.message.callback:0.0.0]
                         Export-Package[org.w3c.dom.traversal:0.0.0]
                         Export-Package[org.apache.xml.security.encryption:0.0.0]
                         Export-Package[javax.xml.validation:0.0.0]
                         Export-Package[javax.security:0.0.0]
                         Export-Package[javax.ejb.spi:0.0.0]
                         Export-Package[org.apache.xml.security.utils:0.0.0]
                         Export-Package[javax.ws:0.0.0]
                         Export-Package[javax.swing.border:0.0.0]
                         Export-Package[org.w3c.dom.stylesheets:0.0.0]
                         Export-Package[com:0.0.0]
                         Export-Package[javax.imageio:0.0.0]
                         Export-Package[org.w3c.dom.ls:0.0.0]
                         Export-Package[javax.swing.plaf.synth:0.0.0]
                         Export-Package[javax.xml.rpc:0.0.0]
                         Export-Package[com.sun.mail:0.0.0]
                         Export-Package[javax.management.relation:0.0.0]
                         Export-Package[javax.resource.spi.work:0.0.0]
                         Export-Package[javax:0.0.0]
                         Export-Package[com.sun.mail.handlers:0.0.0]
                         Export-Package[org.apache.xml.security.keys.keyresolver:0.0.0]
                         Export-Package[javax.xml.bind.annotation:0.0.0]
                         Export-Package[javax.swing.text.html:0.0.0]
                         Export-Package[org.apache.xml.security.c14n:0.0.0]
                         Export-Package[javax.security.auth.kerberos:0.0.0]
                         Export-Package[javax.xml.rpc.handler.soap:0.0.0]
                         Export-Package[org.jcp.xml:0.0.0]
                         Export-Package[org.w3c.dom.xpath:0.0.0]
                         Export-Package[javax.persistence:0.0.0]
                         Export-Package[javax.swing.text:0.0.0]
                         Export-Package[com.sun:0.0.0]
                         Export-Package[javax.accessibility:0.0.0]
                         Export-Package[javax.naming.directory:0.0.0]
                         Export-Package[com.sun.mail.iap:0.0.0]
                         Export-Package[javax.imageio.plugins.jpeg:0.0.0]
                         Export-Package[org.apache.xml.security.c14n.implementations:0.0.0]
                         Export-Package[javax.xml.ws.handler:0.0.0]
                         Export-Package[javax.sound.sampled:0.0.0]
                         Export-Package[org.apache.xml.security.keys:0.0.0]
                         Export-Package[javax.validation.groups:0.0.0]
                         Export-Package[javax.swing.event:0.0.0]
                         Export-Package[javax.annotation.security:0.0.0]
                         Export-Package[javax.swing.text.rtf:0.0.0]
                         Export-Package[javax.resource:0.0.0]
                         Export-Package[javax.resource.cci:0.0.0]
                         Export-Package[javax.xml.rpc.holders:0.0.0]
                         Export-Package[javax.security.auth.callback:0.0.0]
                         Export-Package[javax.xml.transform.stream:0.0.0]
                         Export-Package[javax.servlet.annotation:0.0.0]
                         Export-Package[org.apache.xml.security.keys.content.keyvalues:0.0.0]
                         Export-Package[com.sun.activation.viewers:0.0.0]
                         Export-Package[javax.sql.rowset.spi:0.0.0]
                         Export-Package[javax.net:0.0.0]
                         Export-Package[org.apache.xml.security.resource.schema:0.0.0]
                         Export-Package[javax.enterprise.deploy.model.exceptions:0.0.0]
                         Export-Package[javax.annotation.sql:0.0.0]
                         Export-Package[javax.enterprise.inject:0.0.0]
                         Export-Package[javax.servlet.jsp:0.0.0]
                         Export-Package[javax.xml.crypto.dsig.dom:0.0.0]
                         Export-Package[javax.crypto:0.0.0]
                         Export-Package[javax.xml.rpc.soap:0.0.0]
                         Export-Package[javax.net.ssl:0.0.0]
                         Export-Package[javax.annotation:0.0.0]
                         Export-Package[org.xml.sax:0.0.0]
                         Export-Package[javax.enterprise.event:0.0.0]
                         Export-Package[javax.sql.rowset.serial:0.0.0]
                         Export-Package[org.w3c.dom:0.0.0]
                         Export-Package[javax.management.remote:0.0.0]
                         Export-Package[org.apache.xml.security:0.0.0]
                         Export-Package[javax.xml.ws.spi:0.0.0]
                         Export-Package[com.sun.mail.auth:0.0.0]
                         Export-Package[javax.mail.internet:0.0.0]
                         Export-Package[javax.security.auth.message.module:0.0.0]
                         Export-Package[javax.validation:0.0.0]
                         Export-Package[org.jcp:0.0.0]
                         Export-Package[javax.enterprise.deploy:0.0.0]
                         Export-Package[javax.script:0.0.0]
                         Export-Package[javax.servlet.jsp.el:0.0.0]
                         Export-Package[javax.xml.xpath:0.0.0]
                         Export-Package[com.sun.activation.registries:0.0.0]
                         Export-Package[javax.xml.transform:0.0.0]
                         Export-Package[org.apache.xml.security.algorithms:0.0.0]
                         Export-Package[javax.swing.colorchooser:0.0.0]
                         Export-Package[javax.xml.ws.wsaddressing:0.0.0]
                         Export-Package[javax.enterprise.deploy.spi.status:0.0.0]
                         Export-Package[javax.xml.ws:0.0.0]
                         Export-Package[javax.xml.parsers:0.0.0]
                         Export-Package[javax.lang.model.type:0.0.0]
                         Export-Package[javax.jms:0.0.0]
                         Export-Package[javax.resource.spi:0.0.0]
                         Export-Package[javax.transaction.xa:0.0.0]
                         Export-Package[javax.print.attribute:0.0.0]
                         Export-Package[javax.security.sasl:0.0.0]
                         Export-Package[javax.security.auth.message.config:0.0.0]
                         Export-Package[javax.management.loading:0.0.0]
                         Export-Package[com.sun.mail.imap:0.0.0]
                         Export-Package[org:0.0.0]
                         Export-Package[javax.xml.crypto.dsig:0.0.0]
                         Export-Package[org.apache.xml.security.exceptions:0.0.0]
                         Export-Package[javax.naming:0.0.0]
                         Export-Package[javax.ejb:0.0.0]
                         Export-Package[javax.management:0.0.0]
                         Export-Package[javax.inject:0.0.0]
                         Export-Package[org.apache.xml.security.c14n.helper:0.0.0]
                         Export-Package[javax.transaction:0.0.0]
                         Export-Package[org.apache.xml.security.signature:0.0.0]
                         Export-Package[javax.xml.bind.attachment:0.0.0]
                         Export-Package[javax.sql:0.0.0]
                         Export-Package[javax.swing.plaf.metal:0.0.0]
                         Export-Package[javax.print.event:0.0.0]
                         Export-Package[javax.sound.midi:0.0.0]
                         Export-Package[com.sun.mail.util.logging:0.0.0]
                         Export-Package[javax.naming.ldap:0.0.0]
                         Export-Package[javax.xml.crypto.dsig.spec:0.0.0]
                         Export-Package[org.apache.xml.security.utils.resolver.implementations:0.0.0]
                         Export-Package[javax.xml.stream.util:0.0.0]
                         Export-Package[org.apache:0.0.0]
                         Export-Package[javax.xml.registry:0.0.0]
                         Export-Package[javax.naming.event:0.0.0]
                         Export-Package[javax.xml.bind.annotation.adapters:0.0.0]
                         Export-Package[javax.imageio.event:0.0.0]
                         Export-Package[org.xml.sax.ext:0.0.0]
                         Export-Package[javax.sound.sampled.spi:0.0.0]
                         Export-Package[javax.validation.bootstrap:0.0.0]
                         Export-Package[javax.security.auth.x500:0.0.0]
                         Export-Package[javax.security.auth.login:0.0.0]
                         Export-Package[javax.xml.transform.stax:0.0.0]
                         Export-Package[org.apache.xml.security.keys.storage.implementations:0.0.0]
                         Export-Package[javax.enterprise.deploy.shared.factories:0.0.0]
                         Export-Package[javax.swing.table:0.0.0]
                         Export-Package[javax.swing.plaf:0.0.0]
                         Export-Package[javax.activity:0.0.0]
                         Export-Package[org.jcp.xml.dsig.internal.dom:0.0.0]
                         Export-Package[javax.security.auth:0.0.0]
                         Export-Package[javax.xml.registry.infomodel:0.0.0]
                         Export-Package[javax.swing.plaf.multi:0.0.0]
                         Export-Package[javax.interceptor:0.0.0]
                         Export-Package[org.apache.xml.security.algorithms.implementations:0.0.0]
                         Export-Package[javax.management.modelmbean:0.0.0]
                         Export-Package[javax.resource.spi.endpoint:0.0.0]
                         Export-Package[javax.activation:0.0.0]
                         Export-Package[javax.servlet.http:0.0.0]
                         Export-Package[javax.xml.bind.util:0.0.0]
                         Export-Package[javax.lang.model:0.0.0]
                         Export-Package[com.sun.mail.pop3:0.0.0]
                         Export-Package[javax.servlet.jsp.tagext:0.0.0]
                         Export-Package[javax.management.monitor:0.0.0]
                         Export-Package[javax.persistence.criteria:0.0.0]
                         Export-Package[javax.xml.namespace:0.0.0]
                         Export-Package[javax.enterprise.inject.spi:0.0.0]
                         Export-Package[javax.security.jacc:0.0.0]
                         Export-Package[org.w3c.dom.ranges:0.0.0]
                         Export-Package[javax.enterprise.deploy.spi:0.0.0]
                         Export-Package[javax.management.timer:0.0.0]
                         Export-Package[javax.enterprise.util:0.0.0]
                         Export-Package[org.w3c.dom.html:0.0.0]
                         Export-Package[org.apache.xml.security.keys.content.x509:0.0.0]
                         Export-Package[javax.swing.filechooser:0.0.0]
                         Export-Package[javax.management.openmbean:0.0.0]
                         Export-Package[org.ietf.jgss:0.0.0]
                         Export-Package[javax.sql.rowset:0.0.0]
                         Export-Package[javax.enterprise.deploy.model:0.0.0]
                         Export-Package[org.jcp.xml.dsig.internal:0.0.0]
                         Export-Package[javax.xml.datatype:0.0.0]
                         Export-Package[javax.decorator:0.0.0]
                         Export-Package[javax.swing.tree:0.0.0]
                         Export-Package[org.apache.xml.security.transforms:0.0.0]
                         Export-Package[javax.security.cert:0.0.0]
                         Export-Package[org.w3c.dom.bootstrap:0.0.0]
                         Export-Package[com.sun.mail.smtp:0.0.0]
                         Export-Package[javax.ws.rs.core:0.0.0]
                         Export-Package[org.apache.xml.security.keys.storage:0.0.0]
                         Export-Package[org.apache.xml.security.transforms.params:0.0.0]
                         Export-Package[javax.persistence.metamodel:0.0.0]
                         Export-Package[org.xml.sax.helpers:0.0.0]
                         Export-Package[com.sun.mail.util:0.0.0]
                         Export-Package[javax.xml.ws.handler.soap:0.0.0]
                         Export-Package[javax.rmi.ssl:0.0.0]
                         Export-Package[javax.xml.stream.events:0.0.0]
                         Export-Package[javax.validation.metadata:0.0.0]
                         Export-Package[org.apache.xml.security.utils.resolver:0.0.0]
                         Export-Package[javax.mail:0.0.0]
                         Export-Package[javax.security.auth.message:0.0.0]
                         Export-Package[javax.xml.rpc.server:0.0.0]
                        Requirements
                        10:11:15,784 TRACE [org.jboss.osgi.framework.internal.FrameworkEventsPlugin] (MSC service thread 1-2) AbstractBundleState INSTALLED: javaee.api:0.0.0
                        

                         

                        For your bundle the resolver has a choice and picks the jboss-osgi-http bundle as the exporter of javax.servlet. It's an interesting integration issue that I need to think about for a little while ...

                         

                        If you don't need the HttpService you could remove that bundle. This would require to remove the console as well however.

                         

                        Tracked by: https://issues.jboss.org/browse/AS7-1900

                        • 9. Re: ClassCastException: MyFilter cannot be cast to javax.servlet.Filter
                          mreasy

                          Thanks Thomas for the confirmation

                          From my point of view, I would deploy the WAR as OSGi-bundle, when https://issues.jboss.org/browse/AS7-1601 is resolved, but I think also e.g. an EJB-jar might have the demand to load e.g. javax.servlet.Filter for whatever reason and this should succeed and not be misrouted to the OSGi-bundle's classloader.