I wrote the following in answer to some other newbie questions(not far from
there myself so I understand.)  The most important thing to know is that all
you need to put into your own webapp is the cocoon.jar(not cocoon.war so
this is not a typo below).  It could stand a rewrite but here it is right
now.

Understand that what you download from the apache Cocoon site is not a
software tool or IDE but a super-powered servlet with many illustrations of
how to use it, all in one huge example webapp (much beyond a typical "Hello
World!" example).  Your starting point is getting this one huge example web
app to deploy once or twice on tomcat by placing the cocoon.war file in the
webapps folder of tomcat.  The "as is" Cocoon installation either works or
it doesn't.  There is nothing you can do right or wrong. Especially for the
Current Version System CVS revision xml-cocoon2 from the jakarta site
http://jakarta.apache.org/site/cvsindex.html.  My current tomcat revision is
Apache Tomcat/4.0.2-b1.  After I get a stable Cocoon revision running I use
it for a few months and back it up religiously when I go for the next cvs.
The command line:

 build.bat -Dinclude.webapp.libs=yes -Dinstall.war=%TOMCAT_HOME%\webapps

often will not work depending on the exact TOMCAT_HOME environment variable
you are using.  For example c:/Program Files/tomcat... has a space and can
cause age old problems.  Just copy the cocoon.war to the
%TOMCAT_HOME%\webapps yourself.  Fire tomcat up.  It either works or you got
a bum revision or copy of Cocoon.war. If it doesn't work the second time you
fire it up, delete the generated ...tomcat/work/localhost/cocoon and the
...tomcat/webapps/cocoon folders so that it has to deploy from the
cocoon.war file again.  May have to do this repeatedly until you rebuild
cocoon.war without hsqldb active or start making your own webapp
project(deployed through your own *.war file).  The problem is with the
hsqldb database example has a bug while shutting down.  The sooner that you
rebuild cocoon from its sources with
<hsqldb-server class="org.apache.cocoon.components.hsqldb.ServerImpl"
logger="core.hsqldb-server"
pool-max="1" pool-min="1">
<parameter name="port" value="9002"/>
<parameter name="silent" value="true"/>
<parameter name="trace" value="false"/>
</hsqldb-server>

commented out in the src/webapp/cocoon.xconf file, the better.  The the rest
of the examples will start and stop just find.  Note that some of the
examples need extra jars placed in the cocoon/lib folder such as jndi.jar,
phpsrvlt.jar, etc. The important thing is to get past flopping around in
this one huge example webapp and start your own serious webapp as soon as
possible after you see Cocoon's one huge example webapp run once or twice.

Cocoon is not a typically installed software package and so to apply it to
your own web app at first is not intuitive.  The documentation has a long
way to go to catch up; remember it is a work in progress and tends to assume
that we know the small but totally baffling how-to-get-started stuff.  I
finally discovered a cool way to do it and perhaps with editing from the
Cocoon 2 Team we can put together a "How to apply Cocoon 2" for their web
site.  The most important thing is to set up your own webapp project build
area.  This takes some work but you can do it in stages.  To start, create a
project folder(sibling to the xml-cocoon2 folder), name it according to your
project, prepare your directory structure:

+->lib
        <all of the jars from your current working xml-cocoon2/lib folder>
        <plus the cocoon.jar from the xml-cocoon2/build/cocoon folder>
        //this is key because now your own build can be simplyfied
+->src //For your own custom additions to cocoon
    +->documentation //At first just a copy from the xml-cocoon2/src
            //You can eventually put your own or only things you need here
    +->java //Only your own custom code here.  No cocoon code because
                    cocoon.jar already has the compiled Cocoon classes.
    +->webapp    //At first a copy of the webapp from xml-cocoon2/src
                      //This you start modifying starting with the homepage
                      //and sitemap.xmap
appendcp.bat
                    //classpath appender
build.bat
build.xml    //A stripped down or commented out revision from the one
                   //in the xml-cocoon2 folder.  Have it generate a build
folder
                   // for construction of  your webapp jar and war files.
database.properties.
                    //set up your database initialization
                    //you will need to set somethings according to
                    //
http://xml.apache.org/cocoon/developing/datasources.html

Your custom webapp's build.xml can be pared down considerably from the huge
example cocoon webapp.  Until you make custom source code additions to your
...src/java folder you can disable the compile target.  Mostly you are
having it build the stuff it needs for your war file while applying build
variables such as
database-driver=org.gjt.mm.mysql.Driver.


The next stage is studying the ...src/webapp/sitemap.xmap file and modify
the welcome pattern matching to something you know and want.  There is no
need to pare the sitemap.xmap file down; eventually you will need more and
more of it and anything not in immediate use just lies dormant.  Finding the
first welcome page can require some sleuthing.  Currently it is nearly half
way down sitemap.xmap and looks like:
<map:pipeline>

<map:match pattern="">

<map:redirect-to uri="welcome"/>

</map:match>

<map:match pattern="welcome">

<map:generate src="docs/samples/samples.xml"/>

...

So ...src/webapp/docs/samples/samples.xml is the home page!  For those
familiar with Cocoon, this is no surprise but this was where I first started
to catch on!  What it meant to me is that I could start building my own
serious webapp now that I had the starting page and could study, modify
small parts of the whole to observe the changes that would occur after each
redeployment on tomcat.  I changed the welcome pattern matching to:
<map:pipeline>
<map:match pattern="">

<map:redirect-to uri="welcome"/>

</map:match>

<map:match pattern="welcome">

<map:generate src="home.xml"/>

where home.xml is a stripped down ...src/webapp/docs/samples/samples.xml to
pieces pertinent to my serious webapp.  It depends at this point on what you
want your web app to do.  For me I already had a number of mysql databases I
wanted to display and administrate so I studied
http://xml.apache.org/cocoon/developing/datasources.html and pooled them up.
Then got into my own xsp development applying the esql.xsl stylesheet.
Studying xsl is very important for creating your own webapp's consistent
look and feel.  The consistent look and feel is maintained by the xsl
stylesheets and the formatted objects namespace
xmlns:fo="http:www.w3.org/1999/XSL/Format".  Only a few of the xsl
stylesheets in the one huge example cocoon webapp are sacred and those are
mostly in ...src/java.  Others such as
...src/webapp/stylesheets/page/simple-page2html.xsl you are encouraged to
modify, rename or replace (updating the sitemap.xmap pattern matching
required) in your webapp.  The power of Cocoon is that when you change a
presentation attribute or style, after the next build and deployment, your
entire website has the new look and feel consistently throughout it's pages.
After some up front hard work, web site maintainance becomes dynamic and
fun; not a mundane chore. Here we would need to branch into chapters; one
for each stylesheet or webapp segments goal?

This is Saturday morning, January 19 and I just couldn't focus on my
projects so I tried to help someone else instead. Those just starting keep
asking [specific] questions and those with more experience than me, please
revise this description of "How to apply Cocoon 2" or use anything from this
message if you find anything includable in the documentation.

Regards,

Roger


----- Original Message -----
From: "Robert Leftwich" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Sunday, March 31, 2002 10:04 PM
Subject: Re: [Newbie] Where do cocoon apps go?


> At 12:32 PM 1/04/2002, Eric de Groot wrote:
> >I read all the articles and tutorials with the cocoon documentation, but
I cannot find any information telling me how to actually let an app use
cocoon.  Does the app need to be in a sub-directory of /webapps/cocoon/ ,
without it s own web.xml, etc..?  How can I have my application
/webapps/myapp/ use cocoon?  Do I need to route everything through Cocoon2
in my web.xml?  How will cocoon know where my sitemap is?  Is there any
documentation that details how to create a cocoon application from scratch?
The tutorial says we need a sitemap, this code, this sql, etc.., but doesn t
explain where any of it goes.  Any help to get me started would be
appreciated.  Thanks.
> >
> >-Eric de Groot
>
> You might take a look at Chello (http://chello.sourceforge.net/), which is
a minimal 'hello world' style web app with a setup including the following
features:
>
> ·       Project compilation using ANT
> ·       Unit Testing with JUnit
> ·       Functional Testing with HTTPUnit
> ·       Continuous integration process with CruiseControl
> ·       Documentation generation for
> ·       your Java Code using Javadoc
> ·       your XSL Stylesheets using XSLDoc
> ·       Your project documentation using Cocoon
> ·       Automatic build of Web archive file (WAR) for easy distribution
>
> Note that the existing setup is for an older release of Cocoon (v2 rc2). I
am currently running it with the latest v2.02 release of cocoon and was
going to submit the change list to the chello site for feedback (as I am a
newbie as well) prior to telling the rest of the world about it, but I guess
I've just done that :-)
>
> HTH
>
> Robert
>
>
> ---------------------------------------------------------------------
> 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: <[EMAIL PROTECTED]>
> For additional commands, e-mail: <[EMAIL PROTECTED]>
>
>



---------------------------------------------------------------------
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: <[EMAIL PROTECTED]>
For additional commands, e-mail: <[EMAIL PROTECTED]>

Reply via email to