Post Subject : Tutorial on J2EE using JBOSS-4.x, Eclipse-3.x, Lomboz-3.x and 
PostgreSQL-8.x on Windows XP

Ref. 1 : Tutorial for building J2EE Applications using JBOSS and ECLIPSE 
(Chapter 5 : BMP Entity Bean)
         http://www.tusc.com.au/tutorial/html/chap5.html

Ref. 2 : Tutorial on J2EE using JBOSS, ECLIPSE and Lomboz (Forum on Ref. 1)
         http//www.jboss.org/index.html?module=bb&op=viewtopic&t=36910

Ref. 3 : Environment in use ;
- Windows XP SP2
- J2SDK 1.4.2_08
- Eclipse 3.0.2
- JBoss 4.0.2
- Lomboz 3.0.1 + emf-sdo-runtime-2.0.0
- PostgreSQL 8.0.3 (= DefaultDS)

Followings are some notes on Chapter 5 (BMP Entity Bean) in Ref. 1

* Chapter 4 (Statefull Session Bean) has been jumped over.
* Task numbers are based on Ref. 1. 
* No change has been made to the server configuration file 
(jboss402postgres.server) thus far.

Task 1 : Create the Customer BMP Entity Bean
- Before start the task, make a copy of "xdoclet.xml" under MyStoreMgr/META-INF 
as a backup. 
- On creation of "CustomerBean", check some points before proceeding further 
steps.
a. make sure the XDoclet part;/**
  | * @ejb.bean name="Customer"* jndi-name="CustomerBean"* type="BMP"
  | **/
b. comment out "ejbCreate()" and "ejbPostCreate()" methods
public abstract class CustomerBean implements javax.ejb.EntityBean {
  | 
  | //  /**
  | //   *
  | //   * <!-- begin-user-doc -->
  | //   * The  ejbCreate method.
  | //   * <!-- end-user-doc -->
  | //   *
  | //   * <!-- begin-xdoclet-definition --> 
  | //   * @ejb.create-method 
  | //   * <!-- end-xdoclet-definition --> 
  | //   * @generated
  | //   */
  | //  public java.lang.String ejbCreate() throws javax.ejb.CreateException {
  | //    // EJB 2.0 spec says return null for CMP ejbCreate methods.
  | //    // TODO: YOU MUST INITIALIZE THE FIELDS FOR THE BEAN HERE. 
  | //    // setMyField("Something"); 
  | //    // begin-user-code
  | //    return null;
  | //    // end-user-code
  | //  }
  | //
  | //  /**
  | //   * <!-- begin-user-doc -->
  | //   * The container invokes this method immediately after it calls 
ejbCreate.
  | //   * <!-- end-user-doc -->
  | //   * 
  | //   * @generated
  | //   */
  | //  public void ejbPostCreate() throws javax.ejb.CreateException {
  | //    // begin-user-code
  | //    // end-user-code
  | //  }
  | 
  | }
c. confirm no parts of "xdoclet.xml" are missed.
  = the lower half of xdoclet.xml might disappear on the first creation.
  = recover it from the backup file if any.

d. check xdoclet.xml for <!-- BEANS START --> section.
  If no "fileset" for CustomerBean.java, make it as follows;
   :
  |   <!-- BEANS START -->
  |        <fileset dir="${project.dir}/src/" defaultexcludes="yes">
  |                <include name="au/com/tusc/session/StoreAccessBean.java" />
  |        </fileset>      <fileset dir="${project.dir}/src/" 
defaultexcludes="yes">
  |                <include name="au/com/tusc/bmp/CustomerBean.java" />
  |        </fileset>  <!-- BEANS END -->
  |    :
Task 2 : Create Customer's DAO Interface
: (as per the steps in Ref. 1)
Task 9 : Add a create method to the StoreAccess Bean

Task 10 : Add a Business Method in StoreAccess Bean
- After "Generate EJB Classes" (before "deploy");
  = change <ejb-ref> tag under "session" in jboss.xml to <ejb-local-ref> as 
shown in Ref. 1.
  = add "ejb/" to CustomerLocal in <ejb-ref-name> tag under "session" in 
ejb-jar.xml as follows;
       :
  |          <ejb-local-ref >            
<ejb-ref-name>ejb/CustomerLocal</ejb-ref-name>            
<ejb-ref-type>Entity</ejb-ref-type>
  |             <local-home>au.com.tusc.bmp.CustomerLocalHome</local-home>
  |             <local>au.com.tusc.bmp.CustomerLocal</local>
  |             <ejb-link>Customer</ejb-link>
  |          </ejb-local-ref>
  |        :
