J2EE
Home Up J2EE JDBC Getting Started

Notes on JBoss

  1. An example that does not work with the latest JBoss: http://web.pdx.edu/~suratman/ejb/examples.html
  2. Download latest as of Tue Sep 24 15:36:18 2002
  3. I grabbed this from the JBoss forums
    1. Write and deploy a JSP :
      1. Write the JSP
        Example (uno.jsp) :


        <%@ page import="java.text.*,
        java.util.*"%>

        <HTML>
        <BODY>
        <%
        Date d = new Date();
        String hoy = DateFormat.getDateInstance().format(d);
        %>
        La Fecha de hoy es :
        <EM> <%= hoy %> </EM>
        </BODY>
        </HTML>

      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"?>
        <application>
        <display-name>uno</display-name>
        <module>
        <web>
        <web-uri>uno.war</web-uri>
        <context-root>/uno</context-root>
        </web>
        </module>
        </application>


      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
        Run the JBoss-Tomcat server.

      6. 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.
    2. HERE IS THE PROCEDURE FOR JBoss 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>
        <servlet-name>Dos</servlet-name>
        <servlet-class>com.servlet.Dos</servlet-class>
        </servlet>
        </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"?>
        <application>
        <display-name>dos</display-name>
        <module>
        <web>
        <web-uri>dos.war</web-uri>
        <context-root>/dos</context-root>
        </web>
        </module>
        </application>

      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. Try out the above examples
      bulletBe sure to type run.bat -c all to startup jboss before trying this.
      bulletHere are the two ear files from the above tutorial for your convenience:
      bulletdos.ear
      bulletuno.ear
      bulletCopy the above to ear files to the deploy directory. The deploy directory is C:\jboss-3.1.0alpha_tomcat-4.0.4\server\all\deploy (assuming you installed JBoss in the top level directory).
      bulletCheck out
      1. http://10.0.0.4:8080/uno/uno.jsp
      2. http://10.0.0.4:8080/dos/servlet/Dos
      3. http://10.0.0.4:8080/axis/servlet/AxisServlet
        bulletThis last one is a little disappointing. Apparently the developers are going to do something interesting with this page in the future.
  4. Tutorial on soap/JBoss: http://www.csd.abdn.ac.uk/~bscharla/teaching/mtp_software/jboss/jboss-net-HelloWorld.shtml
  5. Here is another tutorial recently converted to JBoss

    Peter from WestSideWidgets was kind enough to port the examples to JBoss. I used XDoclet to generate the deployment descriptors, but never spent the time with JBoss to test them. Peter tested them and fixed them. Thus, the example has been ported to JBoss.

    (Part 1 and 2 worked with RI. Part 3 and 4 worked with WebLogic.)


    JBoss Port!

    If you don't know what I am talking about see....

    EJB CMP/CMR Tutorial

    But here is a hint....

    This tutorial is designed to introduce you to Container-Managed Persistence (CMP) and Container-Managed Relationships (CMR) in Enterprise JavaBeans 2.0 (EJB). (Source code for examples at bottom of page)

    About the code:
    The code in the first two parts works with Sun's RI for J2EE. Peter Luellen from West Side Widgets created the deployment descriptors to get final code from part 1 and 2 working for JBoss. Peter also got the examples for part 3 and 4 to work with JBoss. Please check out the JBoss Port of the examples.

    The code for part 3 and 4 was tested with BEA WebLogic, but should work with other application servers as well. The code from part 3 and 4 was based on the code from part 2. I modified the code to use EJBDoclet task (part of XDoclet). XDoclet ROCKs! The ant build script is set up to run EJBDoclet task. I suggest you check out XDoclet... it is the bee's knees! (Peter Luellen tested and fixed the code so that it would also work with JBoss.)

    A future article will show how to port the code to many different application servers

     

 

 

Home Up Feedback Contents Search

Send mail to webmaster@SIGNITEK.com with questions or comments about this web site.