在eclipse中使用JBossIDE和xDoclet创建EJB

本文详细介绍了EJB项目在JBoss和Oracle环境下的搭建与部署过程。包括创建EJB模块和EJB、配置xDoclet、创建数据源映射、编辑源代码、运行xDoclet生成文件、设置打包配置、运行打包、复制驱动文件、启动JBoss服务器以及部署项目等步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1. create EJB module(lomboz)
2. create EJB (JBoss): package must end with: .ejb
3. Config xDoclet(eclipse project properties)
  1. add standard-->standard EJB-->ejb doclet
  2. right click ejbdoclet and select jboss
    set version: 4.0
    set datasource: java:/tutorial
    set datasourcemapping: Oracle9i( look up D:/j2ee/jboss-4.0.1/server/default/conf/standardjbosscmp-jdbc.xml for it)
    set destDir: simpleejb/META-INF/ (where the the jboss.xml and jbosscmp-jdbc.xml will create)
  3. select home, interface,remoteinterface,localhome and select destdir
  4. entitypk: set destdir to simpleejb/src 
  5. set fileset
   
  3. click ok
 
4. create datasource mapping
  1. copy jdbc driver to: D:/j2ee/jboss-4.0.1/server/default/lib
  2. create table
  3. find D:/j2ee/jboss-4.0.1/docs/examples/jca/oracle-ds.xml and copy it to D:/j2ee/jboss-4.0.1/server/default/deploy
  4. update it like below:
   <datasources>
   <local-tx-datasource>
     <jndi-name>HeliumDS</jndi-name>
     <connection-url>jdbc:oracle:thin:@192.168.0.109:1521:labdb</connection-url>
     <driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
     <user-name>helium</user-name>
     <password>helium</password>
     <!-- Uses the pingDatabase method to check a connection is still valid before handing it out from the pool -->
     <!--valid-connection-checker-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleValidConnectionChecker</valid-connection-checker-class-name-->
     <!-- Checks the Oracle error codes and messages for fatal errors -->
     <exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter</exception-sorter-class-name>
 
       <!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml (optional) -->
       <metadata>
          <type-mapping>Oracle9i</type-mapping>
       </metadata>
   </local-tx-datasource>
 
 </datasources>
5. edit source code
  1. find /**
        *@ejb.bean...
  replace it with:
/**
 * @ejb.bean name="SimpleEntity"
 *           display-name="Name for SimpleEntity"
 *           description="Description for SimpleEntity"
 *           jndi-name="ejb/SimpleEntityHome"
 *           type="CMP"
 *           cmp-version="2.x"
 *           view-type="both"
 *        local-jndi-name = "ejb/SimpleEntityLocalHome"
 *           primkey-field = "domainid"
 *  @ejb.persistence table-name = "domain"
 *  @jboss.persistence table-name = "domain"
 *  @ejb:util
 *       generate="physical"      
 *
 */

 2. for each field, add code like:
 
 /**       
  *  @ejb.interface-method view-type = "both"        
  *  @ejb.persistence column-name = "domainid"        
  *  @ejb.pk-field        
  *  @return        
  */
  public abstract String getDomainId();       
 
 /**     
  *     @ejb.interface-method view-type = "both"        
  *           @param name
  *
  */        
    public abstract void setDomainId(String id);       
 
     /**         
     * @ejb.interface-method view-type = "both"        
     *  @ejb.persistence column-name = "name"        
     *  @return        
     */       
    public abstract String getName();   
   
    /**          @ejb.interface-method view-type = "both"
     *          @param name        
     */       
   
    public abstract void setName(String name); 
   
3. right click project bar and select run xDoclet. Two files are generated: jboss.xml and jbosscmp-jdbc.xml
4. setup packaging configuration: addstandard-->select EJB-->select destDir
5. run packaging
6. copy classes12.jar to D:/j2ee/jboss-4.0.1/server/default/lib
6. JBoss launcher
   1. go into debug...
   2. select jboss4.0.X
   3. put project into source
   4. run the server
7. deploy the project

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值