- Start JBoss from "Lomboz J2EE View" tag in Eclipse.
  Note : Use "Run Server" instead of "Debug Server"
  = In case of error with "Debug Server",
    : click "Stop the launched server" button
    : exit Eclipse
    : delete MyStorePgSQL.jar file under /sever/postgres/deploy
    : start Eclipse again, and then JBoss with "Run Server"


=== On completion of CustomerBean.java, XDoclet sections of each file are as 
follows;

- StoreAccessBean.java
Note : The lomboz sections are generated automatically.
/**
  |  *
  |  * <!-- begin-user-doc --> A generated session bean <!-- end-user-doc --> *
  |  <!-- lomboz.beginDefinition -->
  |  <?xml version="1.0" encoding="UTF-8"?>
  |  <lomboz:EJB xmlns:j2ee="http://java.sun.com/xml/ns/j2ee"; 
xmlns:lomboz="http://lomboz.objectlearn.com/xml/lomboz";>
  |  <lomboz:session>
  |  <lomboz:sessionEjb>
  |  <j2ee:display-name>StoreAccess</j2ee:display-name>
  |  <j2ee:ejb-name>StoreAccess</j2ee:ejb-name>
  |  <j2ee:ejb-class>au.com.tusc.session.StoreAccessBean</j2ee:ejb-class>
  |  <j2ee:session-type>Stateless</j2ee:session-type>
  |  <j2ee:transaction-type>Container</j2ee:transaction-type>
  |  </lomboz:sessionEjb>
  |  </lomboz:session>
  |  </lomboz:EJB>
  |  <!-- lomboz.endDefinition -->
  |  *
  |  * <!-- begin-xdoclet-definition --> 
  |  * @ejb.bean name="StoreAccess"     
  |  *           jndi-name="StoreAccessBean"
  |  *           type="Stateless" 
  |  *           transaction-type="Container"
  |  * 
  |  * @ejb.dao class="au.com.tusc.session.StoreAccessDAO"
  |  *  impl-class="au.com.tusc.dao.StoreAccessDAOImpl"
  |  * 
  |  * @ejb.resource-ref res-ref-name="jdbc/DefaultDS"
  |  *  res-type="javax.sql.Datasource"
  |  *  res-auth="container"
  |  *
  |  * @jboss.resource-ref res-ref-name="jdbc/DefaultDS"
  |  *  jndi-name="java:/DefaultDS" 
  |  * 
  |  * @ejb.ejb-ref ejb-name="Customer"
  |  *  view-type="local"
  |  *  ref-name="CustomerLocal"
  |  * 
  |  * @jboss.ejb-ref-jndi ref-name="CustomerLocal"
  |  *  jndi-name="CustomerLocal"
  |  * 
  |  * @ejb.util generate="physical"
  |  * 
  | * <!-- end-xdoclet-definition --> 
  |  * @generated
  |  * 
  |  */
- CustomerBean.java
Note : The lomboz sections are generated automatically.
/**
  |  *
  |  * <!-- begin-user-doc --> You can insert your documentation for 
'<em><b>CustomerBean</b></em>'. <!-- end-user-doc --> *
  |  <!--  begin-lomboz-definition -->
  |  <?xml version="1.0" encoding="UTF-8"?>
  |  <lomboz:EJB xmlns:j2ee="http://java.sun.com/xml/ns/j2ee"; 
xmlns:lomboz="http://lomboz.objectlearn.com/xml/lomboz";>
  |  <lomboz:entity>
  |  <lomboz:entityEjb>
  |  <j2ee:display-name>Customer</j2ee:display-name>
  |  <j2ee:ejb-name>Customer</j2ee:ejb-name>
  |  <j2ee:ejb-class>au.com.tusc.bmp.CustomerBean</j2ee:ejb-class>
  |  <j2ee:persistence-type>Bean</j2ee:persistence-type>
  |  <j2ee:cmp-version>2.x</j2ee:cmp-version>
  |  <j2ee:abstract-schema-name>mySchema</j2ee:abstract-schema-name>
  |  </lomboz:entityEjb>
  |  <lomboz:tableName></lomboz:tableName>
  |  <lomboz:dataSourceName></lomboz:dataSourceName>
  |  </lomboz:entity>
  |  </lomboz:EJB>
  |  <!--  end-lomboz-definition -->
  |  *
  |  * <!-- begin-xdoclet-definition -->
  |  *
  |  *
  | 
  | 
  |  /**
  |  * @ejb.bean name="Customer"
  |  *  jndi-name="CustomerBean"
  |  *  type="BMP"
  |  * 
  |  * @ejb.dao class="au.com.tusc.bmp.CustomerDAO"
  |  *  impl-class="au.com.tusc.dao.CustomerDAOImpl"
  |  * 
  |  * @ejb.resource-ref res-ref-name="jdbc/DefaultDS"
  |  *  res-type="javax.sql.DataSource"
  |  *  res-auth="Container"
  |  * 
  |  * @jboss.resource-ref res-ref-name="jdbc/DefaultDS"
  |  *  jndi-name="java:/DefaultDS"
  |  * 
  |  * @ejb.util generate="physical"
  |  * 
  |  * <!-- end-xdoclet-defintion -->
  |  * @generated
  |  **/
 - Also, ejb-jar.xml is;
