University of Cincinnati logo and link  
A look at our XML Files
 
  UC ingot This is a very slim application, and the configuration files are equally slim.  A fully functional EJB program with entity beans would have database information in some of these files as well.
    • Many of these files are automatically generated.  But they occasionally require hand-tweaking, so let's describe them here.
    • Some of these files are application server independent, while others are vendor dependent.  Generally, the vendor dependent ones have 'jboss' in the name somewhere.  Each vendor will have its own vendor-dependent files.
  • (client) web.xml: the an ejb-ref section.
    • Includes the ejb ref name and ejb type (Session, Entity, Message).
    • Gives the class names for the home and remote interfaces.


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC
   "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
   "http://java.sun.com/dtd/web-app_2_3.dtd">

<web-app>
   
   <display-name>Web Client</display-name>
   
   <!-- The Welcome File List -->
   <welcome-file-list>
      <welcome-file>index.jsp</welcome-file>
      <welcome-file>index.html</welcome-file>
   </welcome-file-list>
   
   <ejb-ref>
      <ejb-ref-name>ejb/simpleejb/Hello</ejb-ref-name>
      <ejb-ref-type>Session</ejb-ref-type>
      <home>simpleejb.HelloHome</home>
      <remote>simpleejb.Hello</remote>
   </ejb-ref>
   
</web-app>
 
 

  • (client) jboss-web.xml
    • A subset of web.xml, with the information that JBoss cares about.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE jboss-web
    PUBLIC "-//JBoss//DTD Web Application 2.3//EN"
    "http://www.jboss.org/j2ee/dtds/jboss-web_3_0.dtd">

<jboss-web>
   
   <ejb-ref>
      <ejb-ref-name>ejb/simpleejb/Hello</ejb-ref-name>
      <jndi-name>ejb/simpleejb/Hello</jndi-name>
   </ejb-ref>
   
</jboss-web>
 

  • (ejb) ejb-jar file
    • Defines the name of the EJB.
    • Also contains the name of the home, remote, and bean classes.
    • Specifies type of bean and type of persistence (database connection).


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN" "http://java.sun.com/dtd/ejb-jar_2_0.dtd">

<ejb-jar >

   <description>A very simple EJB Example</description>
   <display-name>Edited by Brandan</display-name>

   <enterprise-beans>

      <!-- Session Beans -->
      <session >
         <description><![CDATA[A simple hello world EJB]]></description>
         <display-name>Hello World EJB</display-name>

         <ejb-name>simpleejb/Hello</ejb-name>

         <home>simpleejb.HelloHome</home>
         <remote>simpleejb.Hello</remote>
         <ejb-class>simpleejb.HelloBean</ejb-class>
         <session-type>Stateless</session-type>
         <transaction-type>Container</transaction-type>  

      </session>

     <!--
       To add session beans that you have deployment descriptor info for, add
       a file to your merge directory called session-beans.xml that contains
       the <session></session> markup for those beans.
     -->

   </enterprise-beans>

   <!-- Relationships -->

   <!-- Assembly Descriptor -->
   <assembly-descriptor >

   <!-- finder permissions -->
   <!-- transactions -->
   <!-- finder transactions -->
   </assembly-descriptor>

</ejb-jar>
 

  • (ejb) jboss.xml
    • The ejb-name and jndi-name.  Take special care to make sure the jndi-name matches the name used in jboss-web on the client and the JSP! 
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE jboss PUBLIC "-//JBoss//DTD JBOSS//EN" "http://www.jboss.org/j2ee/dtd/jboss.dtd">

<jboss>

   <enterprise-beans>

      <session>
         <ejb-name>simpleejb/Hello</ejb-name>
         <jndi-name>ejb/simpleejb/Hello</jndi-name>
      </session>
   </enterprise-beans>

   <resource-managers>
      <resource-manager res-class="javax.mail.Session">
         <res-name>test/Mail</res-name>
         <res-jndi-name>java:Mail</res-jndi-name>
      </resource-manager>
   </resource-managers>

</jboss>
 

 Wrapup