JBoss4.0.5GA+EJB3

Recently I always used the Spring+Hibernate+Struts frameworks to persist data into db,
But EJB3 is the standard spec of J2EE,so try to migrate JBoss4.0.5GA J2EE container to study EJB3.
Install:
1.JBoss4.0.5GA(download it ok,then unzip it in a folder)    http://jboss.org
2.Obtain the EJB3 for JBoss4.0.5GA patch, http://labs.jboss.com/portal/jbossejb3/download/index.html

3.according to the EJB3 install patch:
$ cd jboss-EJB-3.0_RC9-FD-patch1
$ ant -f install.xml -Djboss.server.config=all

4.then Run the server use below command:   
$cd jboss\bin
$ run -c all

5.Now it's time to put down your ejb3 and test codes.
for explain the progress,all the codes are very simple(stateless session bean).
EBJ3:
interface
package com.aaron.ejb3
public interface HelloWorld {
    public String SayHello(String name);
}
implement
package com.aaron.ejb3
import javax.ejb.Remote;
import javax.ejb.Stateless;

@Stateless
@Remote ({HelloWorld.class})
public class HelloWorldBean implements HelloWorld {

    public String SayHello(String name) {       
        return name +"say:Hello world this is the first EJB3";
    }

}

Write a jsp for test the EJB3:

<%@ page contentType="text/html; charset=GB2312"%>
<%@ page import="package com.aaron.ejb3.HelloWorld, javax.naming.*, java.util.Properties"%>
<%
  Properties props = new Properties();
  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"); 

  InitialContext ctx;
  try {
   ctx = new InitialContext(props);
   HelloWorld helloworld = (HelloWorld) ctx.lookup("HelloWorldBean/remote");
   out.println(helloworld.SayHello("Aaron"));
  } catch (NamingException e) {
   out.println(e.getMessage());
  }
%>

6.Deploy the EJB3 and jsp
compile the EJB3 and package it for jar file,
and create a web structure including the above jsp file.
Run the jsp file.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值