NetRexx Servlets on Tomcat - a few easy steps

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

NetRexx Servlets on Tomcat - a few easy steps

measel

I’ll be posting a more colorful version of this somewhere on the interweb.  My ultimate goal is a packaged appliance for VirutalBox with NetRexx as the centerpiece.

 

I decided on a Linux (Debian) base, with Tomcat (java web server).  You can get a prebuilt image here:  http://www.turnkeylinux.org/tomcat

 

I use Virtualbox on my Windows machine to host virtual guests.  (Free) And it works great.  https://www.virtualbox.org/

 

The Turnkey ISO can be attached and booted and will install to a virtual hard drive.

 

Cool.  Now this is a “server” type machine that you can access via putty or other ssh tool or via a browser.  It has no GUI.  Command line or browser only.  Which is fine.

 

So lets install NetRexx.  From the command prompt, change to or create a temp directory and cd to it.

 

1)       wget http://www.netrexx.org/files/NetRexx-3.02RC1.zip

2)      unzip NetRexx-3.02RC1.zip

3)      follow the readme --- oops breaks down here – the shell scripts aren’t right

4)      work around… ?

 

CLASSPATH=/root/lib/NetRexxC.jar:/root/lib/NetRexxF.jar:/usr/share/tomcat6/lib/servlet-api.jar

export CLASSPATH

java -classpath $CLASSPATH org.netrexx.process.NetRexxC /media/sf_transfer/precompile/NrxServletTest.nrx

 

NetRexx portable processor, version NetRexx 3.02, build 11-20130323-1551

Copyright (c) RexxLA, 2011,2013.  All rights reserved.

Parts Copyright (c) IBM Corporation, 1995,2008.

Program NrxServletTest.nrx

  === class NrxServletTest ===

    method doGet(HttpServletRequest,HttpServletResponse)

      signals IOException

      overrides HttpServlet.doGet(HttpServletRequest,HttpServletResponse)

java.lang.ClassNotFoundException: com.sun.tools.javac.Main

Compilation of 'NrxServletTest.nrx' failed [javac failed]

 

Ok, fine, it did create the NrxServletTest.java, so javac NrxServletTest and we’ve got the class file.

 

Now how to package our servlet and get it working in the webserver.  First the WAR file and aptly named it is.

 

We create a directory structure that we will then jar up to deploy to Tomcat and copy our NetRexx class to the classes directory.

The NetRexxC.jar will go in the lib directory so Tomcat can find it.

The web.xml file describes the servlet class to url mapping.

 

------------------directory structure ----------------------

/Temp/

   NetRexxWAR/

      META-INF/

      WEB-INF/

         Classes/

            NrxServletTest.class

         web.xml

         lib/

             NetRexxC.jar

 

-----------web.xml example---------------

 

<?xml version="1.0" encoding="ISO-8859-1"?>

<web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.4" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">

    <display-name>NetRexx Test Servlet, a first Web Application</display-name>

    <description>

        This is a simple web application containing a single servlet

        of the "Hello, World" variety.

    </description>

 

    <servlet>

        <servlet-name>nrxHello</servlet-name>

        <servlet-class>NrxServletTest</servlet-class>

    </servlet>

 

    <servlet-mapping>

        <servlet-name>nrxHello</servlet-name>

        <url-pattern>/Hello</url-pattern>

    </servlet-mapping>

</web-app>

 

----------------------------------------------------

Then to create the WAR file, CD into the NetRexxWAR directory and type jar –cvf NetRexxWAR.war .

(don’t forget that period )

 

 

Deploy the application war file from the Tomcat console. In your browser use the guest ip and /manager  ex:  192.168.56.101/Manager

 

You’ll see a screen with the default url.  Scroll down to the Deploy section and where it says “War file to deploy” select the NetRexxWAR.war that you just created.  Hit the deploy button and you’ll see it appear in the list at the top of the page.

 

Now, to access your servlet, go to the server/NetRexxWAR/Hello – ex:  http://192.168.56.101/NetRexxWAR/Hello

 

If all went well you’ll see this:

 

Welcome to the NetRexx Servlet example page

 

/* NrxServletTest.nrx */

