1 Reply Latest reply on Aug 29, 2002 9:38 AM by lepekhine

    I have a Entity Bean ? How to write ejb-jar.xml?

    lzhlzh

      //MusicCDHome.java

      package com.whaic.music;

      import java.rmi.RemoteException;
      import javax.ejb.*;


      public interface MusicCDHome extends EJBHome {
      public MusicCD create(String upc)
      throws CreateException, RemoteException;
      public MusicCD findByPrimaryKey(String pk)
      throws FinderException, RemoteException;
      }

      //MusicCDBean.java

      package com.whaic.music;

      import java.rmi.RemoteException;
      import javax.ejb.*;


      public interface MusicCDHome extends EJBHome {
      public MusicCD create(String upc)
      throws CreateException, RemoteException;
      public MusicCD findByPrimaryKey(String pk)
      throws FinderException, RemoteException;
      }


      //MusicCD.java
      package com.whaic.music;

      import java.rmi.RemoteException;
      import javax.ejb.*;


      public interface MusicCD extends EJBObject {
      public String getTitle() throws RemoteException;
      public void setTitle(String title) throws RemoteException;

      public String getArtist() throws RemoteException;
      public void setArtist(String artist) throws RemoteException;

      public String getType() throws RemoteException;
      public void setType(String type) throws RemoteException;

      public float getPrice() throws RemoteException;
      public void setPrice(float price) throws RemoteException;
      }

      //ejb-jar.xml

      <?xml version="1.0"?>

      <!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 1.1//EN" "http://java.sun.com/j2ee/dtds/ejb-jar_1_1.dtd">

      <ejb-jar>
      <display-name>MusicCDEJB</display-name>
      <enterprise-beans>

      Models a MusicCD
      <ejb-name>MusicCDBean</ejb-name>
      com.whaic.music.MusicCDHome
      com.whaic.music.MusicCD
      <ejb-class>com.whaic.music.MusicCDBean</ejb-class>
      <persistence-type>Container</persistence-type>
      <prim-key-class>java.lang.String</prim-key-class>
      False

      <cmp-field><field-name>upc</field-name></cmp-field>
      <cmp-field><field-name>title</field-name></cmp-field>
      <cmp-field><field-name>artist</field-name></cmp-field>
      <cmp-field><field-name>type</field-name></cmp-field>
      <cmp-field><field-name>price</field-name></cmp-field>

      </enterprise-beans>

      <assembly-descriptor>
      <container-transaction>

      <ejb-name>MusicCDBean</ejb-name>
      <method-name>*</method-name>

      <trans-attribute>Required</trans-attribute>
      </container-transaction>
      </assembly-descriptor>
      </ejb-jar>





      1¡¢what should I want?

      2¡¢what's difference between CMP1.0 and CMP2.0?

      3¡¢where can I find some examples on program on this net?

        • 1. Re: I have a Entity Bean ? How to write ejb-jar.xml?
          lepekhine

          Hi lzhlzh!
          You are in the beginning of a long way...
          First of all you should write EJB java files
          without any errors. You have a lot of them...
          Then you should write not only ejb-jar.xml,
          but some other configuration xml files for
          application server. For JBoss they are:
          jboss.xml, jboss-security.xml etc.
          It is very hard to write all of them without
          errors. To facilitate this task XDoclet exists.
          (go to http://sourceforge.net/projects/xdoclet and see).
          XDoclet allows you to write only one file - EJB bean,
          all others will be produced automatically.
          When you got all of them you should pack them into
          jar and deploy it to the application server.
          And even after successful deployment you will get
          nothing until you write some programs for using EJB.
          They may be client program or web components.
          Web components need their own descriptors, which
          also can be produced with XDoclet.
          So the short answer to the first question is XDoclet.
          For the second and 3rd - go to http://java.sun.com
          and see documentation, examples and tutorials
          - this is the simplest way.
          Wish you success, Alexander