10 Replies Latest reply on May 3, 2013 5:28 AM by thomas.diesler

    OSGI WAB deployment in JBoss AS 7.1.1 fails due with - "Cannot obtain web.xml"

    eran_kazula

      Hello,

       

      I've created a (VERY!) simple OSGI Web Application Bundle and for some reason when I deploy it on the JBoss AS 7.1.1 I recieve the following error:

       

      Caused by: org.jboss.osgi.deployment.interceptor.LifecycleInterceptorException: Cannot obtain web.xml from: vfs:

       

      I've tried "playing around" with the structure of the JAR file (and changing the 'Bundle-ClassPath' instruction accordingly) but with no success.

       

      Any ideas what am I'm missing here?

       

      Thanks,

      Eran.

       

       

      The project details -

       

      The bundle is a JAR file of the following structure:

       

      MyWebAppBundle.jar

           |

           |----META-INF

           |          |----MANIFEST.MF    

           |

           |----WEB-INF

           |          |----classes/.../MyServletClass.class

           |          |----web.xml

       


      The manifest file contains the following:

       

      Manifest-Version: 1.0

      Bundle-ManifestVersion: 2

      Bundle-SymbolicName: MyWebAppBundle

      Bundle-Version: 1.0.0

      Bundle-ClassPath: WEB-INF/classes

      Web-ContextPath: /MyWAB

      Import-Package: javax.servlet.http,javax.servlet

       

       

      The web.xml file contains the following:

       

      <web-app>

           <display-name>My OSGI Web Application</display-name>

               <servlet>

                    <servlet-name>Servlet</servlet-name>

                     <servlet-class>SomeServletClass</servlet-class>

                </servlet>

                <servlet-mapping>

                     <servlet-name>Servlet</servlet-name>

                     <url-pattern>/servlet</url-pattern>

                </servlet-mapping>

      </web-app>

       


        • 1. Re: OSGI WAB deployment in JBoss AS 7.1.1 fails due with - "Cannot obtain web.xml"
          jaikiran

          Please post the entire exception stacktrace.

          • 2. Re: OSGI WAB deployment in JBoss AS 7.1.1 fails due with - "Cannot obtain web.xml"
            eran_kazula

            Thanks jaikiran for your quick response. Here is full stacktrace:

             

            19:36:12,218 ERROR [org.jboss.as.osgi] (MSC service thread 1-4) JBAS011900: Cannot start bundle: MyWebAppBundle:1.0.0: org.osgi.framework.BundleException: Cannot transition to STARTING: MyWebAppBundle:1.0.0

                      at org.jboss.osgi.framework.internal.HostBundleState.transitionToActive(HostBundleState.java:284) [jbosgi-framework-core-1.1.8.Final.jar:1.1.8.Final]

                      at org.jboss.osgi.framework.internal.HostBundleState.startInternal(HostBundleState.java:223) [jbosgi-framework-core-1.1.8.Final.jar:1.1.8.Final]

                      at org.jboss.osgi.framework.internal.AbstractBundleState.start(AbstractBundleState.java:494) [jbosgi-framework-core-1.1.8.Final.jar:1.1.8.Final]

                      at org.jboss.as.osgi.deployment.BundleStartTracker$1.processService(BundleStartTracker.java:144) [jboss-as-osgi-service-7.1.1.Final.jar:7.1.1.Final]

                      at org.jboss.as.osgi.deployment.BundleStartTracker$1.transition(BundleStartTracker.java:119) [jboss-as-osgi-service-7.1.1.Final.jar:7.1.1.Final]

                      at org.jboss.msc.service.ServiceControllerImpl.invokeListener(ServiceControllerImpl.java:1416) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]

                      at org.jboss.msc.service.ServiceControllerImpl.access$2700(ServiceControllerImpl.java:49) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]

                      at org.jboss.msc.service.ServiceControllerImpl$ListenerTask.run(ServiceControllerImpl.java:1954) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]

                      at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885) [rt.jar:1.6.0]

                      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907) [rt.jar:1.6.0]

                      at java.lang.Thread.run(Thread.java:619) [rt.jar:1.6.0]

            Caused by: org.jboss.osgi.deployment.interceptor.LifecycleInterceptorException: Cannot obtain web.xml from: vfs:/D:/sdk/jboss/jboss-as-7.1.1.Final/bin/content/MyWebAppBundle.jar/WEB-INF/classes/

                      at org.jboss.osgi.framework.internal.WebXMLVerifierInterceptor$1.invoke(WebXMLVerifierInterceptor.java:85) [jbosgi-framework-core-1.1.8.Final.jar:1.1.8.Final]

                      at org.jboss.osgi.deployment.interceptor.AbstractLifecycleInterceptorService.handleStateChange(AbstractLifecycleInterceptorService.java:281) [jbosgi-deployment-1.0.12.Final.jar:1.0.12.Final]

                      at org.jboss.osgi.framework.internal.LifecycleInterceptorPlugin.handleStateChange(LifecycleInterceptorPlugin.java:125) [jbosgi-framework-core-1.1.8.Final.jar:1.1.8.Final]

                      at org.jboss.osgi.framework.internal.AbstractBundleState.changeState(AbstractBundleState.java:183) [jbosgi-framework-core-1.1.8.Final.jar:1.1.8.Final]

                      at org.jboss.osgi.framework.internal.AbstractBundleState.changeState(AbstractBundleState.java:172) [jbosgi-framework-core-1.1.8.Final.jar:1.1.8.Final]

                      at org.jboss.osgi.framework.internal.HostBundleState.transitionToActive(HostBundleState.java:282) [jbosgi-framework-core-1.1.8.Final.jar:1.1.8.Final]

                      ... 10 more

            • 3. Re: OSGI WAB deployment in JBoss AS 7.1.1 fails due with - "Cannot obtain web.xml"
              jaikiran

              Caused by: org.jboss.osgi.deployment.interceptor.LifecycleInterceptorException: Cannot obtain web.xml from: vfs:/D:/sdk/jboss/jboss-as-7.1.1.Final/bin/content/MyWebAppBundle.jar/WEB-INF/classes/

              It's looking at the wrong location for the web.xml. I'll take a look at the code later today when I'm at my work desk.

              • 4. Re: OSGI WAB deployment in JBoss AS 7.1.1 fails due with - "Cannot obtain web.xml"
                jaikiran

                I actually hadn't paid full attention to that stacktrace and had assumed the exception being thrown from AS7 code. Now that I look at it, it's being thrown from a class in the JBoss OSGi project. Anyway, the location it is looking for is still incorrect. The latest version in AS7 upstream is 1.3.0 whereas AS 7.1.1.Final had 1.1.8 (as shown in that stacktrace). I'll check with someone from the OSGi team to see if this a known issue that was fixed.

                • 5. Re: OSGI WAB deployment in JBoss AS 7.1.1 fails due with - "Cannot obtain web.xml"
                  thomas.diesler

                  We have test coverage for this so I don't think that the functionality is generally broken. This could however be a windows file system issue.

                  Could you pls attach your WAB to https://issues.jboss.org/browse/AS7-4825

                  I'll investigate.

                  • 6. Re: OSGI WAB deployment in JBoss AS 7.1.1 fails due with - "Cannot obtain web.xml"
                    eran_kazula

                    Well, after closely reviewing several other MANIFEST files, it seems that the 'Bundle-ClassPath' instruction is the issue here. Modifying this instruction's value to also include the '.' (dot), seemed to resolve the "Cannot obtain web.xml" error (BTW, removing this instruction altogether seem to get the same result). 

                     

                    The thing that now, after the bundle gets deployed and started correctly, it does NOT work ... #$%^%#$^# e.g. when trying to access the servlet (through a browser for example), you get a 404 (resource not found) error response. I've tried modifying and changing the 'Web-ContextPath' instrcution in the MANIFEST.MF / The 'url-pattern' attribute in the 'web.xml' but still no success. I've also manually configured the following 2 bundles / capabilities - "org.ops4j.pax.web:pax-web-jsp:1.1.2" and "org.ops4j.pax.web:pax-web-jetty-bundle:1.1.2" and still I get the "not found" result from "Jetty"....

                     

                    Any ideas here?

                     


                    • 7. Re: OSGI WAB deployment in JBoss AS 7.1.1 fails due with - "Cannot obtain web.xml"
                      thomas.diesler

                      The route that most people take is to start from the working samples.

                       

                      The latest distribution is jbosgi-1.1.0. Try running

                       

                      [tdiesler@tdvaio example]$ mvn -Dtarget.container=jboss710 clean install

                       

                      Running org.jboss.test.osgi.example.webapp.WebAppNegativeTestCase

                      Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 5.17 sec

                      Running org.jboss.test.osgi.example.webapp.WebAppTestCase

                      Tests run: 3, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.873 sec

                      • 8. Re: OSGI WAB deployment in JBoss AS 7.1.1 fails due with - "Cannot obtain web.xml"
                        thomas.diesler

                        It's a bug that we require the '.' (dot) in the Bundle-ClassPath

                        https://issues.jboss.org/browse/JBOSGI-559

                         

                        Thanks for reporting this

                        • 9. Re: OSGI WAB deployment in JBoss AS 7.1.1 fails due with - "Cannot obtain web.xml"
                          arthurtsang

                          i have the same problem as Eran.  after adding the . (dot) to Bundle-ClassPath, the bundle started but doesn't work.  I tried to deploy David's WAB from this post https://community.jboss.org/message/647106 and got the same 404 error.  eventually i gave up and wrote a simple bundle which register the servlet to pax web's webcontainer directly (https://ops4j1.jira.com/wiki/display/paxweb/Http+Service+Extensions). 

                          • 10. Re: OSGI WAB deployment in JBoss AS 7.1.1 fails due with - "Cannot obtain web.xml"
                            thomas.diesler

                            We have test coverage for this both in wildfly and in jbosgi. I advise to start from a working example.