<?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><![CDATA[No Description.]]></description>
  |    <display-name>Generated by XDoclet</display-name>
  | 
  |    <enterprise-beans>
  | 
  |       <!-- Session Beans -->
  |       <session >
  |          <description><![CDATA[<!-- begin-user-doc --> A generated session 
bean <!-- end-user-doc --> * <!-- lomboz.beginDefinition --> <?xml 
version="1.0" encoding="UTF-8"?> <lomboz:EJB 
xmlns:j2ee="http://java.sun.com/xml/ns/j2ee"; 
xmlns:lomboz="http://lomboz.objectlearn.com/xml/lomboz";> <lomboz:session> 
<lomboz:sessionEjb> <j2ee:display-name>StoreAccess</j2ee:display-name> 
<j2ee:ejb-name>StoreAccess</j2ee:ejb-name> 
<j2ee:ejb-class>au.com.tusc.session.StoreAccessBean</j2ee:ejb-class> 
<j2ee:session-type>Stateless</j2ee:session-type> 
<j2ee:transaction-type>Container</j2ee:transaction-type> </lomboz:sessionEjb> 
</lomboz:session> </lomboz:EJB> <!-- lomboz.endDefinition --> <!-- 
begin-xdoclet-definition -->]]></description>
  | 
  |          <ejb-name>StoreAccess</ejb-name>
  | 
  |          <home>au.com.tusc.session.StoreAccessHome</home>
  |          <remote>au.com.tusc.session.StoreAccess</remote>
  |          <local-home>au.com.tusc.session.StoreAccessLocalHome</local-home>
  |          <local>au.com.tusc.session.StoreAccessLocal</local>
  |          <ejb-class>au.com.tusc.session.StoreAccessSession</ejb-class>
  |          <session-type>Stateless</session-type>
  |          <transaction-type>Container</transaction-type>
  | 
  |          <ejb-local-ref >
  |             <ejb-ref-name>ejb/CustomerLocal</ejb-ref-name>
  |             <ejb-ref-type>Entity</ejb-ref-type>
  |             <local-home>au.com.tusc.bmp.CustomerLocalHome</local-home>
  |             <local>au.com.tusc.bmp.CustomerLocal</local>
  |             <ejb-link>Customer</ejb-link>
  |          </ejb-local-ref>
  | 
  |          <resource-ref >
  |             <res-ref-name>jdbc/DefaultDS</res-ref-name>
  |             <res-type>javax.sql.Datasource</res-type>
  |             <res-auth>container</res-auth>
  |          </resource-ref>
  | 
  |       </session>
  | 
  |      <!--
  |        To add session beans that you have deployment descriptor info for, 
add
  |        a file to your XDoclet merge directory called session-beans.xml that 
