4 Replies Latest reply on Jun 15, 2017 12:00 PM by ehodges

    CXF Servlet fails to start because META-INF is not on the classpath

    ehodges

      I have an EAR that contains a WAR.  The WAR has a CXF Servlet.  I'm working on updating the open source libraries in this EAR and getting it running on Wildfly 10.

       

      The EAR deploys on WebSphere 9 and Geronimo, but it fails on WildFly because CXFServlet can't read the resource "META-INF/cxf/cxf.xml".  That file is part of "cxf-core-3.1.11.jar".  It is inside the EAR and available to the WAR's classloader.

       

      I found Wildfly documentation (https://docs.jboss.org/author/display/WFLY10/Class+Loading+in+WildFly) that says "By default items in META-INF of a dependency are not accessible".  I think this is the cause of my problem.

       

      That document describes something called an "ee subsystem configuration" and shows a snippet of an XML file.  I think that's part of something called "jboss-deployment-structure.xml"?

       

      Is there any way to avoid JBoss specific deployment descriptors and still use CXF?  Other Java EE app servers don't need to be told to include META-INF in the classpath.

        • 1. Re: CXF Servlet fails to start because META-INF is not on the classpath
          ehodges

          If there is no way to include META-INF files in the classpath without creating a "jboss-deployment-structure.xml" file, then I guess I'll have to do that.

           

          I've tried creating one.  I added it to the WAR's WEB_INF directory, but that produced a message during deployment that said the file was ignored for "sub-deployments".

           

          So I added it to the EAR's META_INF.  It looks like this:

           

          <jboss-deployment-structure>

             <deployment>

                <dependencies>

                   <module name="cxf-core-3.1.11" meta-inf="TRUE" />

                </dependencies>

             </deployment>

          </jboss-deployment-structure>

           

          I can't find documentation on what the "meta-inf" attribute's value should be.  Just guessing it should be "TRUE".

           

          I can't find documentation on what the module's name attribute value should be, either.  My CXF JAR is called "cxf-core-3.1.11.jar", so I guessed the module name would be "cxf-core-3.1.11".  That doesn't seem to work.  Now when I deploy the log is full of these:

           

          14:39:31,428 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-3) MSC000001: Failed to start service jboss.module.service."deployment.<foo>.ear.cxf-core-3.1.11.jar".main: org.jboss.msc.service.StartException in service jboss.module.service."deployment.<foo>.ear.cxf-core-3.1.11.jar".main: WFLYSRV0179: Failed to load module: deployment.<foo>.ear.cxf-core-3.1.11.jar:main

            at org.jboss.as.server.moduleservice.ModuleLoadService.start(ModuleLoadService.java:91)

            at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1948)

            at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1881)

            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)

            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)

            at java.lang.Thread.run(Thread.java:748)

          Caused by: org.jboss.modules.ModuleNotFoundException: cxf-core-3.1.11:main

            at org.jboss.modules.Module.addPaths(Module.java:1093)

            at org.jboss.modules.Module.link(Module.java:1449)

            at org.jboss.modules.Module.relinkIfNecessary(Module.java:1477)

            at org.jboss.modules.ModuleLoader.loadModule(ModuleLoader.java:225)

            at org.jboss.as.server.moduleservice.ModuleLoadService.start(ModuleLoadService.java:68)

            ... 5 more

           

          I'm searching the web for a solution but I haven't found one yet.  Any ideas?  Is there some documentation out there I'm just not finding?

          • 2. Re: CXF Servlet fails to start because META-INF is not on the classpath
            jaikiran

            Can you post the complete stacktrace of the original issue (the cannot read the resource error) please? That will give us a bit more context.

            • 3. Re: CXF Servlet fails to start because META-INF is not on the classpath
              ehodges

              Here's the stack trace:

               

              08:40:20,367 INFO  [org.springframework.web.context.support.XmlWebApplicationContext] (ServerService Thread Pool -- 70) Refreshing Root WebApplicationContext: startup date [Thu Jun 15 08:40:20 CDT 2017]; parent: Root WebApplicationContext

              08:40:20,369 INFO  [org.springframework.beans.factory.xml.XmlBeanDefinitionReader] (ServerService Thread Pool -- 70) Loading XML bean definitions from class path resource [META-INF/cxf/cxf.xml]

              08:40:20,374 ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 70) MSC000001: Failed to start service jboss.undertow.deployment.default-server.default-host./TestWeb: org.jboss.msc.service.StartException in service jboss.undertow.deployment.default-server.default-host./TestWeb: org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [META-INF/cxf/cxf.xml]; nested exception is java.io.FileNotFoundException: class path resource [META-INF/cxf/cxf.xml] cannot be opened because it does not exist

                at org.wildfly.extension.undertow.deployment.UndertowDeploymentService$1.run(UndertowDeploymentService.java:85)

                at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)

                at java.util.concurrent.FutureTask.run(FutureTask.java:266)

                at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)

                at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)

                at java.lang.Thread.run(Thread.java:748)

                at org.jboss.threads.JBossThread.run(JBossThread.java:320)

              Caused by: org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [META-INF/cxf/cxf.xml]; nested exception is java.io.FileNotFoundException: class path resource [META-INF/cxf/cxf.xml] cannot be opened because it does not exist

                at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:344)

                at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:304)

                at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:181)

                at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:217)

                at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:188)

                at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:125)

                at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:94)

                at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:129)

                at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:613)

                at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:514)

                at org.apache.cxf.transport.servlet.CXFServlet.createSpringContext(CXFServlet.java:151)

                at org.apache.cxf.transport.servlet.CXFServlet.loadBus(CXFServlet.java:74)

                at org.apache.cxf.transport.servlet.CXFNonSpringServlet.init(CXFNonSpringServlet.java:77)

                at io.undertow.servlet.core.LifecyleInterceptorInvocation.proceed(LifecyleInterceptorInvocation.java:117)

                at org.wildfly.extension.undertow.security.RunAsLifecycleInterceptor.init(RunAsLifecycleInterceptor.java:78)

                at io.undertow.servlet.core.LifecyleInterceptorInvocation.proceed(LifecyleInterceptorInvocation.java:103)

                at io.undertow.servlet.core.ManagedServlet$DefaultInstanceStrategy.start(ManagedServlet.java:250)

                at io.undertow.servlet.core.ManagedServlet.createServlet(ManagedServlet.java:133)

                at io.undertow.servlet.core.DeploymentManagerImpl$2.call(DeploymentManagerImpl.java:546)

                at io.undertow.servlet.core.DeploymentManagerImpl$2.call(DeploymentManagerImpl.java:517)

                at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:42)

                at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43)

                at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)

                at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)

                at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)

                at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)

                at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)

                at io.undertow.servlet.core.DeploymentManagerImpl.start(DeploymentManagerImpl.java:559)

                at org.wildfly.extension.undertow.deployment.UndertowDeploymentService.startContext(UndertowDeploymentService.java:101)

                at org.wildfly.extension.undertow.deployment.UndertowDeploymentService$1.run(UndertowDeploymentService.java:82)

                ... 6 more

              Caused by: java.io.FileNotFoundException: class path resource [META-INF/cxf/cxf.xml] cannot be opened because it does not exist

                at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:172)

                at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:330)

                ... 35 more

               

              This method:

               

                at org.apache.cxf.transport.servlet.CXFServlet.createSpringContext(CXFServlet.java:151)

               

              is where the code sets an org.springframework.web.context.support.XmlWebApplicationContext's config location to "classpath:/META-INF/cxf/cxf.xml" and then calls XmlWebApplicationContext.refresh().  I believe that ultimately fails becaue "META-INF/cxf/cxf.xml" isn't visible to the classloader.

               

              I've stepped through the same code run by the WebSphere app server and "META-INF/cxf/cxf.xml" is visible.

              • 4. Re: CXF Servlet fails to start because META-INF is not on the classpath
                ehodges

                Any suggestions about getting WildFly 10 to treat the cxf-core-3.1.11.jar in my EAR as a "module"?  The documentation I find about WildFly/JBoss modules all talks about creating directories, as if the EAR was exploded.  I just want to deploy an EAR containing a CXF JAR and have CXF servlets work like they do in other Java EE app servers.