You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Richard In Public <ed...@blueyonder.co.uk> on 2003/02/20 21:35:40 UTC

CmdLine not honouring web.xml parameters?

Hi,

1.  I have finally managed to generate a *static* version of a web project
by invoking Cocoon-2 from the *command line*.  And it only took 4 days ;-)

2.  My final problem was of the "java.sql.SQLException: no suitable driver"
variety, mentioned several times in posts to this mailing list.  My pages
were served without error by Tomcat but crashed when generated from the
command line.  Posts dealing with this problem focused on the web.xml and
cocoon.xconf configuration files - mine were clearly correct.

3.  This post from Conrad Wood pointed me to the answer:
http://www.mail-archive.com/cocoon-users@xml.apache.org/msg07701.html

4.  I tested my theory by adding the following lines to the
org.spache.cocoon.Main.java file, rebuilding the cocoon.war file and
updating my cocoon webapp within my tomcat installation:

public class Main {

    static {
         try {
             Class.forName("com.mysql.jdbc.Driver");
         } catch (Exception ex) {
              System.err.println("Unable to load driver.");
         }
    }

    ..//...

5.  It would seem that the web.xml files is not being processed by the
command line tool.  [I am using the -c option to set my context dir as
%CATALINA_HOME%/webapps/cocoon (contains WEB-INF folder and sitemap).

Am I doing something stupid or is this a genuine bug?

Richard


Windows XP
Tomcat4.1.18
Cocoon-2.1-dev

-----------------------------------------
    Relevant Portion of web.xml
-----------------------------------------
<init-param>
<param-name>load-class</param-name>
<param-value>
       com.mysql.jdbc.Driver
</param-value>
</init-param>

-----------------------------------------
    Relevant Portion of web.xml
-----------------------------------------

<datasources>
    <jdbc name="mysqldb">
    <pool-controller max="10" min="5"/>
    <dburl>jdbc:mysql://localhost:3306/lifeproj</dburl>
    <user>root</user>
    <password></password>
    </jdbc>
</datasources>

-----------------------------------------
    Relevant Portion of myxsp.xsp
-----------------------------------------

<esql:connection>
<esql:pool>lifeprojdb</esql:pool>
<!--esql:dburl>jdbc:mysql://localhost:3306/lifeproj</esql:dburl>
<esql:driver>com.mysql.jdbc.Driver</esql:driver-->
<esql:execute-query>
<esql:query>
----------------------------------------------------------------------------
----------------
    My .bat file (modified version of
http://wiki.cocoondev.org/Wiki.jsp?page=CommandLine)
----------------------------------------------------------------------------
-----------------

@echo off
cls
:: -------------------------------------------------------------------------
----
:: run.bat - Win32 Run Script for Apache Cocoon
::
:: $Id: run.bat,v 1.3 2002/03/06 15:44:57 nicolaken Exp $
:: -------------------------------------------------------------------------
----
:: ----- Verify and Set Required Environment
Variables -------------------------
if not "%JAVA_HOME%" == "" goto gotJavaHome
echo You must set JAVA_HOME to point at your Java Development Kit
installation
goto cleanup
:gotJavaHome
:: ----- Verify and Set Tomcat Location (UV
10/1/03) ---------------------------
if not "%TOMCAT_HOME%" == "" goto gotTomcatHome
echo You must set TOMCAT_HOME to point to your Tomcat installation
goto cleanup
:gotTomcatHome
:: ----- Verify and Set Required Environment
Variables -------------------------
if not "%COCOON_LIB%" == "" goto gotCocoonLib
set COCOON_LIB=.\WEB-INF\lib
:gotCocoonLib
if not "%COCOON_WORK%" == "" goto gotCocoonWork
set COCOON_WORK=.\work
:gotCocoonWork
:: ----- Set Up The Runtime
Classpath ------------------------------------------
set CP=%JAVA_HOME%\lib\tools.jar;%COCOON_WORK%
call appendcp.bat %COCOON_LIB%\avalon-framework-4.1.3.jar
call appendcp.bat %COCOON_LIB%\batik-all-1.5b2.jar
call appendcp.bat %COCOON_LIB%\chaperon-20030208.jar
call appendcp.bat %COCOON_LIB%\cocoon-2.1-dev.jar
call appendcp.bat %COCOON_LIB%\cocoon-authentication-fw-block.jar
call appendcp.bat %COCOON_LIB%\cocoon-bsf-block.jar
call appendcp.bat %COCOON_LIB%\cocoon-batik-block.jar
call appendcp.bat %COCOON_LIB%\cocoon-chaperon-block.jar
call appendcp.bat %COCOON_LIB%\cocoon-databases-block.jar
call appendcp.bat %COCOON_LIB%\cocoon-fop-block.jar
call appendcp.bat %COCOON_LIB%\cocoon-hsqldb-block.jar
call appendcp.bat %COCOON_LIB%\cocoon-html-block.jar
call appendcp.bat %COCOON_LIB%\cocoon-jfor-block.jar
call appendcp.bat %COCOON_LIB%\cocoon-itext-block.jar
call appendcp.bat %COCOON_LIB%\cocoon-jsp-block.jar
::call appendcp.bat %COCOON_LIB%\cocoon-linkrewriter-block.jar
call appendcp.bat %COCOON_LIB%\cocoon-lucene-block.jar
call appendcp.bat %COCOON_LIB%\cocoon-naming-block.jar
call appendcp.bat %COCOON_LIB%\cocoon-php-block.jar
call appendcp.bat %COCOON_LIB%\cocoon-poi-block.jar
call appendcp.bat %COCOON_LIB%\cocoon-portal-fw-block.jar
call appendcp.bat %COCOON_LIB%\cocoon-profiler-block.jar
call appendcp.bat %COCOON_LIB%\cocoon-proxy-block.jar
call appendcp.bat %COCOON_LIB%\cocoon-python-block.jar
call appendcp.bat %COCOON_LIB%\cocoon-samples-block.jar
call appendcp.bat %COCOON_LIB%\cocoon-scratchpad.jar
call appendcp.bat %COCOON_LIB%\cocoon-session-fw-block.jar
call appendcp.bat %COCOON_LIB%\cocoon-slide-block.jar
call appendcp.bat %COCOON_LIB%\cocoon-swf-block.jar
call appendcp.bat %COCOON_LIB%\cocoon-velocity-block.jar
call appendcp.bat %COCOON_LIB%\cocoon-web3-block.jar
call appendcp.bat %COCOON_LIB%\commons-collections-2.1.jar
call appendcp.bat %COCOON_LIB%\commons-discovery,jar
call appendcp.bat %COCOON_LIB%\commons-httpclient-20030210.jar
call appendcp.bat %COCOON_LIB%\commons-jxpath-1.0.jar
call appendcp.bat %COCOON_LIB%\commons-logging-1.0.jar
call appendcp.bat %COCOON_LIB%\cornerstone-20021213.jar
call appendcp.bat %COCOON_LIB%\cornerstone-excalibur-thread-20021213.jar
call appendcp.bat
%COCOON_LIB%\cornerstone-excalibur-threadcontext-20021213.jar
call appendcp.bat %COCOON_LIB%\excalibur-altrmi-common-20030116.jar
call appendcp.bat %COCOON_LIB%\excalibur-altrmi-registry-20030116.jar
call appendcp.bat %COCOON_LIB%\excalibur-altrmi-server-impl-20030116.jar
call appendcp.bat
%COCOON_LIB%\excalibur-altrmi-server-interfaces-20030116.jar
call appendcp.bat %COCOON_LIB%\excalibur-cli-1.0.jar
call appendcp.bat %COCOON_LIB%\excalibur-collections-20020820.jar
call appendcp.bat %COCOON_LIB%\excalibur-component-20020916.jar
call appendcp.bat %COCOON_LIB%\excalibur-concurrent-20020820.jar
call appendcp.bat %COCOON_LIB%\excalibur-datasource-vm14-20021121.jar
call appendcp.bat %COCOON_LIB%\excalibur-instrument-20021108.jar
call appendcp.bat %COCOON_LIB%\excalibur-io-1.1.jar
call appendcp.bat %COCOON_LIB%\excalibur-logger-20020820.jar
call appendcp.bat %COCOON_LIB%\excalibur-monitor-20020820.jar
call appendcp.bat %COCOON_LIB%\excalibur-pool-20020820.jar
call appendcp.bat %COCOON_LIB%\excalibur-sourceresolve-20030130.jar
call appendcp.bat %COCOON_LIB%\excalibur-store-20020820.jar
call appendcp.bat %COCOON_LIB%\excalibur-util-1.0.jar
call appendcp.bat %COCOON_LIB%\excalibur-xmlutil-20030130.jar
call appendcp.bat %COCOON_LIB%\hsqldb-1.7.1.jar
call appendcp.bat %COCOON_LIB%\Jisp2.0.1.jar
call appendcp.bat %COCOON_LIB%\logkit-1.1.jar
call appendcp.bat %COCOON_LIB%\mysql-connector-java-2.0.14-bin.jar
call appendcp.bat %COCOON_LIB%\pizza-1.1.jar
call appendcp.bat %COCOON_LIB%\slide-kernel-20020130.jar
call appendcp.bat %COCOON_LIB%\resolver-20021114.jar
call appendcp.bat %COCOON_LIB%\velocity-1.2.jar
call appendcp.bat %COCOON_LIB%\xercesImpl-2.1.0.jar
call appendcp.bat %COCOON_LIB%\xsltc-20030211.jar
:: Removed because the classpath it generates is too long:
rem for %%i in (WEB-INF\lib\*.jar) do call appendcp.bat %%i
call appendcp.bat %TOMCAT_HOME%\common\lib\servlet.jar
:: Required for Java 1.3
call appendcp.bat %TOMCAT_HOME%\common\lib\xml-apis.jar
call appendcp.bat %TOMCAT_HOME%\common\lib\xercesImpl-2.1.0.jar
call appendcp.bat %TOMCAT_HOME%\common\lib\xalan-2.4.1.jar
::call appendcp.bat %TOMCAT_HOME%\common\lib\batik-all-1.5b1.jar
:: ----- Run
Cocoon ------------------------------------------------------------
if "%OS%" == "Windows_NT" goto nt
%JAVA_HOME%\bin\java.exe %COCOON_OPTS% -classpath %CP%
org.apache.cocoon.Main %1 %2 %3 %4 %5 %6 %7 %8 %9
:nt
%JAVA_HOME%\bin\java.exe %COCOON_OPTS% -classpath %CP%
org.apache.cocoon.Main %*
:: ----- Cleanup the
environment -----------------------------------------------
:cleanup
set CP=
----------------------------------------------------------------------------
----------------
    Command Line Instruction
----------------------------------------------------------------------------
-----------------

::C:\ApplicationHome\jakarta-tomcat-4.1.18-LE-jdk14\webapps\cocoon>mybat.bat
 -c "C:\ApplicationHome\jakarta-tomcat-4.1.18-::LE-jdk14 \webapps\cocoon" -C
WEB-INF/cocoon.xconf -u INFO -d out -b brokenLinks.txt
myproject/homepage.html


---------------------------------------------------------------------
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: CmdLine not honouring web.xml parameters?

Posted by Richard In Public <ed...@blueyonder.co.uk>.
Upayavira,

Thanks for your response.  Specifying the database connection parameters
within the esql does work.  However, I would like to bring this to the
attention of the cocoon team so that this important feature can be provided.
I'll hang if you're going to send in a patch.  Otherwise I will have a go at
that.

Regards,

Richard


----- Original Message -----
From: "Upayavira" <uv...@upaya.co.uk>
To: "Richard In Public" <ed...@blueyonder.co.uk>;
<co...@xml.apache.org>
Sent: Friday, February 21, 2003 10:11 AM
Subject: Re: CmdLine not honouring web.xml parameters?


> Richard,
>
> I have spent some time pouring over the code of the command line
interface. The
> parameters that Tomcat gets from web.xml need to be provided to the
command
> line interface as command line parameters. However, I do not recall an
option to
> force-load classes, which would be required for JDBC drivers.
>
> It shouldn't be too hard to do - just copy some code over from the
CocoonServlet
> to the Main.java. I'll see if I can come up with a patch this weekend.
>
> As I've not been able to get JDBC to work very well myself, I may not be
able to
> test it very well, though.
>
> As a short term solution, you can specify the dburl, driver, user and
password
> using   <esql:driver>, <esql:dburl>,  <esql:username> and <esql:password>
within
> your <esql:connection>. This will avoid the reference in web.xml. It
looses your
> connection pooling, but it should work.
>
> Hope that helps.
>
> Regards, Upayavira
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: cocoon-users-help@xml.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-users-help@xml.apache.org


Re: CmdLine not honouring web.xml parameters?

Posted by Upayavira <uv...@upaya.co.uk>.
Richard,

I have spent some time pouring over the code of the command line interface. The 
parameters that Tomcat gets from web.xml need to be provided to the command 
line interface as command line parameters. However, I do not recall an option to 
force-load classes, which would be required for JDBC drivers.

It shouldn't be too hard to do - just copy some code over from the CocoonServlet 
to the Main.java. I'll see if I can come up with a patch this weekend.

As I've not been able to get JDBC to work very well myself, I may not be able to 
test it very well, though.

As a short term solution, you can specify the dburl, driver, user and password 
using   <esql:driver>, <esql:dburl>,  <esql:username> and <esql:password> within 
your <esql:connection>. This will avoid the reference in web.xml. It looses your 
connection pooling, but it should work.

Hope that helps.

Regards, Upayavira


---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-users-help@xml.apache.org