import java.io

import javax.servlet

import javax.servlet.http

 

class NrxServletTest extends HttpServlet

method doGet(req=HttpServletRequest,res=HttpServletResponse) public final

  res.setContentType("text/html") -- Set Content type to HTML

  out = PrintWriter -- Create an object for streaming code

  out = res.getWriter

  out.println("<HTML>") -- Output code for browser

  out.println("<HEAD>")

  out.println("<TITLE>NetRexx Servlet Example</TITLE>")

  out.println("</HEAD>")

  out.println("<BODY>")

  out.println("<H1>Welcome to the NetRexx Servlet example page</H1>")

  out.println("</BODY>")

  out.println("</HTML>")

 

 


_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/

Reply | Threaded
Open this post in threaded view
|

Re: NetRexx Servlets on Tomcat - a few easy steps

Nix, Robert P.
Re: [Ibm-netrexx] NetRexx Servlets on Tomcat - a few easy steps You can get rid of the java.lang.ClassNotFoundException: com.sun.tools.javac.Main exception in NetRexxC by adding the tools.jar file to your $CLASSPATH. In my case, it’s located at /usr/lib/jvm/java-6-openjdk-armhf/lib/tools.jar (You’ll find it elsewhere, unless your computer fits in your pocket and smells of raspberries.)

--
Robert P. Nix          Mayo Foundation        .~.
RO-OC-1-18             200 First Street SW    /V\
507-284-0844           Rochester, MN 55905   /( )\
-----                                        ^^-^^
"In theory, theory and practice are the same, but
 in practice, theory and practice are different."



On 4/24/13 8:46 AM, "Measel, Mike" <Mike.Measel@...> wrote:

I’ll be posting a more colorful version of this somewhere on the interweb.  My ultimate goal is a packaged appliance for VirutalBox with NetRexx as the centerpiece.
 
I decided on a Linux (Debian) base, with Tomcat (java web server).  You can get a prebuilt image here: http://www.turnkeylinux.org/tomcat
 
I use Virtualbox on my Windows machine to host virtual guests.  (Free) And it works great. https://www.virtualbox.org/
 
The Turnkey ISO can be attached and booted and will install to a virtual hard drive.
 
Cool.  Now this is a “server” type machine that you can access via putty or other ssh tool or via a browser.  It has no GUI.  Command line or browser only.  Which is fine.
 
So lets install NetRexx.  From the command prompt, change to or create a temp directory and cd to it.
 
1)      wget http://www.netrexx.org/files/NetRexx-3.02RC1.zip

2)     unzip NetRexx-3.02RC1.zip

3)     follow the readme --- oops breaks down here – the shell scripts aren’t right

4)     work around… ?

 
CLASSPATH=/root/lib/NetRexxC.jar:/root/lib/NetRexxF.jar:/usr/share/tomcat6/lib/servlet-api.jar
export CLASSPATH
java -classpath $CLASSPATH org.netrexx.process.NetRexxC /media/sf_transfer/precompile/NrxServletTest.nrx
 
NetRexx portable processor, version NetRexx 3.02, build 11-20130323-1551
Copyright (c) RexxLA, 2011,2013.  All rights reserved.
Parts Copyright (c) IBM Corporation, 1995,2008.
Program NrxServletTest.nrx
  === class NrxServletTest ===
    method doGet(HttpServletRequest,HttpServletResponse)
      signals IOException
      overrides HttpServlet.doGet(HttpServletRequest,HttpServletResponse)
java.lang.ClassNotFoundException: com.sun.tools.javac.Main
Compilation of 'NrxServletTest.nrx' failed [javac failed]
 
Ok, fine, it did create the NrxServletTest.java, so javac NrxServletTest and we’ve got the class file.
 
Now how to package our servlet and get it working in the webserver.  First the WAR file and aptly named it is.
 
We create a directory structure that we will then jar up to deploy to Tomcat and copy our NetRexx class to the classes directory.
The NetRexxC.jar will go in the lib directory so Tomcat can find it.
The web.xml file describes the servlet class to url mapping.
 
