------ Forwarded Message From: Bas Cancrinus <[EMAIL PROTECTED]> Organization: Cancrinus Groep B.V. Date: Sat, 02 Jun 2001 03:59:01 +0200 To: [EMAIL PROTECTED] Subject: My Tomcat-Jboss HOWTO Hi webmaster, I've had lots of problems configuring Tomcat to cooperate with Jboss and according to the list archives I'm not alone... The attached HOWTO is written to simplify this tedious task for future Tomcat-Jboss users and I'd really appreciate it if you could add it to the existing online Tomcat-documentation. Thanks a lot! Bas -- Bas E. Cancrinus <[EMAIL PROTECTED]> Product Manager RepTrack (TM) <http://www.reptrack.nl> Developer Cancrinus Search <http://www.csearch.nl> Tomcat - Jboss HOWTO Summary This document describes how you should configure Tomcat v3.2.2, and applications deployed within, if you want to operate on remote Enterprise JavaBeans deployed in Jboss v2.2.1 from these applications. It is assumed that your EJB's work well when you operate on them directly (i.e. from stand-alone apps or applets). Step 1: Configure Tomcat Your out-of-the-box Tomcat-distribution is almost ready for JBoss. You only have to add a RequestInterceptor to the chain of RequestInterceptors in the Interceptors-section of your <tomcat home>/conf/server.xml: <RequestInterceptor className="org.apache.tomcat.request.Jdk12Interceptor" /> Tomcat should not generate extra output during startup after this modification. Step 2: Configure your application There are many quick and dirty ways to make your application ready for Jboss, but in this section we try to play by the rules. This section defines 3 necessary activities: * Modify your <app home>/WEB-INF/web.xml * Distribute your Jboss client-libraries * Distribute your EJB home and remote interfaces * Modify your JSP/Servlet-code for remote EJB-operations Add the following code between the web-app tags of your <app home>/WEB-INF/web.xml: <context-param> <param-name>java.naming.factory.initial</param-name> <param-value>org.jnp.interfaces.NamingContextFactory</param-value> </context-param> <context-param> <param-name>java.naming.provider.url</param-name> <param-value>localhost:1099</param-value> </context-param> Copy the following libraries from <jboss home>/client/ to <app home>/WEB-INF/lib/: jboss-client.jar jbosssx-client.jar jnp_client.jar jta_spec1_0_1.jar Copy ejb.jar from <jboss home>/lib/ext/ to <app home>/WEB-INF/lib/ and copy the home and remote interface of all needed EJB's to <app home>/WEB-INF/classes/. Finally make sure that your JSP/Servlet code references the properties set in <app home>/WEB-INF/web.xml using the getServletContext().getInitParameter() method. The following code-snippet demonstrates how this method can be used in a JSP/Servlet: // Set properties Properties newProps = System.getProperties(); newProps.put ("java.naming.factory.initial", getServletContext().getInitParameter ("java.naming.factory.initial")); newProps.put ("java.naming.provider.url", getServletContext().getInitParameter ("java.naming.provider.url")); System.setProperties (newProps); AnEJB x = null; // Obtain a remote reference try { InitialContext jndiContext = new InitialContext(); Object ref = jndiContext.lookup("ejb/AnEJBHome"); AnEJBHome home = (AnEJBHome) PortableRemoteObject.narrow (ref, AnEJBHome.class); gocha = home.create(); } catch (Exception e) { System.err.println ("An exception occurred while obtaining a remote reference:"); System.err.println (e.toString()); } Bas Cancrinus <[EMAIL PROTECTED]> ------ End of Forwarded Message