facebook

How to create a session bean?

  1. MyEclipse IDE
  2.  > 
  3. General Development
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #203234 Reply

    sstrenn
    Member

    I must be doing something wrong. Whenever I follow the MyEclipse help on EJB Module and EJB creation, my session bean lacks a remote interface, and the home create method is returning the wrong data type. Thus, when I try to deploy, I get numerous errors from JBoss noting that my EJB methods do not throw RemoteException.

    Is it just me, or is the wizard messed up?

    #203246 Reply

    Scott Anderson
    Participant

    Is it just me, or is the wizard messed up?

    That remains to be determined. 😉

    Creating a deployable EJB is really a multi-step process. After you run the wizard you should have only one class file, your bean class. You then configure XDoclet to generate your home and remote interfaces for you when XDoclet is run. However, the XDoclet configuration can be a bit tricky if you haven’t used it extensively. Did you try the example in the help verbatim? Exactly the same project, bean name, property settings, etc? The reason I ask is that you’ll only get a remote interface generated when you specify the @ejb.interface-method tag on each of the methods that makes up the interface.

    #205505 Reply

    mailsam
    Member

    I am in a similar situation.

    I have created a session bean class and have specified the @ejb.interface-method tag for the method as shown below.

    /**
    * An example business method
    *
    * @ejb.interface-method view-type = “remote”
    *
    * @throws EJBException Thrown if the instance could not perform
    * the function requested by the container because of an system-level error.
    */

    But when I run XDoclet it only generates a HomeInterface. The jboss deployment descriptor looks like:
    <session>
    <ejb-name>LoginSessionBean</ejb-name>
    <jndi-name>ejb/LoginSessionBeanHome</jndi-name>

    </session>

    Am I missing something?

    #205510 Reply

    support-michael
    Keymaster

    I consulted our TraderX XDoclet demo and here is a fragment of the bean class javadoc:

    * @ejb.bean name = "Trader"
     *           type = "Stateless"
     *           display-name = "Trader"
     *           description = "Trader EJB"
     *           view-type = "both"
     *           jndi-name = "ejb/com/genuitec/trader/ejb/TraderHome"

    The view-type = “both” will generate both local and remote homes.

    Following is a business method on my bean class.

        /**
         * Buys shares of a stock for a named customer.
         *
         * @param customerName      String Customer name
         * @param stockSymbol       String Stock symbol
         * @param shares            int Number of shares to buy
         * @return                  TradeResult Trade Result
         *                          if there is an error while buying the shares
         * 
         * @ejb.interface-method 
         */
        public TradeResult buy(String stockSymbol, int shares) {

    Does this help?

    #236334 Reply

    What next ???

    #236379 Reply

    Greg
    Member

    You can see how to access a session bean from a web application by downloading the source code to the entire TraderX Enterprise Application from the EAR Development quickstart:
    http://www.myeclipseide.com/images/tutorials/quickstarts/earprojects/

    In the resources section, you will see a download of the traderx_src.zip.

Viewing 6 posts - 1 through 6 (of 6 total)
Reply To: How to create a session bean?

You must be logged in to post in the forum log in