如何开发、调试和测试EJB3 APP?

如何开发、调试和测试EJB3APP?

1Install Eclipse + JBOSS IDE 2.0

2.官方的使用JBOSS IDE来开发EJB3 APP的教程还没出来(查看http://www.jboss.com/docs/trailblazer),所以只能用下列步骤

3.创建一个普通的java project,把我自己定义的“ejb library”加入到classpath里,同时把junit 4也添加到classpath

4.打开JBoss Server ViewwindowàShow ViewàOther..àJBoss Server View

5.在JBoss Server Viewcreate a jboss server,注意:选的server选项如下图:


<!--[if gte vml 1]><v:shape id="图片_x0020_7" o:spid="_x0000_i1027" type="#_x0000_t75" alt="pic1" style='width:325.5pt; height:242.25pt;visibility:visible;mso-wrap-style:square'> <v:imagedata src="file:///C:/DOCUME~1/bobo/LOCALS~1/Temp/msohtmlclip1/01/clip_image007.jpg" o:title="pic1" /> </v:shape><![endif]-->

创建完之后,JBoss Server View见下图:

<!--[if gte vml 1]><v:shape id="图片_x0020_8" o:spid="_x0000_i1026" type="#_x0000_t75" alt="http://java.chinaitlab.com/UploadFiles_8734/200707/20070712092918236.jpg" style='width:345.75pt;height:224.25pt;visibility:visible;mso-wrap-style:square'> <v:imagedata src="file:///C:/DOCUME~1/bobo/LOCALS~1/Temp/msohtmlclip1/01/clip_image008.jpg" o:title="20070712092918236" /> </v:shape><![endif]-->

6.如果是要调试的话,则选定server,然后click上图的debug button,如果是运行,则click run button

7.在project root folder下创建好build.xml,它非常重要,用于打包和copy打包的文件到jboss server deploy目录下(build.xml参看自己的ejb3 hello world project)。

8.然后如果要调试的话,就在build.xmloutline viewright click task,然后选择Debug AsàAnt Build(见下图),如果不是调试,则选择Run AsàAnt Build

<!--[if gte vml 1]><v:shape id="图片_x0020_9" o:spid="_x0000_i1025" type="#_x0000_t75" alt="http://java.chinaitlab.com/UploadFiles_8734/200707/20070712092918599.jpg" style='width:237pt;height:186pt;visibility:visible;mso-wrap-style:square'> <v:imagedata src="file:///C:/DOCUME~1/bobo/LOCALS~1/Temp/msohtmlclip1/01/clip_image009.jpg" o:title="20070712092918599" /> </v:shape><![endif]-->

9.进行Junit Test也很容易,但最关键的前提是还是需要先启动jboss server,然后把你的ejb jar发布到jboss里才可以进行junit test,因为ejb的调用离不开ejb container!!那么调用ejb的代码如下:

publicstaticObject getEJB(String jndipath) {

Properties props =newProperties();

props.setProperty("java.naming.factory.initial","org.jnp.interfaces.NamingContextFactory");

props.setProperty("java.naming.provider.url","localhost:1099");

props.setProperty("java.naming.factory.url.pkgs","org.jboss.naming:org.jnp.interfaces");

InitialContext ctx =newInitialContext(props);

ctx.lookup("HelloWorldBean/remote");

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值