Looking for a JavaEE Architect or Potential Tech Co-Founder?
Please don't hesitate to contact me.

Custom application context or name in Jboss or Wildfly

As far as I know there are 3 ways to deploy an application in JBoss or Wildfly with a custom application context name.

1.) By adding jboss-web.xml in your web project WEB-INF folder;
<?xml version="1.0" encoding="UTF-8"?>
<jboss-web xmlns="http://www.jboss.com/xml/ns/javaee"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="
      http://www.jboss.com/xml/ns/javaee
      http://www.jboss.org/j2ee/schema/jboss-web_5_1.xsd">
   <context-root>/</context-root>
</jboss-web>

2.) Adding application.xml in your ear's META-INF folder:
<?xml version="1.0" encoding="UTF-8"?>
<application version="5" 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/application_5.xsd">
 <module>
  <ejb>czetsuya-ejb.jar</ejb>
 </module>
 <module>
  <web>
   <web-uri>czetsuya.war</web-uri>
   <context-root>/</context-root>
  </web>
 </module>
</application>

3.) In your ear's pom.xml:
<plugin>
 <groupId>org.apache.maven.plugins</groupId>
 <artifactId>maven-ear-plugin</artifactId>
 <version>${version.ear.plugin}</version>
 <configuration>
  <!-- Tell Maven we are using Java EE 6 -->
  <version>6</version>
  <!-- Use Java EE ear libraries as needed. Java EE ear libraries are 
   in easy way to package any libraries needed in the ear, and automatically 
   have any modules (EJB-JARs and WARs) use them -->
  <defaultLibBundleDir>lib</defaultLibBundleDir>
  <modules>

   <webModule>
    <groupId>com.kbs</groupId>
    <artifactId>czetsuya-web</artifactId>
    <contextRoot>/</contextRoot>
   </webModule>

  </modules>
  <fileNameMapping>no-version</fileNameMapping>
 </configuration>
</plugin>
Custom application context or name in Jboss or Wildfly Custom application context or name in Jboss or Wildfly Reviewed by Edward Legaspi on Saturday, June 07, 2014 Rating: 5

No comments:

Powered by Blogger.