- OpenEJB - Hello world
- 日常茶飯事
- 2011. 12. 6. 06:42
- http://openejb.apache.org/hello-world.html
openejb-3.1.4_hello> set OPENEJB_HOME=D:/java/openejb/openejb-3.1.4
openejb-3.1.4_hello> set JAVA_HOME=C:\Program Files\Java\jdk1.6.0_26
openejb-3.1.4_hello> set path=%path%;%openejb_home%/bin;%java_home%/bin
openejb-3.1.4_hello> set JAVA_HOME=C:\Program Files\Java\jdk1.6.0_26
openejb-3.1.4_hello> set path=%path%;%openejb_home%/bin;%java_home%/bin
package org.acme; import javax.ejb.Remote; @Remote public interface Hello{ public String sayHello(); }
package org.acme; import javax.ejb.Stateless; @Stateless public class HelloBean implements Hello{ public String sayHello(){ return "Hello World!!!!"; } }
openejb-3.1.4_hello> javac -cp %OPENEJB_HOME%/lib/javaee-api-5.0-3.jar -d . *.java
openejb-3.1.4_hello> jar cvf hello.jar org
추가된 manifest
추가 중: org/(내부 = 0) (외부= 0)(0%가 저장되었습니다.)
추가 중: org/acme/(내부 = 0) (외부= 0)(0%가 저장되었습니다.)
추가 중: org/acme/Hello.class(내부 = 203) (외부= 168)(17%가 감소되었습니다.)
추가 중: org/acme/HelloBean.class(내부 = 383) (외부= 274)(28%가 감소되었습니다.)
openejb-3.1.4_hello> jar cvf hello.jar org
추가된 manifest
추가 중: org/(내부 = 0) (외부= 0)(0%가 저장되었습니다.)
추가 중: org/acme/(내부 = 0) (외부= 0)(0%가 저장되었습니다.)
추가 중: org/acme/Hello.class(내부 = 203) (외부= 168)(17%가 감소되었습니다.)
추가 중: org/acme/HelloBean.class(내부 = 383) (외부= 274)(28%가 감소되었습니다.)
package org.acme; import java.util.Properties; import javax.naming.InitialContext; import javax.naming.Context; import javax.rmi.PortableRemoteObject; public class HelloClient{ public static void main(String[] args) throws Exception{ Properties props = new Properties(); props.put(Context.INITIAL_CONTEXT_FACTORY,"org.apache.openejb.client.RemoteInitialContextFactory"); props.put(Context.PROVIDER_URL,"ejbd://127.0.0.1:4201"); Context ctx = new InitialContext(props); Object ref = ctx.lookup("HelloBeanRemote"); Hello h = (Hello)PortableRemoteObject.narrow(ref,Hello.class); String result = h.sayHello(); System.out.println(result); } }
openejb-3.1.4_hello> javac -d . HelloClient.java
openejb-3.1.4_hello> start %OPENEJB_HOME%/bin/openejb start
Apache OpenEJB 3.1.4 build: 20101112-03:32
http://openejb.apache.org/
log4j:WARN No appenders could be found for logger (org.apache.openejb.resource.activemq.ActiveMQResourceAdapter).
log4j:WARN Please initialize the log4j system properly.
[init] OpenEJB Remote Server
** Starting Services **
NAME IP PORT
httpejbd 127.0.0.1 4204
admin thread 127.0.0.1 4200
ejbd 127.0.0.1 4201
ejbd 127.0.0.1 4203
hsql 127.0.0.1 9001
telnet 127.0.0.1 4202
-------
Ready!
Apache OpenEJB 3.1.4 build: 20101112-03:32
http://openejb.apache.org/
log4j:WARN No appenders could be found for logger (org.apache.openejb.resource.activemq.ActiveMQResourceAdapter).
log4j:WARN Please initialize the log4j system properly.
[init] OpenEJB Remote Server
** Starting Services **
NAME IP PORT
httpejbd 127.0.0.1 4204
admin thread 127.0.0.1 4200
ejbd 127.0.0.1 4201
ejbd 127.0.0.1 4203
hsql 127.0.0.1 9001
telnet 127.0.0.1 4202
-------
Ready!
openejb-3.1.4_hello> %OPENEJB_HOME%/bin/openejb deploy hello.jar
Application deployed successfully at "hello.jar"
App(id=D:\resources\programs\java\openejb\openejb-3.1.4\apps\hello.jar)
EjbJar(id=hello.jar, path=D:\resources\programs\java\openejb\openejb-3.1.4\apps\hello.jar)
Ejb(ejb-name=HelloBean, id=HelloBean)
Jndi(name=HelloBeanRemote)
Application deployed successfully at "hello.jar"
App(id=D:\resources\programs\java\openejb\openejb-3.1.4\apps\hello.jar)
EjbJar(id=hello.jar, path=D:\resources\programs\java\openejb\openejb-3.1.4\apps\hello.jar)
Ejb(ejb-name=HelloBean, id=HelloBean)
Jndi(name=HelloBeanRemote)
openejb-3.1.4_hello> java -cp %OPENEJB_HOME%/lib/openejb-client-3.1.4.jar;%OPENEJB_HOME%/lib/javaee-api-5.0-3.jar;. org.acme.HelloClient
Hello World!!!!
Hello World!!!!
Recent comment