0 Replies Latest reply on Jan 29, 2014 9:46 AM by eloi.rui

    Create a WAB in JBoss AS 7.1.1

    eloi.rui

      Hello, I'm trying to create a Web Application Bundle for JBoss AS 7.1.1 but each time I try to deploy the bundle is deployed correctly but I can't access the web-contextroot.

      Here's my steps:

       

      1. Create a new Maven Web Application in NetBeans. Build, deploy in Jboss and works 100%.

      2. Add pom configuration of maven-bundle-plugin (I'm using the same configuration of Part 4 of 6: OSGi-enabled Java EE Applications - https://www.youtube.com/watch?v=bSX89JjQoRM)

       

      <build>
              <finalName>${artifactId}</finalName>
              <pluginManagement>
                  <plugins>
                      <plugin>
                          <groupId>org.apache.felix</groupId>
                          <artifactId>maven-bundle-plugin</artifactId>
                          <version>2.1.0</version>
                          <extensions>true</extensions>
                          <configuration>
                              <supportedProjectTypes>
                                  <supportedProjectType>ejb</supportedProjectType>
                                  <supportedProjectType>war</supportedProjectType>
                                  <supportedProjectType>bundle</supportedProjectType>
                                  <supportedProjectType>jar</supportedProjectType>
                              </supportedProjectTypes>
                              <instructions>
                                  <!-- Read all OSGi configuration info from this optional file -->
                                  <_include>-osgi.properties</_include>
                                  <!-- By default, we don't export anything -->
                                  <Export-Package>!*.impl.*, *</Export-Package>
                              </instructions>
                          </configuration>
                          <executions>
                              <execution>
                                  <id>bundle-manifest</id>
                                  <phase>process-classes</phase>
                                  <goals>
                                      <goal>manifest</goal>
                                  </goals>
                              </execution>
                              <execution>
                                  <id>bundle-install</id>
                                  <phase>install</phase>
                                  <goals>
                                      <goal>install</goal>
                                  </goals>
                              </execution>
                          </executions>
                      </plugin>
                      <plugin> <!-- Need to use this plugin to build war files -->
                          <artifactId>maven-war-plugin</artifactId>
                          <groupId>org.apache.maven.plugins</groupId>
                          <!-- Use version 2.1-beta-1, as it supports the new property failOnMissingWebXml -->
                          <version>2.1-beta-1</version>
                          <configuration>
                              <archive>
                                  <!-- add bundle plugin generated manifest to the war -->
                                  <manifestFile>
                                      ${project.build.outputDirectory}/META-INF/MANIFEST.MF
                                  </manifestFile>
                                  <!-- For some reason, adding Bundle-ClassPath in maven-bundle-plugin
                                  confuses that plugin and it generates wrong Import-Package, etc.
                                  So, we generate it here.
                                  -->
                                  <manifestEntries>
                                      <Bundle-ClassPath>WEB-INF/classes/
                                      </Bundle-ClassPath>
                                  </manifestEntries>
                              </archive>
                          <!-- We don't have a web.xml -->
                          <failOnMissingWebXml>false</failOnMissingWebXml>
                          </configuration>
                      </plugin>
                      <plugin>
                          <artifactId>maven-jar-plugin</artifactId>
                          <configuration>
                              <archive>
                                  <!-- add bundle plugin generated manifest to the jar -->
                                  <manifestFile>
                                      ${project.build.outputDirectory}/META-INF/MANIFEST.MF
                                  </manifestFile>
                              </archive>
                          </configuration>
                      </plugin>
                      <plugin> <!-- Need to use this plugin to build ejb-jar files -->
                          <artifactId>maven-ejb-plugin</artifactId>
                          <groupId>org.apache.maven.plugins</groupId>
                          <!-- Use version 2.1-beta-1, as it supports the new property failOnMissingWebXml -->
                          <version>2.1</version>
                          <configuration>
                              <configuration>
                                  <ejbVersion>3.1</ejbVersion>
                              </configuration>
                              <archive>
                                  <!-- add bundle plugin generated manifest to the war -->
                                  <manifestFile>
                                      ${project.build.outputDirectory}/META-INF/MANIFEST.MF
                                  </manifestFile>
                              </archive>
                          </configuration>
                      </plugin>
                      <plugin>
                          <groupId>org.apache.maven.plugins</groupId>
                          <artifactId>maven-compiler-plugin</artifactId>
                          <configuration>
                              <source>1.5</source>
                              <target>1.5</target>
                          </configuration>
                      </plugin>
                  </plugins>
              </pluginManagement>
              <plugins>
                  <plugin>
                      <!-- Enable this plugin for all modules -->
                      <groupId>org.apache.felix</groupId>
                      <artifactId>maven-bundle-plugin</artifactId>
                  </plugin>
              </plugins>
          </build>
      

       

      3. Add osgi.properties file with:

       

      Bundle-ClassPath: .,WEB-INF/classes/

      Bundle-SymbolicName: testeee

      Web-ContextPath: /Testeee

       

      5. Add Activator class:

       

      import org.osgi.framework.BundleActivator;
      import org.osgi.framework.BundleContext;
      
      /**
       *
       * @author reloi
       */
      public class Activator implements BundleActivator {
      
          public void start(BundleContext context) throws Exception {
              System.out.println("Hello");
          }
      
          public void stop(BundleContext context) throws Exception {
              System.out.println("Bye");
          }
      }
      

       

      Build. Try to deploy appears the message: Cannot obtain web.xml from: vfs:

       

      4. Add web.xml in WEB-INF

       

      <?xml version="1.0" encoding="UTF-8"?>
      
      
      <web-app id="testeee" xmlns="http://java.sun.com/xml/ns/javaee"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
        version="3.0">
          <session-config>
              <session-timeout>
                  30
              </session-timeout>
          </session-config>
      </web-app>
      

       

      5. Deploy

       

      14:42:00,208 INFO  [org.jboss.osgi.framework.internal.BundleManager] (MSC service thread 1-2) Install bundle: testeee:1.0.0.SNAPSHOT
      14:42:00,214 INFO  [stdout] (MSC service thread 1-2) Hello 14:42:00,215 INFO  [org.jboss.osgi.framework.internal.HostBundleState] (MSC serv
      ice thread 1-2) Bundle started: testeee:1.0.0.SNAPSHOT 
      14:42:00,411 INFO  [org.jboss.as.server] (DeploymentScanner-threads - 2) JBAS018565: Replaced deployment "testeee.war" with deployment "testeee.war"
      

       

      But when I try to access http://localhost:8080/testeee/ the page doesn't exists.

       

      What am I doing wrong? Any thoughts?

       

       

      Thanks