You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by David Rothman <dr...@allinstant.com> on 2001/03/12 21:56:23 UTC

Cocoon and Jetty and Jboss

For those interested in easily setting up Cocoon with an
open source servlet and EJB container, your prayers have been answered.

Please try this out and I'll make an update to the
cocoon installation page...

If anything is missing, please let me know.

If anyone has been able to achieve simple config success
with Tomcat and Jboss, maybe you could share with us something
similar (hint - hint).

Good luck!

Cheers,

David

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

Welcome to the New World...

The Full OpEn SoUrCe J2EE/XML Monty...

INSTRUCTIONS TO SETUP SETUP JBOSS WITH JETTY AND COCOON FROM SCRATCH

1. Download and unpack jboss/jetty from jboss.org website
(i'm using jboss pre-2.1 and jetty 3.0.2 all installed in
c:\jboss_jetty\ on a win2K machine using sun jdk 1.3.0)


2. Run out of the box
by going to /jboss/bin and running run_with_jetty.bat or .sh if in linux


3. Check that jboss/jetty loads up with no problems including
tomcat-test.ear
--> test this by accessing http://localhost:8080/jboss/
--> then run servlet,
--> once this works, smile : ) you're almost there


4. Get cocoon, i'm using the 1.8.2 version precompiled


5. Copy cocoon related jars:
a) copy turbine-pool.jar, fop_0_15_0.jar, xalan_1_2_D02.jar, and w3c.jar
from cocoon-1.8.2/lib to jetty-3.0.2/lib

b)copy cocoon.jar from cocoon-1.8.2/bin to jetty-3.0.2/lib

courtesy of Fredrik Borgh:
FB> Your cocoon jar-files can be placed in <jetty>/lib (this is where I keep
FB> 'em) or you can leave them where they are, it's up to you :)!!

6. Setup xerces jar at the front of the classpath line
a) copy xerces_1_2.jar from cocoon-1.8.2/lib to jboss-PRE-2.1/lib

b) place xerces_1_2.jar ahead of all other in classpath
see below for my current jboss/bin/run.bat file


7. Set up Jetty to handle Cocoon
a) In Jetty/webapps directory, I created xml directory or (pick any name you
want)

b) copy samples directory from cocoon/samples to Jetty/webapps/xml/

c) create WEB-INF directory in Jetty/webapps/xml/

d) copy cocoon.properties from cocoon/conf to Jetty/webapps/xml/WEB-INF

e) copy Jetty/webapps/default/WEB-INF/web.xml to
Jetty-3.0.2/webapps/xml/WEB-INF
and replace contents with

<!DOCTYPE web-app
    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
    "http://java.sun.com/j2ee/dtds/web-app_2.2.dtd">

<web-app>
 <servlet>
  <servlet-name>cocoon</servlet-name>
  <servlet-class>org.apache.cocoon.Cocoon</servlet-class>
  <init-param>
   <param-name>properties</param-name>
   <param-value>./WEB-INF/cocoon.properties</param-value>
  </init-param>
 </servlet>

 <servlet-mapping>
  <servlet-name>cocoon</servlet-name>
  <url-pattern>*.xml</url-pattern>
 </servlet-mapping>
</web-app>