------------------directory structure ----------------------
/Temp/
   NetRexxWAR/
      META-INF/
      WEB-INF/
         Classes/
            NrxServletTest.class
         web.xml
         lib/
             NetRexxC.jar
 
-----------web.xml example---------------
 
<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.4" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
    <display-name>NetRexx Test Servlet, a first Web Application</display-name>
    <description>
        This is a simple web application containing a single servlet
        of the "Hello, World" variety.
    </description>
 
    <servlet>
        <servlet-name>nrxHello</servlet-name>
        <servlet-class>NrxServletTest</servlet-class>
    </servlet>
 
    <servlet-mapping>
        <servlet-name>nrxHello</servlet-name>
        <url-pattern>/Hello</url-pattern>
    </servlet-mapping>
</web-app>
 
----------------------------------------------------
Then to create the WAR file, CD into the NetRexxWAR directory and type jar –cvf NetRexxWAR.war .
(don’t forget that period )
 
 
Deploy the application war file from the Tomcat console. In your browser use the guest ip and /manager  ex:  192.168.56.101/Manager
 
You’ll see a screen with the default url.  Scroll down to the Deploy section and where it says “War file to deploy” select the NetRexxWAR.war that you just created.  Hit the deploy button and you’ll see it appear in the list at the top of the page.
 
Now, to access your servlet, go to the server/NetRexxWAR/Hello – ex: http://192.168.56.101/NetRexxWAR/Hello
 
If all went well you’ll see this:
 
Welcome to the NetRexx Servlet example page


/* NrxServletTest.nrx */
import java.io
import javax.servlet
import javax.servlet.http
 
class NrxServletTest extends HttpServlet
method doGet(req=HttpServletRequest,res=HttpServletResponse) public final
  res.setContentType("text/html") -- Set Content type to HTML
  out = PrintWriter -- Create an object for streaming code
  out = res.getWriter
  out.println("<HTML>") -- Output code for browser
  out.println("<HEAD>")
  out.println("<TITLE>NetRexx Servlet Example</TITLE>")
  out.println("</HEAD>")
  out.println("<BODY>")
  out.println("<H1>Welcome to the NetRexx Servlet example page</H1>")
  out.println("</BODY>")
  out.println("</HTML>")
 



_______________________________________________
Ibm-netrexx mailing list
Ibm-netrexx@...
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/


_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/

Reply | Threaded
Open this post in threaded view
|

Re: NetRexx Servlets on Tomcat - a few easy steps

measel
Re: [Ibm-netrexx] NetRexx Servlets on Tomcat - a few easy steps

Yes thanks Robert, I know, I was just trying to follow the instructions for a change.  J

 

Raspberry NetRexx, Nice.

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Nix, Robert P.
Sent: Wednesday, April 24, 2013 10:24 AM
To: IBM Netrexx
Subject: Re: [Ibm-netrexx] NetRexx Servlets on Tomcat - a few easy steps

 

You can get rid of the java.lang.ClassNotFoundException: com.sun.tools.javac.Main exception in NetRexxC by adding the tools.jar file to your $CLASSPATH. In my case, it’s located at /usr/lib/jvm/java-6-openjdk-armhf/lib/tools.jar (You’ll find it elsewhere, unless your computer fits in your pocket and smells of raspberries.)

--
Robert P. Nix          Mayo Foundation        .~.
RO-OC-1-18             200 First Street SW    /V\
507-284-0844           Rochester, MN 55905   /( )\
-----                                        ^^-^^
"In theory, theory and practice are the same, but
 in practice, theory and practice are different."



On 4/24/13 8:46 AM, "Measel, Mike" <Mike.Measel@...> wrote:

I’ll be posting a more colorful version of this somewhere on the interweb.  My ultimate goal is a packaged appliance for VirutalBox with NetRexx as the centerpiece.
 
I decided on a Linux (Debian) base, with Tomcat (java web server).  You can get a prebuilt image here: http://www.turnkeylinux.org/tomcat
 
I use Virtualbox on my Windows machine to host virtual guests.  (Free) And it works great. https://www.virtualbox.org/
 
The Turnkey ISO can be attached and booted and will install to a virtual hard drive.
 
