You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Alessio Sangalli <al...@manoweb.com> on 2002/11/10 21:11:57 UTC

Using Cocoon from the command

For the first time in a year and a half I want to use Cocoon from the 
command line. I will be able to use the results in an environment 
without Cocoon or Java and I won't have to generate every time the data 
etc etc.

I use Sun's JDK 1.4.1_01, Cocoon 2.0.3, on Linux.

I've found at least of informations on dejanews and the mail list archives:

http://groups.google.com/groups?q=cocoon+command+line&hl=en&lr=&ie=UTF-8&oe=UTF-8&safe=off&selm=jPAd8.9020%240C1.767012%40newsread1.prod.itd.earthlink.net&rnum=4

Uh, I should have looked at the code!
I answered my own simple question. For reference:
java -classpath . org.apache.cocoon.Main  --help

-Mark

and:

http://marc.theaimsgroup.com/?l=xml-cocoon-users&m=100439206023213&w=2

You can use Cocoon command line interface.

java org.apache.cocoon.Main -c<sourcepath> -d<resultpath>  -w<tmppath> \
-l<logfilename>  -uINFO -f<list.uris>

sourcepath : where your cocoon files are, with the sitemap and so on
resultpath : where tour HTML files go
tmppath    : a directory for tmp files
logfilename : the log file
list.uris : a file containing the list of URI your want to build using 
Cocoon


good, however WHERE should I give those command lines?

I've never compiled Cocoon by sources because in the early days of the 
2.0beta it was a pain in *** ***, and I used to download the binary 
.war. However this time I had to, because Main.class wasn't avaiable 
anywhere on a binary distribution only.

$ sh build all

will create cocoon.jar but I can't get it working; at best I get a


$ java -classpath . org.apache.cocoon.Main
Exception in thread "main" java.lang.NoClassDefFoundError: 
org/apache/avalon/framework/CascadingException
         at java.lang.ClassLoader.defineClass0(Native Method)
         at java.lang.ClassLoader.defineClass(ClassLoader.java:502)
etc etc etc..........


I tried to unzip the jar, to go directly inside and call Main.class from 
its own dir, etc


what can I do...!

bye & thank you
as






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

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


Can serializer recognize parameter in resource?

Posted by Bv Cc <bv...@hotmail.com>.
I hope serializers can do different encoding output for different language
document with using same transformers.

I defined a resource for using same transformers group transforming
different language pages. I also defined different serializers for each
enconding output. I wish serializer in resource could recognize parameters
for different "type"s , but it seems not work. How can I accomplish it.

Some sitemap.xmap code clip as below
   <map:serializer name="html" mime-type="text/html"
src="org.apache.cocoon.serialization.HTMLSerializer">
    <encoding>ISO-8859-1</encoding>
   </map:serializer>
   <map:serializer name="html-utf" mime-type="text/html"
src="org.apache.cocoon.serialization.HTMLSerializer">
    <encoding>UTF-8</encoding>
   </map:serializer>
   <map:serializer name="html-jp" mime-type="text/html"
src="org.apache.cocoon.serialization.HTMLSerializer">
    <encoding>Shift-JIS</encoding>
   </map:serializer>

and resource as

 <map:resources>
   <map:resource name="content-transform">
   <map:transform src="xsl/contlang.xsl">
    <map:parameter name="choslang" value="{pagelang}"/>
   </map:transform>
   <map:transform src="xsl/content.xsl"/>
   <map:transform src="xsl/home.xsl">
    <map:parameter name="gate-file" value="../Statics/gate.xml"/>
    <map:parameter name="menu-file" value="../docs/{gatepage}/title.xml"/>
    <map:parameter name="memo-file" value="../Statics/memo.xml"/>
    <map:parameter name="gatename" value="{gatepage}"/>
    <map:parameter name="titlename" value="{titlepage}"/>
    <map:parameter name="choslang" value="{pagelang}"/>
   </map:transform>
   <map:serialize type="{pagelang}"/>
   </map:resource>
 </map:resources>



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

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


Re: Using Cocoon from the command

Posted by Alessio Sangalli <al...@manoweb.com>.
boris wrote:

> I had to put all this jar to the classpath to work with the cli, without
> java-errors. (win98)
> I think a sidemap with minimum components don't needs all that stuff to
> compile correctly.
> A good trick to look into the jar-files is to rename it to a zip-file 
> and to
> open it with winzip. So you can find, that 'org/apache/log/Priority' 
> belongs
> to logkit-20020529.jar.


I don't have window but for the tests I used:

for i in `ls *.jar`; do echo "~~~~~~~~~$i~~~~~~~~"; jar tvf $i | grep 
KEYWORD; done

to find where needed classes are located.

I've also patched the sources, writing the needed classes inside the 
Manifest file _*IN ONLY ONE ROW*_ and not in that ugly way + updating 
all the filenames, etc (and yes, I've also commented out a lot of stuff 
from sitemap - cocoon.xconf), but I was stopped when I got the following 
error:

Exception in thread "main" java.lang.NoClassDefFoundError: 
javax/servlet/ServletConfig
         at java.lang.Class.getDeclaredConstructors0(Native Method)
         at java.lang.Class.privateGetDeclaredConstructors(Class.java:1590)
         at java.lang.Class.getConstructor0(Class.java:1762)
         at java.lang.Class.newInstance0(Class.java:276)
         at java.lang.Class.newInstance(Class.java:259)
         at 
org.apache.avalon.excalibur.component.DefaultComponentFactory.newInstance(DefaultComponentFactory.java:102)
         at 
org.apache.avalon.excalibur.component.ThreadSafeComponentHandler.initialize(ThreadSafeComponentHandler.java:98)
         at 
org.apache.avalon.excalibur.component.ExcaliburComponentManager.initialize(ExcaliburComponentManager.java:158)
         at org.apache.cocoon.Cocoon.initialize(Cocoon.java:270)
         at org.apache.cocoon.Main.main(Main.java:397)

ps I've included in CLASSPATH servlet.jar from common/lib directory of 
tomcat..........

I'm frustrated, I don't know what to do. Luckily I have a lot of spare 
time, on the train when I come back from Milan, ... any other 
suggestion? Where can I find this class or whatever it can't find?


bye
as





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

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


Re: Using Cocoon from the command

Posted by boris <bo...@web.de>.
I had to put all this jar to the classpath to work with the cli, without
java-errors. (win98)
I think a sidemap with minimum components don't needs all that stuff to
compile correctly.
A good trick to look into the jar-files is to rename it to a zip-file and to
open it with winzip. So you can find, that 'org/apache/log/Priority' belongs
to logkit-20020529.jar.

rem ### setting classpath for cocoon-cli ####
set CLASSPATH=c:\programme\apache group\tomcat
4.1\webapps\cocoon\WEB-INF\lib\cocoon-2.0.3.jar
set CLASSPATH=c:\programme\apache group\tomcat
4.1\webapps\cocoon\WEB-INF\lib\avalon-framework-20020627.jar;%CLASSPATH%
set CLASSPATH=c:\programme\apache group\tomcat
4.1\webapps\cocoon\WEB-INF\lib\avalon-excalibur-vm12-20020705.jar;%CLASSPATH
%
set CLASSPATH=c:\programme\apache group\tomcat
4.1\webapps\cocoon\WEB-INF\lib\logkit-20020529.jar;%CLASSPATH%
set CLASSPATH=c:\programme\apache group\tomcat
4.1\webapps\cocoon\WEB-INF\lib\cocoon-scratchpad.jar;%CLASSPATH%
set CLASSPATH=c:\programme\apache group\tomcat
4.1\common\lib\servlet.jar;%CLASSPATH%
set CLASSPATH=c:\programme\apache group\tomcat
4.1\webapps\cocoon\WEB-INF\lib\resolver-20020130.jar;%CLASSPATH%
set CLASSPATH=c:\programme\apache group\tomcat
4.1\webapps\cocoon\WEB-INF\lib\pizza-1.1.jar;%CLASSPATH%
set CLASSPATH=c:\programme\apache group\tomcat
4.1\webapps\cocoon\WEB-INF\lib\velocity-1.2.jar;%CLASSPATH%
set CLASSPATH=c:\programme\apache group\tomcat
4.1\webapps\cocoon\WEB-INF\lib\batik-all-1.5b2.jar;%CLASSPATH%
set CLASSPATH=c:\programme\apache group\tomcat
4.1\webapps\cocoon\WEB-INF\lib\hsqldb-1.61.jar;%CLASSPATH%
set CLASSPATH=c:\programme\apache group\tomcat
4.1\webapps\cocoon\WEB-INF\classes\;%CLASSPATH%

