- 
        1. Re: I need a single examplejasonbrome Aug 19, 2002 5:35 PM (in response to sheldon)Have you read through the JBoss 3.0 quickstart docs yet? 
 http://www.jboss.org/docs/#free-30x
 If you have, what particular problems were you having?
- 
        2. Re: I need a single exampletorreblanca Aug 20, 2002 3:13 PM (in response to sheldon)Sheldon, 
 Here is the procedure for JSPs :
 1. Write the JSP
 Example (uno.jsp) :
 <%@ page import="java.text.*,
 java.util.*"%>
 <%
 Date d = new Date();
 String hoy = DateFormat.getDateInstance().format(d);
 %>
 La Fecha de hoy es :
 <%= hoy %>
 2. Create a WAR file with JSP file. Use the following command :
 jar -cvfM uno.war uno.jsp
 3. Create an application.xml file in META-INF directory. You need set the correct values in <web-uri> tag and <context-root> tag.
 web-uri = WAR name file
 Example (application.xml):
 <?xml version="1.0" encoding="ISO-8859-1"?>
 <display-name>uno</display-name>
 <web-uri>uno.war</web-uri>
 <context-root>/uno</context-root>
 4. Create a EAR file with WAR file and application.xml file. Use the following command :
 jar -cvfM uno.ear uno.war META-INF
 5. Copy this EAR file in %JBOSS_HOME%\server\default\deploy
 6. Run the JBoss-Tomcat server.
 7. Test the JSP. Use the following URL:
 http://[IP ADDRESS SERVER]:8080/uno/uno.jsp
 The first time is slow because JBoss-Tomcat compiles the JSP file but the next time is fast.
 HERE IS THE PROCEDURE FOR SERVLETS :
 1. Write your servlet. For example
 Dos.java
 package com.servlet;
 import java.io.*;
 import javax.servlet.*;
 import javax.servlet.http.*;
 public class Dos extends HttpServlet {
 public void doGet(HttpServletRequest request,
 HttpServletResponse response)
 throws ServletException, IOException {
 PrintWriter out = response.getWriter();
 out.println("Hello World");
 }
 }
 2. Compile your servlet. Use the following command :
 javac -classpath d:\jboss-3.0.1_Tomcat-4.0.4\catalina\common\lib\servlet.jar Dos.java
 3. Create a WEB-INF directory.
 4. Create a classes directory in WEB-INF directory and copy Dos.class.
 WEB-INF (Subdirectory)
 I
 I
 classes (Subdirectory) ---
 I
 I
 com (subdirectory)----
 I
 I
 servlet (subdirectory)
 I
 I
 Dos.class (Java Class)
 5. Create a web.xml file in WEB-INF directory.
 For example:
 <?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>
 <servlet-name>Dos</servlet-name>
 <servlet-class>com.servlet.Dos</servlet-class>
 </web-app>
 6. Create a META-INF directory.
 7. Create an application.xml file in META-INF directory.
 For example:
 application.xml
 <?xml version="1.0" encoding="ISO-8859-1"?>
 <display-name>dos</display-name>
 <web-uri>dos.war</web-uri>
 <context-root>/dos</context-root>
 8. Create a WAR file. Use the following command :
 jar -cvfM dos.war WEB-INF
 9. Create a EAR file. Use the following command :
 jar -cvfM dos.ear dos.war META-INF
 10. Copy the EAR file in %JBOSS_HOME%\server\default\deploy
 11. Run the JBoss-Tomcat server.
 12. Test the Servlet. Use the following URL:
 http://[IP ADDRESS SERVER]:8080/dos/servlet/Dos
 Regards
 Javier
- 
        3. Re: I need a single exampletorreblanca Aug 20, 2002 3:15 PM (in response to sheldon)Sheldon 
 I send you in attachment the following files :
 uno.ear (JSP example)
 dos.ear (Servlet example)
 Test it.
 Regards
 Javier
- 
        4. Re: I need a single exampleskydive Aug 22, 2002 10:44 AM (in response to sheldon)Thank you very much, it worked perfectly. 
- 
        5. Re: I need a single examplebakul Aug 23, 2002 3:23 PM (in response to sheldon)Is there any example which shows how to write and deploy Session and Entity Beans, Clients, configure Datasources etc. for JBoss3. I couldn't find any examples shipped with the server and the Getting started docs doesn't contain nay information on EJBs. Those chapters are empty. 
 I have my own EJB jar files but I need to know what extra to do deploy my jar files on JBoss, what files I need to put where and what to put in the classpath.
 Thanks
 Bakul