Cool.  Now this is a “server” type machine that you can access via putty or other ssh tool or via a browser.  It has no GUI.  Command line or browser only.  Which is fine.
 
So lets install NetRexx.  From the command prompt, change to or create a temp directory and cd to it.
 
1)      wget http://www.netrexx.org/files/NetRexx-3.02RC1.zip

2)     unzip NetRexx-3.02RC1.zip

3)     follow the readme --- oops breaks down here – the shell scripts aren’t right

4)     work around… ?

 
CLASSPATH=/root/lib/NetRexxC.jar:/root/lib/NetRexxF.jar:/usr/share/tomcat6/lib/servlet-api.jar
export CLASSPATH
java -classpath $CLASSPATH org.netrexx.process.NetRexxC /media/sf_transfer/precompile/NrxServletTest.nrx
 
NetRexx portable processor, version NetRexx 3.02, build 11-20130323-1551
Copyright (c) RexxLA, 2011,2013.  All rights reserved.
Parts Copyright (c) IBM Corporation, 1995,2008.
Program NrxServletTest.nrx
  === class NrxServletTest ===
    method doGet(HttpServletRequest,HttpServletResponse)
      signals IOException
      overrides HttpServlet.doGet(HttpServletRequest,HttpServletResponse)
java.lang.ClassNotFoundException: com.sun.tools.javac.Main
Compilation of 'NrxServletTest.nrx' failed [javac failed]
 
Ok, fine, it did create the NrxServletTest.java, so javac NrxServletTest and we’ve got the class file.
 
Now how to package our servlet and get it working in the webserver.  First the WAR file and aptly named it is.
 
We create a directory structure that we will then jar up to deploy to Tomcat and copy our NetRexx class to the classes directory.
The NetRexxC.jar will go in the lib directory so Tomcat can find it.
The web.xml file describes the servlet class to url mapping.
 
------------------directory structure ----------------------
/Temp/
   NetRexxWAR/
      META-INF/
      WEB-INF/
         Classes/
            NrxServletTest.class
         web.xml
         lib/
             NetRexxC.jar
 
-----------web.xml example---------------
 
<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.4" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
    <display-name>NetRexx Test Servlet, a first Web Application</display-name>
    <description>
        This is a simple web application containing a single servlet
        of the "Hello, World" variety.
    </description>
 
    <servlet>
        <servlet-name>nrxHello</servlet-name>
        <servlet-class>NrxServletTest</servlet-class>
    </servlet>
 
    <servlet-mapping>
        <servlet-name>nrxHello</servlet-name>
        <url-pattern>/Hello</url-pattern>
    </servlet-mapping>
</web-app>
 
----------------------------------------------------
Then to create the WAR file, CD into the NetRexxWAR directory and type jar –cvf NetRexxWAR.war .
(don’t forget that period )
 
 
Deploy the application war file from the Tomcat console. In your browser use the guest ip and /manager  ex:  192.168.56.101/Manager
 
You’ll see a screen with the default url.  Scroll down to the Deploy section and where it says “War file to deploy” select the NetRexxWAR.war that you just created.  Hit the deploy button and you’ll see it appear in the list at the top of the page.
 
Now, to access your servlet, go to the server/NetRexxWAR/Hello – ex: http://192.168.56.101/NetRexxWAR/Hello
 
If all went well you’ll see this:
 
Welcome to the NetRexx Servlet example page


/* NrxServletTest.nrx */
import java.io
import javax.servlet
import javax.servlet.http
 
class NrxServletTest extends HttpServlet
method doGet(req=HttpServletRequest,res=HttpServletResponse) public final
  res.setContentType("text/html") -- Set Content type to HTML
  out = PrintWriter -- Create an object for streaming code
  out = res.getWriter
  out.println("<HTML>") -- Output code for browser
  out.println("<HEAD>")
  out.println("<TITLE>NetRexx Servlet Example</TITLE>")
  out.println("</HEAD>")
  out.println("<BODY>")
  out.println("<H1>Welcome to the NetRexx Servlet example page</H1>")
  out.println("</BODY>")
  out.println("</HTML>")
 


_______________________________________________
Ibm-netrexx mailing list
Ibm-netrexx@...
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/


_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/