|
Page Edited :
OPENEJB :
New Instructions
New Instructions has been edited by Dain Sundstrom (Sep 20, 2007). Change summary: work in progress... Install and run Tomcat 6Tomcat 5.x is not supported due to classloading differences and the lack of annotation processing support. On Unix platforms (Linux, MacOSX): $ chmod u+x bin/*.sh On all platforms: the following instructions assume running Tomcat using the bin/catalina.sh or bin/catalina.bat scripts and not running as a service, a daemon or an IDE plugin.
Test an example applicationCreate a stateless session beanCreate an interfacepackage org.acme; import javax.ejb.*; @Remote public interface Greeting{ public String greet(); } Create the bean classpackage org.acme; import javax.ejb.*; @Stateless public class GreetingBean implements Greeting{ public String greet(){ return "I just greeted you buddy"; } } Create a servletpackage org.acme; import javax.servlet.*; import javax.servlet.http.*; import javax.naming.*; import java.io.*; import java.util.*; public class TestServlet extends HttpServlet{ public void doGet(HttpServletRequest request, HttpServletResponse response){ try{ response.setContentType("text/html"); PrintWriter writer = response.getWriter(); Properties p = new Properties(); p.put("java.naming.factory.initial","org.apache.openejb.client.LocalInitialContextFactory"); InitialContext ctx = new InitialContext(p); Greeting g = (Greeting)ctx.lookup("GreetingBeanBusinessRemote"); writer.print(g.greet()); }catch(Exception e){ e.printStackTrace(); } } } Register the servlet in web.xml<?xml version="1.0" encoding="ISO-8859-1"?> <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd"> <web-app> <display-name>Test Application</display-name> <servlet> <servlet-name>TestServlet</servlet-name> <servlet-class>org.acme.TestServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>TestServlet</servlet-name> <url-pattern>/test</url-pattern> </servlet-mapping> </web-app> Package the warCompile the above classes into the WEB-INF/classes directory and package everything into testweb.war (or a file name of your liking) Drop the war in the tomcat webapps directoryDrop the testweb.war in the tomcat webapps directory Send a request to the servlet#Open the browser [OPTIONAL] Run OpenEJB iTestsInstall iTestsSimply copy the OpenEJB iTests war to the Tomcat webapp directory. apache-tomcat-6.0.14$ cp openejb-tomcat-3.0.0-SNAPSHOT-itests.war webapps/ Start Tomcatapache-tomcat-6.0.14$ bin/startup.sh Using CATALINA_BASE: /your/tomcat/installation/apache-tomcat-6.0.14 Using CATALINA_HOME: /your/tomcat/installation/apache-tomcat-6.0.14 Using CATALINA_TMPDIR: /your/tomcat/installation/apache-tomcat-6.0.14/temp Using JRE_HOME: /your/java/installation NOTE: Your output will be different from the example above due to differences in installation location. Execute the test client$ java -Dtomcat.home=. -Dremote.servlet.url="" -jar openejb-tomcat-3.0.0-SNAPSHOT-test.jar tomcat _________________________________________________ |_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_| Running EJB compliance tests on HTTP/Tomcat Server _________________________________________________ WARNING: No test suite configuration file specified, assuming system properties contain all needed information. To specify a test suite configuration file by setting its location using the system property "openejb.testsuite.properties" test server = org.apache.openejb.test.TomcatRemoteTestServer entry = java.naming.provider.url:http://127.0.0.1:8080/openejb/remote entry = java.naming.factory.initial:org.apache.openejb.client.RemoteInitialContextFactory ......................................... ......................................... ......................................... ......................................... ......................................... ......................................... ......................................... ......................................... ......................................... ......................................... ......................................... ......................................... ......................................... ......................................... ......................................... ......................................... ......................................... ......................................... ......................................... ......................................... ......................................... ........................ Time: 10.853 OK (885 tests) _________________________________________________ CLIENT JNDI PROPERTIES java.naming.provider.url = "" java.naming.factory.initial = org.apache.openejb.client.RemoteInitialContextFactory _________________________________________________
|
Unsubscribe or edit your notifications preferences