- 
        6. Re: I need a single exampletomyang Aug 25, 2002 1:40 AM (in response to sheldon)Hi all: 
 I followd Torreblanca's instruction exactly (actually, I copied and pasted his example for the jsp page uno.jsp), but when I load the page from the Web browser, I got the error message:
 type Status report
 message No Context configured to process this request
 description The server encountered an internal error (No Context configured to process this request) that prevented it from fulfilling this request.
 Can someone please help me to figure out what is wrong? Thank you very much in advance!
 Tom
- 
        7. Re: I need a single exampletomyang Aug 25, 2002 4:49 PM (in response to sheldon)Hi all: 
 I got the answer to my question. I forgot to include the servlet.jar in my CLASSPATH. Thanks all the for help in the posting.
 Tom
- 
        8. Re: I need a single exampletorreblanca Aug 28, 2002 2:39 PM (in response to sheldon)Bakul, 
 I followed the "Mastering Enterprise JavaBeans" (Ed Roman) book examples. The examples are working in JBoss-3.0.1_Tomcat-4.0.4. I only changed the xml configuration files. The EAR, WAR and JAR structure file is very important to deploy applications.
 You can get free this e-book at :
 http://www.theserverside.com/books/masteringEJB/index.jsp
 In this reply I explain a Session Stateless Session bean and in other replies I will send you examples of Stateful Session bean, Bean-Managed Persistent Entity Bean, Container-Managed Persistent Entity Bean and Message-driven bean.
 I need to prepare every document, let me a little time.
 ________________________________________
 Stateless Session Bean
 This Stateless Session bean example shows the date.
 1. Create the following files : PrimerEJB.java, PrimerHome.java and Primer.java at
 [drive]:\examples\src
 Source of PrimerEJB.java
 __________________________________________________
 package com.ejb1;
 import javax.ejb.SessionBean;
 import javax.ejb.EJBException;
 import javax.ejb.SessionContext;
 import java.rmi.RemoteException;
 import java.util.Date;
 public class PrimerEJB implements SessionBean {
 public String recuperaTiempo() {
 return "La fecha es : " + new Date().toString();
 }
 public void ejbCreate() {}
 public void ejbPassivate() {}
 public void ejbActivate() {}
 public void ejbRemove() {}
 public void setSessionContext(SessionContext context) {}
 }
 _________________________________________________
 The recuperaTiempo method retrieves the date.
 Source of PrimerHome.java
 ________________________________________________
 package com.ejb1;
 import javax.ejb.EJBHome;
 import javax.ejb.CreateException;
 import java.rmi.RemoteException;
 import com.ejb1.Primer;
 public interface PrimerHome extends EJBHome {
 public Primer create() throws CreateException, RemoteException;
 }
 ________________________________________________
 Source of Primer.java
 ________________________________________________
 package com.ejb1;
 import javax.ejb.EJBObject;
 import java.rmi.RemoteException;
 public interface Primer extends EJBObject {
 public String recuperaTiempo() throws RemoteException;
 }
 ________________________________________________
 2. Compile PrimerEJB.java, PrimerHome.java and Primer.java in [drive]:\examples\src.
 javac -d d:\examples\src -classpath %classpath%;.;d:\examples\src;d:\jboss-3.0.1_Tomcat-4.0.4\client\jboss-j2ee.jar *.java
 3. The before step creates the following directory structure:
 [drive]:\examples\src\com\ejb1\PrimerEJB.class
 [drive]:\examples\src\com\ejb1\PrimerHome.class
 [drive]:\examples\src\com\ejb1\Primer.class
 4. Create the jsp (primerEJB.jsp)
 Source of primerEJB.jsp
 ____________________________________________________________
 <%@ page import="javax.naming.InitialContext,
 javax.naming.Context,
 java.util.Properties,
 com.ejb1.Primer,
 com.ejb1.PrimerHome"%>
 <%
 long t1 = System.currentTimeMillis();
 Properties props = new Properties();
 props.put(Context.INITIAL_CONTEXT_FACTORY,
 "org.jnp.interfaces.NamingContextFactory");
 props.put(Context.PROVIDER_URL, "13.134.79.127:1099");
 Context ctx = new InitialContext(props);
 PrimerHome home = (PrimerHome)ctx.lookup("ejb/Primer");
 Primer bean = home.create();
 String time = bean.recuperaTiempo();
 bean.remove();
 ctx.close();
 long t2 = System.currentTimeMillis();
 %>
 p { font-family:Verdana;font-size:12px; }
 Mensaje recibido del bean = "<%= time %>".Tiempo transcurrido :
 <%= (t2 - t1) %> ms.
 _________________________________________________________
 You need to change the following line:
 props.put(Context.PROVIDER_URL, "13.134.79.127:1099");
 change to your IP ADDRESS JBOSS_TOMCAT SERVER :
 props.put(Context.PROVIDER_URL, "[IP ADDRESS SERVER]:1099");
 5. Create ejb-jar.xml in [drive]:\examples\src\META-INF
 Source of ejb-jar.xml
 _______________________________________________________
 <?xml version="1.0"?>
 <!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems,
 Inc.//DTD Enterprise JavaBeans 2.0//EN"
 "http://java.sun.com/dtd/ejb-jar_2_0.dtd">
 <ejb-jar>
 <enterprise-beans>
 <display-name>PrimerEJB</display-name>
 <ejb-name>Primer</ejb-name>
 com.ejb1.PrimerHome
 com.ejb1.Primer
 <ejb-class>com.ejb1.PrimerEJB</ejb-class>
 <session-type>Stateless</session-type>
 <transaction-type>Bean</transaction-type>
 </enterprise-beans>
 </ejb-jar>
 ________________________________________________________
 6. Create jboss.xml in [drive]:\examples\src\META-INF
 Source of jboss.xml
 _______________________________________________________
 <?xml version='1.0' encoding='UTF-8' ?>
 <!DOCTYPE jboss PUBLIC "-//JBoss//DTD JBOSS//EN"
 "http://www.jboss.org/j2ee/dtd/jboss.dtd">
 <enterprise-beans>
 <ejb-name>Primer</ejb-name>
 <jndi-name>ejb/Primer</jndi-name>
 </enterprise-beans>
 _______________________________________________________
 The value in <jndi-name> tag is equal to the following line used in primerEJB.jsp :
 PrimerHome home = (PrimerHome)ctx.lookup("ejb/Primer");
 7. Create [drive]:\examples\src\WEB-INF\classes and then copy the EJB classes with their package structure (PrimerEJB.class, PrimerHome.class and Primer.class).
 the result is :
 [drive]:\examples\src\WEB-INF\classes\com\ejb1\PrimerEJB.class
 [drive]:\examples\src\WEB-INF\classes\com\ejb1\PrimerHome.class
 [drive]:\examples\src\WEB-INF\classes\com\ejb1\Primer.class
 8. Create the JAR file (primerEJB.jar). Change to [drive]:\examples\src directory and use the following instruction :
 jar -cvfM primerEJB.jar com META-INF
 9. Create the WAR file (primerEJB.war). Change to [drive]:\examples\src directory and use the following instruction :
 jar -cvfM primerEJB.war WEB-INF primerEJB.jsp
 10. Copy the JAR file (primerEJB.jar) and WAR file (primerEJB.war) to [drive]:\examples
 11. Create application.xml in [drive]:\examples\META-INF directory.
 Source of application.xml
 __________________________________________________________
 <?xml version="1.0" encoding="ISO-8859-1"?>
 <display-name>Primer EJB</display-name>
 <web-uri>primerEJB.war</web-uri>
 <context-root>/primerEJB</context-root>
 primerEJB.jar
 __________________________________________________________
 The value in <web-uri> tag is the name of your WAR file.
 The value in <context-root> tag is the context of your application.
 The value in tag is the name of your JAR file.
 12. Create the EAR file (primerEJB.ear). Change to [drive]:\examples directory and use the following instruction :
 jar -cvfM primerEJB.ear primerEJB.jar primerEJB.war META-INF
 13. Copy the EAR file to %JBOSS_HOME%\server\default\deploy.
 14. Run JBoss-Tomcat Server
 14. Test the application :
 http://[IP ADDRESS JBOSS-TOMCAT SERVER]:8080/primerEJB/primerEJB.jsp
 You can automate this building process using Ant.
 In the next reply I will send you in attachment the EAR file (primerEJB.ear)
 Regards
 Javier
- 
        9. Re: I need a single exampletorreblanca Aug 28, 2002 2:48 PM (in response to sheldon)Bakul, 
 Here is the file attachment (primerEJB.ear).
 Regards
 Javier
- 
        10. Re: I need a single exampletorreblanca Aug 28, 2002 3:46 PM (in response to sheldon)Bakul, 
 In this moment I found in the forum a Monson-Haefel book using EJB with JBoss, the address is :
 http://www.monson-haefel.com/titanbooks/download.html
 Regards
 Javier
- 
        11. Re: I need a single examplesheldon Sep 5, 2002 3:59 PM (in response to sheldon)Thank you so much. 
 It's very helpful for me.
 I have some idea what's jboss, ejb now.
 
     
     
     
     
    