搜档网
当前位置:搜档网 › ant打ear包的详细步骤

ant打ear包的详细步骤

ant打ear包的详细步骤

用一个简单的ejb3.0示例记录ant打ear包的过程

源码下载

环境:
apache-ant-1.6.5
jboss-4.2.1.GA
jboss-annotations-ejb3.jar
jboss-ejb3.jar
jboss-ejb3x.jar
最后三个包在jboss里有.

1,建ejb3.0项目
session bean接口:HelloWorld
public interface HelloWorld {
public String sayHello(String name);
}

实现类:HelloWorldBean

@Stateless
@Remote ({HelloWorld.class})
public class HelloWorldBean implements HelloWorld {
public String sayHello(String name) {
//https://www.sodocs.net/doc/c15896774.html,mons.collections,这里假设用到了其它包中的类
CollectionUtils c=new CollectionUtils();
//https://www.sodocs.net/doc/c15896774.html,ng
StringUtils s=new StringUtils();
return "hello,i am "+name;
}
}

调用session bean的jsp:


<%
//https://www.sodocs.net/doc/c15896774.html,mons.collections,这里假设用到了其它包中的类
CollectionUtils c=new CollectionUtils();
//https://www.sodocs.net/doc/c15896774.html,ng
StringUtils s=new StringUtils();
%>
<%
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("myproject/HelloWorldBean/remote");
out.println(helloworld.sayHello("mashiguang"));
} catch (NamingException e) {
out.println(e.getMessage());
}
%>


2,ant示例


把一些公用的jar包都放到ear下,而不是分别在ejb jar包和war包里,减少jar包的冗余.






















































































https://www.sodocs.net/doc/c15896774.html,/java/200712/157920.shtml

相关主题