----- Original Message -----
From: "Alessio Sangalli" <al...@manoweb.com>
To: <co...@xml.apache.org>
Sent: Tuesday, November 12, 2002 7:08 PM
Subject: Re: Using Cocoon from the command


>
>
> Darren Petrie wrote:
>
> unfortunately, I've talked too early. Althought an invocation with a
> simple --help parameter works, when I try it with all the arguments:
>
> $ java org.apache.cocoon.Main -c
> ~/java/jakarta-tomcat-4.1.12-LE-jdk14/webapps -d ~/lirc/cocoon/ -w /tmp/
> -l ~/lirc/cocoon-log.txt -uINFO -f ~/lirc/uri-list
> Exception in thread "main" java.lang.NoClassDefFoundError:
> org/apache/log/Priority
>          at org.apache.cocoon.Main.main(Main.java:312)
>
> I've tried to patch Manifest.mf in the sources and rebuild, but it's
> always the same... :(
>
> Why such a powerful interface, the command line, should be so difficult
> to use?
>
> bye, thank you...
> as
>
>
>
>
> ---------------------------------------------------------------------
> Please check that your question  has not already been answered in the
> FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>
>
> To unsubscribe, e-mail:     <co...@xml.apache.org>
> For additional commands, e-mail:   <co...@xml.apache.org>
>



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

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


Re: Using Cocoon from the command

Posted by Bertrand Delacretaz <bd...@codeconsult.ch>.
On Wednesday 13 November 2002 15:17, Alessio Sangalli wrote:
>. . .
> I promise when I'll get this working I will prepare a website with the
> instructions, 
>. . .

Cool!

A nice place to do this is the CocoonDocoWiki at 
http://outerthought.net/wiki/Wiki.jsp, you're much welcome to create a page 
there with this info.

This is, unless you want to write a how-to in xdocs format directly, in which 
case the info can be found at http://xml.apache.org/cocoon/howto/index.html.

-- 
 Bertrand Delacrétaz (codeconsult.ch, jfor.org)

 buzzwords: XML, java, XSLT, Cocoon, FOP, mentoring/teaching/coding.
 blogspace http://www.codeconsult.ch/bertrand

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

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


Re: Using Cocoon from the command

Posted by Alessio Sangalli <al...@manoweb.com>.
Darren Petrie wrote:

> Looks like you need to add more to your classpath.  (logkit-20020529.jar)
> Try adding all the .jar files in cocoon/WEB-INF/lib to your classpath.


I promise when I'll get this working I will prepare a website with the 
instructions, I thoutgh it would have been much simplier using Cocoon 
from the command line than through a server....



bye! thank you
as






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

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


Re: Using Cocoon from the command

Posted by Darren Petrie <dp...@anteon.com>.
Looks like you need to add more to your classpath.  
(logkit-20020529.jar)
Try adding all the .jar files in cocoon/WEB-INF/lib to your classpath.

Darren

On Tuesday, November 12, 2002, at 07:08  PM, Alessio Sangalli wrote:

> unfortunately, I've talked too early. Althought an invocation with a
> simple --help parameter works, when I try it with all the arguments:
>
> $ java org.apache.cocoon.Main -c
> ~/java/jakarta-tomcat-4.1.12-LE-jdk14/webapps -d ~/lirc/cocoon/ -w 
> /tmp/
> -l ~/lirc/cocoon-log.txt -uINFO -f ~/lirc/uri-list
> Exception in thread "main" java.lang.NoClassDefFoundError:
> org/apache/log/Priority
>          at org.apache.cocoon.Main.main(Main.java:312)
>
> I've tried to patch Manifest.mf in the sources and rebuild, but it's
> always the same... :(
>
> Why such a powerful interface, the command line, should be so difficult
> to use?
>
> bye, thank you...
> as


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

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


Re: Using Cocoon from the command

Posted by Alessio Sangalli <al...@manoweb.com>.

Darren Petrie wrote:

unfortunately, I've talked too early. Althought an invocation with a 
simple --help parameter works, when I try it with all the arguments:

$ java org.apache.cocoon.Main -c 
~/java/jakarta-tomcat-4.1.12-LE-jdk14/webapps -d ~/lirc/cocoon/ -w /tmp/ 
-l ~/lirc/cocoon-log.txt -uINFO -f ~/lirc/uri-list
Exception in thread "main" java.lang.NoClassDefFoundError: 
org/apache/log/Priority
         at org.apache.cocoon.Main.main(Main.java:312)

I've tried to patch Manifest.mf in the sources and rebuild, but it's 
always the same... :(

Why such a powerful interface, the command line, should be so difficult 
to use?

bye, thank you...
as




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

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


Re: Using Cocoon from the command

Posted by Alessio Sangalli <al...@manoweb.com>.

Darren Petrie wrote:

[alesan@valkyrie lib]$ pwd
/home/alesan/java/jakarta-tomcat-4.1.12-LE-jdk14/webapps/cocoon/WEB-INF/lib

[alesan@valkyrie lib]$ export CLASSPATH=".:/home/alesan/java/cocoon-2.0.
.3/build/cocoon/classes/:avalon-framework-20020627.jar:avalon-excalibur-vm1
4-20020705.jar"

[alesan@valkyrie lib]$ java org.apache.cocoon.Main --help
------------------------------------------------------------------------
Apache Cocoon 2.0.3
Copyright (c) 1999-2002 Apache Software Foundation. All rights reserved.
------------------------------------------------------------------------

Usage: java org.apache.cocoon.Main [options] [targets]


ok now it works. What a chaos however!!!

bye
as




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

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


Re: Using Cocoon from the command

Posted by Darren Petrie <dp...@anteon.com>.
I too had the same problems getting the command line to run.  The jar  
files needed can be found in webapps/cocoon/WEB-INF/lib.  I ran the  
class files from the build directory cocoon-2.0.3/build/cocoon/classes.  
  The following worked for me.  Maybe this will help.

cd /usr/local/jakarta-tomcat-4.1.12/webapps/cocoon/WEB-INF/lib
setenv CLASSPATH  
".:/usr/local/cocoon-2.0.3/build/cocoon/classes:avalon-framework- 
20020627.jar:avalon-excalibur-vm12-20020705.jar"
java org.apache.cocoon.Main --help

Hope that helps.

Darren


On Monday, November 11, 2002, at 07:02  PM, Alessio Sangalli wrote:

>
> Ugo Cei wrote:
>
>> It SHOULD be possible to just unpack the cocoon.war file from the  
>> binary
>> distribution, cd to WEB-INF/lib and run:
>>
>>     java -jar cocoon-2.0.3.jar
>>
>> However, the Manifest in the JAR is wrong, since it contains:
>>
>> Class-Path: avalon-framework-4.1.2.jar avalon-excalibur-4.1.jar batik-
>>  libs-1.1.1.jar bsf-2.2.jar fop-0.20.3rc.jar jakarta-regexp-1.2.jar js
>>  tyle.jar logkit-1.0.1.jar rhino-1.5r3.jar xalan-2.3.1.jar xercesImpl-
>>  2.0.0.jar xml-apis.jar xt-19991105.jar
>>
>> But the versions of the libraries are not those. For instance, it  
>> should
>> be avalon-framework-20020627.jar instead.
>
> I've tried to modify the MANIFEST file but at the end it didn't work  
> the
> same. It's likely I'm not able to build a JAR, however it seems Cocoon
> can't be used from the command line right now out-of-the-box, am I  
> wrong?
>
> boh
> ciao
> as
>
>
>
>
>
> ---------------------------------------------------------------------
> Please check that your question  has not already been answered in the
> FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>
>
> To unsubscribe, e-mail:     <co...@xml.apache.org>
> For additional commands, e-mail:   <co...@xml.apache.org>
>
Darren Petrie
dpetrie@anteon.com


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

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


Re: Using Cocoon from the command

Posted by Alessio Sangalli <al...@manoweb.com>.
Ugo Cei wrote:

> It SHOULD be possible to just unpack the cocoon.war file from the binary
> distribution, cd to WEB-INF/lib and run:
>
>     java -jar cocoon-2.0.3.jar
>
> However, the Manifest in the JAR is wrong, since it contains:
>
> Class-Path: avalon-framework-4.1.2.jar avalon-excalibur-4.1.jar batik-
>  libs-1.1.1.jar bsf-2.2.jar fop-0.20.3rc.jar jakarta-regexp-1.2.jar js
>  tyle.jar logkit-1.0.1.jar rhino-1.5r3.jar xalan-2.3.1.jar xercesImpl-
>  2.0.0.jar xml-apis.jar xt-19991105.jar
>
> But the versions of the libraries are not those. For instance, it should
> be avalon-framework-20020627.jar instead.

I've tried to modify the MANIFEST file but at the end it didn't work the 
same. It's likely I'm not able to build a JAR, however it seems Cocoon 
can't be used from the command line right now out-of-the-box, am I wrong?

boh
ciao
as





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

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


Re: Using Cocoon from the command

Posted by Ugo Cei <u....@cbim.it>.
Sylvain Wallez wrote:
> Alessio Sangalli wrote:
>> I tried to unzip the jar, to go directly inside and call Main.class 
>> from its own dir, etc
>> what can I do...!
> You should set the correct class path ;-)
> 
> Look at the stack trace : one of the first classes loaded from Avalon by 
> Cocoon can't be found. That's because your classpath is set to "." and 
> so includes only Cocoon's own classes (guessing you start this from the 
> "build/classes" directory).
> 
> Hope this helps,
> Sylvain
> 

It SHOULD be possible to just unpack the cocoon.war file from the binary 
distribution, cd to WEB-INF/lib and run:

	java -jar cocoon-2.0.3.jar

However, the Manifest in the JAR is wrong, since it contains:

Class-Path: avalon-framework-4.1.2.jar avalon-excalibur-4.1.jar batik-
  libs-1.1.1.jar bsf-2.2.jar fop-0.20.3rc.jar jakarta-regexp-1.2.jar js
  tyle.jar logkit-1.0.1.jar rhino-1.5r3.jar xalan-2.3.1.jar xercesImpl-
  2.0.0.jar xml-apis.jar xt-19991105.jar

But the versions of the libraries are not those. For instance, it should 
be avalon-framework-20020627.jar instead.

Maybe the simplest solution is to extract the META-INF/MANIFEST.MF file 
from the JAR, fix it and update the JAR with the correct version.

	Ugo

-- 
Ugo Cei - http://www.beblogging.com/blog/


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

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


Re: Using Cocoon from the command

Posted by Sylvain Wallez <sy...@anyware-tech.com>.
Alessio Sangalli wrote:

<snip/>

> $ java -classpath . org.apache.cocoon.Main
> Exception in thread "main" java.lang.NoClassDefFoundError: 
> org/apache/avalon/framework/CascadingException
>         at java.lang.ClassLoader.defineClass0(Native Method)
>         at java.lang.ClassLoader.defineClass(ClassLoader.java:502)
> etc etc etc..........
>
>
> I tried to unzip the jar, to go directly inside and call Main.class 
> from its own dir, etc
>
>
> what can I do...!


You should set the correct class path ;-)

Look at the stack trace : one of the first classes loaded from Avalon by 
Cocoon can't be found. That's because your classpath is set to "." and 
so includes only Cocoon's own classes (guessing you start this from the 
"build/classes" directory).

Hope this helps,
Sylvain

-- 
Sylvain Wallez                                  Anyware Technologies
http://www.apache.org/~sylvain           http://www.anyware-tech.com
{ XML, Java, Cocoon, OpenSource }*{ Training, Consulting, Projects }



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

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