JBoss.org Community Documentation

11.4.2. Configuration Files

Now that we have built the application, lets take a closer look at some of the important Configuration files. We have built the final archive ready for deployment - jsfejb3.ear. The contents of your EAR file should look like this:

jsfejb3.ear
|+ app.jar   // contains the EJB code
    |+ import.sql
    |+ Todo.class
    |+ TodoDao.class
    |+ TodoDaoInt.class
    |+ META-INF
        |+ persistence.xml
|+ app.war   // contains web UI
    |+ index.html
    |+ index.xhtml
    |+ create.xhtml
    |+ edit.xhtml
    |+ todos.xhtml
    |+ TodoBean.class
    |+ style.css
    |+ META-INF
    |+ WEB-INF
       |+ faces-config.xml
       |+ navigation.xml
       |+ web.xml
|+ META-INF  // contains the descriptors
    |+ application.xml
    |+ jboss-app.xml
  • application.xml: This file lists the JAR files in the EAR (in our case app.jar) and tells the JBoss server what files to look for and where. The root URL for the application is also specified in this file as 'context-root'.

    <application>
      <display-name>Sample Todo</display-name>
      <module>
        <web>
          <web-uri>app.war</web-uri>
          <context-root>/jsfejb3</context-root>
        </web>
      </module>
      <module>
        <ejb>app.jar</ejb>
      </module>
    </application>
    

  • jboss-app.xml: Every EAR application should specify a unique string name for the class loader. In our case, we use the application name 'jsfejb3' as the class loader name.

    <jboss-app>
      <loader-repository>
        jsfejb3:archive=jsfejb3.ear
      </loader-repository>
    </jboss-app>
    

  • app.jar: This contains EJB3 Session Bean and Entity Bean classes and the related configuration files. In addition, the persistence.xml file configures the back-end data source (in our case the default HSQL database) for the EntityManager.

    <persistence>
       <persistence-unit name="helloworld">
          <provider>org.hibernate.ejb.HibernatePersistence</provider>
          <jta-data-source>java:/DefaultDS</jta-data-source>
          <properties>
             <property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect"/>
             <property name="hibernate.hbm2ddl.auto" value="create-drop"/>
          </properties>
       </persistence-unit>
    </persistence>
    

  • app.war: This contains the Web UI files packaged according to the Web Application aRchive (WAR) specification. It contains all the web pages and the required configuration files. The web.xml file is an important file for all JAVA EE web applications. It is the web deployment descriptor file. The faces-config.xml file is the configuration file for JSF. The navigation.xml file contains the rules for JSF page navigation.

    //faces-config.xml
    <faces-config>
      <application>
        <view-handler>
          com.sun.facelets.FaceletViewHandler
        </view-handler>
      </application>
      <managed-bean>
        <description>Dao</description>
        <managed-bean-name>todoBean</managed-bean-name>
        <managed-bean-class>TodoBean</managed-bean-class>
        <managed-bean-scope>request</managed-bean-scope>
      </managed-bean>
    </faces-config>