f) update jboss-PRE-2.1/conf/jetty/jetty.xml to include

  <Call name="addWebApplication">
        <Arg>/xml/*</Arg>
        <Arg><SystemProperty name="jetty.home"
default="."/>/webapps/xml/</Arg>
        <Arg><SystemProperty name="jetty.home"
default="."/>/etc/webdefault.xml/</Arg>
  </Call>


9. Finally, replace org.apache.cocoon.Utils in cocoon.jar for reasons
described below,
coutesy of Fredrik Borgh:

FB> The problem is that the new version of Cocoon (1.8.2) seems to have an
error
FB> in org.apache.cocoon.Utils. I've corrected the error and recompiled the
FB> class. It's included in this mail. All you have to do is to replace the
FB> existing org.apache.cocoon.Utils in cocoon.jar with this one. Please
note
FB> that this is just my own fix, hopefully they'll correct it in a new
release.


10. Go back to command line/shell and call
jboss-PRE-2.1/lib/run_with_jetty.bat

11. Once everything starts up perfectly
go to http://localhost:8080/xml/Cocoon.xml and run the samples at
      http://localhost:8080/xmlsamples/index.xml

if you see this "virtual page" and the samples --> party!!!!! :))

and welcome to brave new world of The Full OpEn SoUrCe J2EE/XML Monty...

and give a small thanks to Marc, Rickard and all the rest of the Jboss
gurus,
Stefano Mazzocchi, Robin Green, Donald Ball and all the rest of the
Cocoon wizards, and Greg Wilkins, Fredrik Borgh and all the gurus and
wizards of Jetty!!!




EXTRA CONFIGURATION FILE INFO

**************jboss/bin/run.bat******************************

@echo off
@if not "%ECHO%" == ""  echo %ECHO%
@if "%OS%" == "Windows_NT"  setlocal

set CLASSPATH=%CLASSPATH%;..\lib\xerces_1_2.jar
set CLASSPATH=%CLASSPATH%;run.jar

REM Add all login modules for JAAS-based security
REM and all libraries that are used by them here
set
CLASSPATH=%CLASSPATH%;..\lib\jdbc2_0-stdext.jar;..\lib\jboss-jaas.jar;\tools
.jar
REM ;..\lib\xalan_1_2_D02.jar

echo Using CLASSPATH: %CLASSPATH%
java -classpath "%CLASSPATH%" org.jboss.Main %1 %2 %3 %4 %5 %6 %7 %8 %9

pause


**************************************************************



************Jetty-3.0.2/webapps/xml/WEB-INF/web.xml*************
<!--
     This is the web-app configurations that allow Cocoon to work under
     Jetty. Please, follow the installation section of the
     documentation (right! ;-)wink-wink) for more information
	about installing Cocoon on Jetty
-->

<!DOCTYPE web-app
    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
    "http://java.sun.com/j2ee/dtds/web-app_2.2.dtd">

<web-app>
 <servlet>
  <servlet-name>cocoon</servlet-name>
  <servlet-class>org.apache.cocoon.Cocoon</servlet-class>
  <init-param>
   <param-name>properties</param-name>
   <param-value>./WEB-INF/cocoon.properties</param-value>
  </init-param>
 </servlet>

 <servlet-mapping>
  <servlet-name>cocoon</servlet-name>
  <url-pattern>*.xml</url-pattern>
 </servlet-mapping>
</web-app>

*********************************************************************




**************jboss-PRE-2.1/conf/jetty/jetty.xml*********************

<?xml version="1.0"  encoding="ISO-8859-1"?>
<!DOCTYPE Configure PUBLIC
 "-//Mort Bay Consulting//DTD Configure 1.0//EN"
 "http://jetty.mortbay.com/configure_1_0.dtd">

<!--
This is a Jetty HTTP server configuration file.  This configuration
uses the generic com.mortbay.Util.XmlConfiguration class to call
the normal com.mortbay.HTTP.HttpServer configuration API from
within an XML script.

The format of this file is described in the configure.dtd file.

The API that can be called by this file is described in the
Javadoc for Jetty.

The following concepts must be understood when configuring
a server:

Listener: is a network interface object that
accepts HTTP requests for the server. SocketListeners accept
normal requests, while JsseListeners accept SSL requests.
The threading model of the server is controlled by the
listener parameters.

WebApplication: is a bundled collection of resources,
servlets and configuration that can provide a unified
WWW application.  It is part of the 2.2 servlet standard.
The contents of the application are configured by the
web.xml deployment descriptor within the application.
The configuration of the application within Jetty requires
on the context of the application to be set.

Context: is a grouping of server resources that share
the same URL path prefix, class path and resource base.
A Web application is an example of a specific context.
Generic contexts may have arbitrary request handlers
added to them.  All contexts have a path specification
(frequently the default "/") and an option virtual
host alias.

Handler:  Handlers are the objects that actually
service the HTTP requests. Examples of Handlers include
ServletHandler, ResourceHandler and NotFoundHandler.
Handlers are contained within Contexts, which provide
conveniance methods for the common handlers so
that servlet and file serving may be configured for
a context without explicit creation of a Handler.


This file configures the demo server and is equivalent
to the com.mortbay.Jetty.Demo class.

$ID: $
-->

<Configure class="com.mortbay.HTTP.HttpServer">
  <Call name="addListener">
    <Arg>
      <New class="com.mortbay.HTTP.SocketListener">
        <Set name="Port">8080</Set>
        <Set name="MinThreads">5</Set>
        <Set name="MaxThreads">255</Set>
        <Set name="MaxIdleTimeMs">60000</Set>
        <Set name="MaxReadTimeMs">60000</Set>
      </New>
    </Arg>
  </Call>

<!--  Uncomment this to add an SSL listener.
  <Call name="addListener">
    <Arg>
      <New class="com.mortbay.HTTP.SunJsseListener">
        <Set name="Port">8443</Set>
        <Set name="MinThreads">5</Set>
        <Set name="MaxThreads">255</Set>
        <Set name="MaxIdleTimeMs">50000</Set>
        <Set name="Keystore">etc/demokeystore</Set>
	<Set name="Password">OBF:1vny1zlo1x8e1vnw1vn61x8g1zlu1vn4</Set>
	<Set name="KeyPassword">OBF:1u2u1wml1z7s1z7a1wnl1u2g</Set>
      </New>
    </Arg>
  </Call>
-->

  <Call name="addWebApplication">
    <Arg>/jetty/*</Arg>
    <Arg><SystemProperty name="jetty.home"/>/webapps/jetty.war</Arg>
    <Arg><SystemProperty name="jetty.home"/>/etc/webdefault.xml/</Arg>
  </Call>

  <Call name="addContext">
    <Arg>/demo/*</Arg>
    <Set name="ResourceBase"><SystemProperty
name="jetty.home"/>/docroot/</Set>
    <Call name="addServlet">
      <Arg>Dump</Arg>
      <Arg>/dump/*,*.DUMP</Arg>
      <Arg>com.mortbay.Servlet.Dump</Arg>
    </Call>
    <Call name="addServlet">
      <Arg>Session</Arg>
      <Arg>/session</Arg>
      <Arg>com.mortbay.Servlet.SessionDump</Arg>
    </Call>
    <Call name="addServlet">
      <Arg>Dispatch</Arg>
      <Arg>/Dispatch/*</Arg>
      <Arg>com.mortbay.Servlet.RequestDispatchTest</Arg>
    </Call>
    <Call name="addServlet">
      <Arg>JSP</Arg>
      <Arg>*.jsp</Arg>
      <Arg>org.apache.jasper.servlet.JspServlet</Arg>
    </Call>
    <Set name="ServingResources">TRUE</Set>
    <Call name="addHandler">
      <Arg><New class="com.mortbay.HTTP.Handler.DumpHandler"/></Arg>
    </Call>
    <Set name="HttpServerAccess">TRUE</Set>
  </Call>

  <Call name="addContext">
    <Arg>/javadoc/*</Arg>
    <Set name="ResourceBase"><SystemProperty
name="jetty.home"/>/javadoc/</Set>
    <Set name="ServingResources">TRUE</Set>
  </Call>

  <Call name="addContext">
    <Arg>/cgi-bin/*</Arg>
    <Set name="ResourceBase"><SystemProperty
name="jetty.home"/>/cgi-bin</Set>
    <Call name="addServlet">
      <Arg>Common Gateway Interface</Arg>
      <Arg>/</Arg>
      <Arg>com.mortbay.Servlet.CGI</Arg>
     <Put name="Path">/bin:/usr/bin:/usr/local/bin</Put>
    </Call>
  </Call>

  <Call name="addContext">
    <Arg>/</Arg>
    <Set name="DynamicServletPathSpec">/servlet/*</Set>
    <Call name="addServlet">
      <Arg>Forward</Arg>
      <Arg>/</Arg>
      <Arg>com.mortbay.Servlet.Forward</Arg>
      <Put name="/">/jetty/index.html</Put>
    </Call>
    <Call name="addHandler">
      <Arg><New class="com.mortbay.HTTP.Handler.NotFoundHandler"/></Arg>
    </Call>
  </Call>

  <Call name="addRealm">
    <Arg>
      <New class="com.mortbay.HTTP.HashUserRealm">
        <Arg>Jetty Demo Realm</Arg>
        <Arg><SystemProperty
name="jetty.home"/>/etc/demoRealm.properties</Arg>
      </New>
    </Arg>
  </Call>

  <Set name="LogSink">
    <New class="com.mortbay.Util.WriterLogSink">
      <Arg><SystemProperty name="jetty.home"
default="./logs"/>/yyyy_mm_dd.request.log</Arg>
      <Set name="RetainDays">90</Set>
      <Set name="Append">true</Set>
    </New>
  </Set>

<!--  add below to run cocoon -->

  <Call name="addWebApplication">
        <Arg>/xml/*</Arg>
        <Arg><SystemProperty name="jetty.home"
default="."/>/webapps/xml/</Arg>
        <Arg><SystemProperty name="jetty.home"
default="."/>/etc/webdefault.xml/</Arg>
  </Call>

</Configure>


***************************************************************


---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>

To unsubscribe, e-mail: <co...@xml.apache.org>
For additional commands, e-mail: <co...@xml.apache.org>