(cc'ed to taglibs-user since if nothing else, this is a useful install
reference)
I was just updating jakarta-taglibs from CVS, and building, and.. ho hum,
exceptions.. read the README, do what it says.. more exceptions.. ARGHH why do
Apache projects have to be such a pain to build?!
So instead of hacking my classpath as I usually do, I thought I'd do a proper
audit of
- what's wrong
- why it's wrong
- how it could be fixed
A weekend and few evenings later, here's the results, and a proposed patch.
I'd appreciate it if someone could look at it and let me know if it's decent.
I'll then document the parts deemed okay, and hopefully we can get them
committed.
Thanks :)
--Jeff
--------------------------------------
Review of jakarta-taglibs buildability
27/2/2001
Jeff Turner <[EMAIL PROTECTED]>
--------------------------------------
First I should note that the README file does not provide instructions beyond:
- get a binary dist of Ant (version unspecified, and it *does* make a diff as
I'll show) or build it from source.
- "install" JAXP (version unspecified; again, it matters)
There's much more decent docs in doc/sourcedist.html, but it's not referred to
as anything one would need for a straight build. So for now let's forget about
the current docs, which don't address many of the issues below, and think about
fixing them afterwards.
>From a clean CVS checkout:
1) --------------------------------------
ACTION: ./build.sh
PROBLEM:
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/tools/ant/Main
CAUSE:
build.sh sets the classpath to include $ANT_HOME/lib/ant.jar
However for a CVS checkout and "./build.sh" of Ant, this file does not exist.
This *does* exist if:
- one does a "./build.sh dist" of Ant
- gets the binary distribution of Ant in ../jakarta-ant
RESOLUTION:
Do a "./build.sh" in jakarta-ant and manually set
ANT_HOME=`pwd`/../jakarta-ant/dist
2) --------------------------------------
ACTION: build.sh
PROBLEM:
BUILD FAILED
No JAXP compliant XML parser found. See http://java.sun.com/xml for the
reference implementation.
--- Nested Exception ---
java.lang.ClassNotFoundException: javax.xml.parsers.SAXParserFactory
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
CAUSE: jaxp.jar is missing from the classpath.
There is no indication that jaxp.jar is needed other than this line in README:
"In addition, you will need to install a JAXP-compatible XML parser". "Install"
is left undefined.
RESOLUTION:
Rather than ask users to set their CLASSPATH, let's make use of the build.sh
mechanism: build.sh should include a JAXP_JAR variable, with a sensible default
($ANT_HOME/lib/jaxp.jar).
Added JAXP_JAR variable to build.sh, with default $ANT_HOME/lib/jaxp.jar. This
takes care of people who have a binary distribution or have built Ant with
"./build.sh dist". For those who did "./build.sh", they'll have to set JAXP_JAR
to "../jakarta-ant/lib/jaxp.jar".
3) --------------------------------------
ACTION: Set JAXP_HOME ; build.sh
PROBLEM:
BUILD FAILED
No JAXP compliant XML parser found. See http://java.sun.com/xml for the
reference implementation.
--- Nested Exception ---
java.lang.ClassNotFoundException: javax.xml.parsers.SAXParserFactory
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
CAUSE: xerces.jar not in classpath.
RESOLUTION:
The default for XERCES_JAR is "../xml-xalan/xerces.jar". Added a note that
this is *not* a typo; it's just relying on the xerces that comes with xalan.
This should be correct for users of binary and CVS Xalan distributions. For
building with an xml-xerces distribution, one should set XERCES_JAR to
something like `pwd`/../../xml/xml-xerces/java/build/xerces.jar
4) --------------------------------------
ACTION: build.sh
PROBLEM:
BUILD FAILED
/home/jeff/apache/jakarta/jakarta-taglibs/build.xml:87:
java.lang.ClassNotFoundException: org.apache.tools.ant.taskdefs.optional.TraXLiaison
--- Nested Exception ---
java.lang.ClassNotFoundException:
org.apache.tools.ant.taskdefs.optional.TraXLiaison
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
CAUSE:
Why is a core Ant task (<style>) using a taskdef marked optional in the first
place? I have submitted it as a bug to the ant-dev folks
(http://nagoya.apache.org/bugzilla/show_bug.cgi?id=699).
This is a pain, because it forces the following additional steps to get taglibs
compiling:
- If one build Ant from source, it's likely that the TraX-based tasks were not
included. I recompiled Ant with jaxp.jar (the 1.1 jaxp) in lib/optional.
- Recent builds of Ant put "core" Ant in ant.jar and optional tasks in
optional.jar. build.sh doesn't look for optional.jar in which the <style>
task implementation is (erroneously) defined, causing the build failure.
RESOLUTION:
Ant bug report filed. For now:
- Ensure that Ant is build with TraX support (put a jaxp1.1 jar in
$ANT_HOME/lib/optional, reset CLASSPATH and rebuild Ant).
- Add $ANT_HOME/lib/optional.jar to the classpath in build.sh. This doesn't
hurt non-bleeding-edge-Ant users and fixes the problem for current Ant
users.
Noting that we've hard-coded the path from $ANT_HOME to ant.jar and
optional.jar, let's un-hardcode it by giving the user an option to override the
ANT_JAR and ANT_OPT_JAR variables. This is done by modifying build.sh
appropriately.
5) --------------------------------------
ACTION: build.sh
PROBLEM:
BUILD FAILED
/home/jeff/apache/jakarta/jakarta-taglibs/build.xml:87:
java.lang.NoClassDefFoundError: javax/xml/transform/Source
--- Nested Exception ---
java.lang.NoClassDefFoundError: javax/xml/transform/Source
at java.lang.Class.forName0(Native Method)
CAUSE: jaxp1.1 not in classpath. Due to the abovementioned Ant bug
(http://nagoya.apache.org/bugzilla/show_bug.cgi?id=699), there is now a
dependency on JAXP1.1.
RESOLUTION:
Ensure that JAXP_JAR is pointing to a JAXP1.1 classes.
6) --------------------------------------
ACTION: build.sh
PROBLEM:
BUILD FAILED
/home/jeff/apache/jakarta/jakarta-taglibs/build.xml:93:
javax.xml.transform.TransformerFactoryConfigurationError:
java.lang.ClassNotFoundException: org.apache.xalan.processor.TransformerFactoryImpl
--- Nested Exception ---
javax.xml.transform.TransformerFactoryConfigurationError:
java.lang.ClassNotFoundException: org.apache.xalan.processor.TransformerFactoryImpl
at javax.xml.transform.TransformerFactory.newInstance(TransformerFactory.java:121)
CAUSE: xalan.jar not set, or old non-TraX version.
RESOLUTION: Set XALAN_JAR to a TraX-compliant xalan.jar, like the one that
comes with the JAXP1.1 package.
7) --------------------------------------
ACTION: build.sh
PROBLEM:
All chugs along fine until we get to regexp:
library:
[copy] Copying 1 file to /home/jeff/apache/jakarta/build/taglibs/regexp/META-INF
[javac] Compiling 13 source files to /home/jeff/apache/jakarta/build/taglibs/regexp
[javac]
/home/jeff/apache/jakarta/jakarta-taglibs/regexp/src/org/apache/taglibs/regexp/ExistsMatchTag.java:65:
Package org.apache.oro.text not found in import.
[javac] import org.apache.oro.text.*;
CAUSE: jakarta-oro jar not in classpath.
RESOLUTION: jakarta-oro shouldn't *have* to be in the classpath. Therefore make use of
Ant's "don't-compile-without-this-jar" feature. This is already used in build.xml; it
just wasn't applied here.
ACTION:
Add the conditional property to build.xml, and:
163c169
< <target name="regexp">
---
> <target name="regexp" if="jakarta.regexp.present">
8) --------------------------------------
PROBLEM: build.sh
CAUSE:
As above; this time with the JNDI taglib:
[javac]
/home/jeff/apache/jakarta/jakarta-taglibs/jndi/src/org/apache/taglibs/jndi/ForEachAttributeTag.java:66:
Package javax.naming not found in import.
[javac] import javax.naming.*;
9) --------------------------------------
RESOLUTION:
As above; add conditional property "jndi.present" to build.xml and make
compilation of the JNDI taglib dependent on it.
10) --------------------------------------
ACTION: build.sh
Success!! :)
Index: README
===================================================================
RCS file: /home/cvspublic/jakarta-taglibs/README,v
retrieving revision 1.5
diff -r1.5 README
60,61c60
< lib/
< ant.jar
---
> lib/ant.jar
Index: build.bat
===================================================================
RCS file: /home/cvspublic/jakarta-taglibs/build.bat,v
retrieving revision 1.8
diff -r1.8 build.bat
9a10,16
> rem ANT_JAR Pathname of the "ant.jar" file.
> rem [%ANT_HOME%/lib/ant.jar]
> rem
> rem ANT_OPT_JAR Pathname of the "optional.jar" file, containing Ant
> rem optional taskdefs (we need the style task).
> rem [%ANT_HOME%/lib/optional.jar]
> rem
26a34,36
> rem JAXP_JAR Pathname of the "jaxp.jar" file.
> rem [%ANT_HOME%/lib/jaxp.jar]
> rem
37c47,48
< rem [./.xml-xalan/xerces.jar]
---
> rem [../xml-xalan/xerces.jar]
> rem (use xerces that comes with xalan)
45a57,58
> set _ANT_JAR=%ANT_JAR%
> set _ANT_OPT_JAR=%ANT_OPT_JAR%
51a65
> set _JAXP_JAR=%JAXP_JAR%
70a85,92
> if not "%ANT_JAR%" == "" goto gotAntJar
> set ANT_JAR=%ANT_HOME%\lib\ant.jar
> :gotAntJar
>
> if not "%ANT_OPT_JAR%" == "" goto gotAntOptJar
> set ANT_OPT_JAR=%ANT_HOME%\lib\optional.jar
> :gotAntOptJar
>
90a113,116
> if not "%JAXP_JAR%" == "" goto gotJaxpJar
> set JAXP_JAR=%ANT_HOME%\lib\jaxp.jar
> :gotJaxpJar
>
102c128
< set
CP=%ANT_HOME%\lib\ant.jar;%BSF_JAR%;%BSFENGINES_JAR%;%SERVLET_JAR%;%XALAN_JAR%;%XERCES_JAR%;%JAVA_HOME%\lib\tools.jar
---
> set
>CP=%ANT_JAR%;%ANT_OPT_JAR%;%BSF_JAR%;%BSFENGINES_JAR%;%SERVLET_JAR%;%XALAN_JAR%;%XERCES_JAR%;%JAXP_JAR%;%JAVA_HOME%\lib\tools.jar
117a144,145
> set ANT_JAR=%_ANT_JAR%
> set ANT_OPT_JAR=%_ANT_OPT_JAR%
123a152
> set JAXP_JAR=%_JAXP_JAR%
127a157,158
> set _ANT_JAR=
> set _ANT_OPT_JAR=
133a165
> set _JAXP_JAR=
Index: build.sh
===================================================================
RCS file: /home/cvspublic/jakarta-taglibs/build.sh,v
retrieving revision 1.4
diff -r1.4 build.sh
9a10,16
> # ANT_JAR Pathname of the "ant.jar" file.
> # [$ANT_HOME/lib/ant.jar]
> #
> # ANT_OPT_JAR Pathname of the "optional.jar" file, containing Ant
> # optional taskdefs (we need the style task).
> # [$ANT_HOME/lib/optional.jar]
> #
26a34,36
> # JAXP_JAR Pathname of the "jaxp.jar" file.
> # [$ANT_HOME/lib/jaxp.jar]
> #
34a45
> # (use the xerces that comes with xalan)
45a57,64
> if [ "$ANT_JAR" = "" ] ; then
> ANT_JAR=$ANT_HOME/lib/ant.jar
> fi
>
> if [ "$ANT_OPT_JAR" = "" ] ; then
> ANT_OPT_JAR=$ANT_HOME/lib/optional.jar
> fi
>
70a90,93
> if [ "$JAXP_JAR" = "" ] ; then
> JAXP_JAR=$ANT_HOME/lib/jaxp.jar
> fi
>
86c109
<
CP=$ANT_HOME/lib/ant.jar:$BSF_JAR:$BSFENGINES_JAR:$SERVLET_JAR:$XALAN_JAR:$XERCES_JAR:$JAVA_HOME/lib/tools.jar
---
>
>CP=$ANT_JAR:$ANT_OPT_JAR:$BSF_JAR:$BSFENGINES_JAR:$SERVLET_JAR:$XALAN_JAR:$XERCES_JAR:$JAXP_JAR:$JAVA_HOME/lib/tools.jar
Index: build.xml
===================================================================
RCS file: /home/cvspublic/jakarta-taglibs/build.xml,v
retrieving revision 1.19
diff -r1.19 build.xml
63a64,69
> <available property="jakarta.regexp.present"
> classname="org.apache.regexp.RE" />
> <available property="jndi.present"
> classname="javax.naming.Name"/>
>
>
163c169
< <target name="regexp">
---
> <target name="regexp" if="jakarta.regexp.present">
167c173
< <target name="jndi">
---
> <target name="jndi" if="jndi.present">