java的组件框架之类的玩意貌似经常变...
版本升级了就不兼容,,,,
学了又学....杯具...
就想EJB貌似出很多新版了,,我还是得学以前的旧版本.
注:Jboss 4.2.3
运行jboss -> \jboss\jboss-4.2.3.GA-jdk6\jboss-4.2.3.GA\bin\run.bat
把工程导出jar,并把文件复制去-> \jboss\jboss-4.2.3.GA-jdk6\jboss-4.2.3.GA\server\default\deploy
源码参考ejb.zip
//Cat.java package com.memorycat.ebj; public interface Cat { public void eat(); }
//CatBean.java package com.memorycat.ebj; import java.util.logging.Logger; import javax.ejb.Remote; import javax.ejb.Stateless; @Stateless @Remote(Cat.class) public class CatBean implements Cat { @Override public void eat() { // TODO Auto-generated method stub Logger.getLogger(this.getClass().getName()).info("MemoryCat likes fishes"); } }
//CatClient.java package com.memorycat.ebj.client; import javax.naming.InitialContext; import javax.naming.NamingException; import com.memorycat.ebj.Cat; public class CatClient { public static void main(String[] args) throws NamingException { InitialContext ctx = new InitialContext(); Cat cat = (Cat) ctx.lookup("CatBean/remote"); cat.eat(); } }
//jndi.properties java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory java.naming.provider.url=localhost:1099
jboss下载地址
http://sourceforge.net/projects/jboss/files/JBoss/JBoss-4.2.3.GA/