contains
  |        the <session></session> markup for those beans.
  |      -->
  | 
  |       <!-- Entity Beans -->
  |       <entity >
  |          <description><![CDATA[<!-- begin-user-doc --> You can insert your 
documentation for '<em><b>CustomerBean</b></em>'.]]></description>
  | 
  |          <ejb-name>Customer</ejb-name>
  | 
  |          <home>au.com.tusc.bmp.CustomerHome</home>
  |          <remote>au.com.tusc.bmp.Customer</remote>
  |          <local-home>au.com.tusc.bmp.CustomerLocalHome</local-home>
  |          <local>au.com.tusc.bmp.CustomerLocal</local>
  | 
  |          <ejb-class>au.com.tusc.bmp.CustomerBMP</ejb-class>
  |          <persistence-type>Bean</persistence-type>
  |          <prim-key-class>au.com.tusc.bmp.CustomerPK</prim-key-class>
  |          <reentrant>False</reentrant>
  | 
  |          <resource-ref >
  |             <res-ref-name>jdbc/DefaultDS</res-ref-name>
  |             <res-type>javax.sql.DataSource</res-type>
  |             <res-auth>Container</res-auth>
  |          </resource-ref>
  | 
  |       </entity>
  | 
  |      <!--
  |        To add entity beans that you have deployment descriptor info for, add
  |        a file to your XDoclet merge directory called entity-beans.xml that 
contains
  |        the <entity></entity> markup for those beans.
  |      -->
  | 
  |       <!-- Message Driven Beans -->
  |      <!--
  |        To add message driven beans that you have deployment descriptor info 
for, add
  |        a file to your XDoclet merge directory called 
message-driven-beans.xml that contains
  |        the <message-driven></message-driven> markup for those beans.
  |      -->
  | 
  |    </enterprise-beans>
  | 
  |    <!-- Relationships -->
  | 
  |    <!-- Assembly Descriptor -->
  |    <assembly-descriptor >
  |      <!--
  |        To add additional assembly descriptor info here, add a file to your
  |        XDoclet merge directory called assembly-descriptor.xml that contains
  |        the <assembly-descriptor></assembly-descriptor> markup.
  |      -->
  | 
  |    <!-- finder permissions -->
  | 
  |    <!-- finder permissions -->
  | 
  |    <!-- transactions -->
  | 
  |    <!-- finder transactions -->
  |    </assembly-descriptor>
  | 
  | </ejb-jar>
- and jboss.xml is;
<?xml version="1.0" encoding="UTF-8"?>
  | <!DOCTYPE jboss PUBLIC "-//JBoss//DTD JBOSS 3.2//EN" 
"http://www.jboss.org/j2ee/dtd/jboss_3_2.dtd";>
  | 
  | <jboss>
  | 
  |    <unauthenticated-principal>nobody</unauthenticated-principal>
  | 
  |    <enterprise-beans>
  | 
  |      <!--
  |        To add beans that you have deployment descriptor info for, add
  |        a file to your XDoclet merge directory called jboss-beans.xml that 
contains
  |        the <session></session>, <entity></entity> and 
<message-driven></message-driven>
  |        markup for those beans.
  |      -->
  | 
  |       <entity>
  |          <ejb-name>Customer</ejb-name>
  |          <jndi-name>CustomerBean</jndi-name>
  |          <local-jndi-name>CustomerLocal</local-jndi-name>
  |          <resource-ref>
  |             <res-ref-name>jdbc/DefaultDS</res-ref-name>
  |             <jndi-name>java:/DefaultDS</jndi-name>
  |          </resource-ref>
  | 
  |         <method-attributes>
  |         </method-attributes>
  | 
  |       </entity>
  | 
  |       <session>
  |          <ejb-name>StoreAccess</ejb-name>
  |          <jndi-name>StoreAccessBean</jndi-name>
  |          <local-jndi-name>StoreAccessLocal</local-jndi-name>
  |          <ejb-local-ref>
  |             <ejb-ref-name>ejb/CustomerLocal</ejb-ref-name>
  |             <jndi-name>CustomerLocal</jndi-name>
  |          </ejb-local-ref>
  |          <resource-ref>
  |             <res-ref-name>jdbc/DefaultDS</res-ref-name>
  |             <jndi-name>java:/DefaultDS</jndi-name>
  |          </resource-ref>
  | 
  |         <method-attributes>
  |         </method-attributes>
  |       </session>
  | 
  |    </enterprise-beans>
  | 
  |    <resource-managers>
  |    </resource-managers>
  | 
  | </jboss>

jbosszone


View the original post : 
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3880255#3880255

Reply to the post : 
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=3880255


-------------------------------------------------------
This SF.Net email is sponsored by: NEC IT Guy Games.  How far can you shotput
a projector? How fast can you ride your desk chair down the office luge track?
If you want to score the big prize, get to know the little guy.  
Play to win an NEC 61" plasma display: http://www.necitguy.com/?r=20
_______________________________________________
JBoss-user mailing list
JBoss-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to