Building JOnAS
On this page I'm going to collect notes on building JOnAS with CACAO and GNU Classpath using ecj (the bytecode version) as Java compiler.
Wohoo! Today, 6.5.2006 2:44, I could for the first time build JOnAS with a CACAO/GNU Classpath/ecj toolchain!
Some Things you Might Need
AntRmicAdaptor - A compiler adaptor for using the rmic tool of GNU Classpath.
BootPackages - do not forget to add a META-INF/INDEX.LIST to your glibj.zip)
WSDL XML Errors
You may experience WSDL XML Errors when building JOnAS with CACAO. I have found out that this errors are indirectly caused by the wrong XML classes to be used. The method javax.xml.parsers.DocumentBuilderFactory.newInstance() should return an instance of
org.apache.xerces.jaxp.DocumentBuilderFactoryImpl
However, the returned instance is of type
gnu.xml.dom.DomDocumentBuilderFactory
(the default in case no other factory class could be found).
Lots of detective work turned up two things:
CACAO's getResources implementation does not remove a leading / from the resource name.
This is fixed now.
The xerxes jar containing the right class is not searched. It should be an endorsed jar, but I have not witnessed ant setting the system properties accordingly. I do not know, yet, where CACAO should get the info to search this jar.
Temporary Workaround: Put the file externals/endorsed/xercesImpl.jar from the JOnAS distribution at the beginning of the BOOTCLASSPATH when invoking ant.
"Could not find a valid processor"
The following error can be fixed by copying the xalan.jar to your ant lib directory.
/home/edwin/ss/cvs/jonas/jonas_tests/conformance/build.xml:356: Could not find a valid processor version implementation from gnu.xml.transform.TransformerFactoryImpl
Random things I found out
the jeremie jrmic compiler passes the classpath in the CLASSPATH environment variable, not as an argument. So whatever you use as javac must respect this variable.
Steps
- get JOnAS source from CVS
- setup fake jdk
- set environment variables
edit build.xml
edit build.properties
- invoke ant
Getting JOnAS Source
For getting all JOnAS modules:
cvs -d:pserver:anonymous@cvs.forge.objectweb.org:/cvsroot/jonas login cvs -z3 -d:pserver:anonymous@cvs.forge.objectweb.org:/cvsroot/jonas co .
Setup Fake JDK
The fake jdk dir must at least contain the following:
./bin ./bin/java ./bin/javac ./lib ./lib/rt.jar ./lib/tools.jar ./jre
Here is an example of a bin/java script for executing CACAO:
#!/bin/sh
HOME="/home/edwin"
CACAO_PREFIX="$HOME/local"
CLASSPATH_PREFIX="$HOME/local/classpath"
JAVA="$CACAO_PREFIX/bin/cacao"
JAVA_ARGS="-Xmx256M"
export BOOTCLASSPATH="$CACAO_PREFIX/share/cacao/vm.zip:$CLASSPATH_PREFIX/share/classpath/glibj.zip:$CLASSPATH_PREFIX/share/classpath/tools.zip"
echo "EXECUTING" "$JAVA" $JAVA_ARGS "$@"
"$JAVA" $JAVA_ARGS "$@"
Here is the script I use as javac. It is works both as an extJavac command for ant and as the javac command called by the jeremie jrmic. It tries to execute ecj with the right arguments, and usually succeeds
Note: This is not very pretty, but I think it does the right thing. It does not add any extra jars except the two boot jars, and not even those when it is called with an explicit -bootclasspath argument.
#!/bin/bash
# we use arrays in case we must handle arguments containing whitespace
declare -a JAVA_ARGS
declare -a bootclasspath_args
declare -a classpath_args
### Configuration ###
HOME="/home/edwin"
CACAO_PREFIX="$HOME/local"
CLASSPATH_PREFIX="$HOME/local/classpath"
JAVA="$CACAO_PREFIX/bin/cacao"
JAVA_ARGS=("-Xmx256M")
export BOOTCLASSPATH="$CACAO_PREFIX/share/cacao/vm.zip:$CLASSPATH_PREFIX/share/classpath/glibj.zip"
ECJ_CLASS="org.eclipse.jdt.internal.compiler.batch.Main"
ECJ_JAR=$HOME/nobackup/ecj.jar
# Build default -bootclasspath and -classpath arguments from the environment
if [ x"$BOOTCLASSPATH" != x"" ] ; then
bootclasspath_args=("-bootclasspath" "$BOOTCLASSPATH")
fi
if [ x"$CLASSPATH" != x"" ] ; then
classpath_args=("-classpath" "$CLASSPATH")
fi
# Don't override -classpath and -bootclasspath specified by the caller
for arg in "$@" ; do
case "$arg" in
-cp | -classpath)
classpath_args=()
;;
-bootclasspath)
bootclasspath_args=()
;;
esac
done
# execute ecj
echo "EXECUTING ecj WITH:" "$JAVA" "${JAVA_ARGS[@]}" -cp "$ECJ_JAR" "$ECJ_CLASS" "${bootclasspath_args[@]}" "${classpath_args[@]}" "$@"
"$JAVA" "${JAVA_ARGS[@]}" -cp "$ECJ_JAR" "$ECJ_CLASS" "${bootclasspath_args[@]}" "${classpath_args[@]}" "$@"
Environment Variables
Export the following environment variables:
- BOOTCLASSPATH
This should include vm.zip of CACAO and glibj.zip and tools.zip of Classpath. (I'm not sure if the latter is necessary.)
- JAVA_HOME
- Set this to your fake jdk directory.
- JONAS_ROOT
- Where you want to put JOnAS.
- CATALINA_HOME
Where to find Tomcat. Needed for the install_tomcat target.
- PATH
Set this to $JAVA_HOME/bin:$PATH
To work aroung the XML problem, the Xerces jar should be at the start of the BOOTCLASSPATH. I prepend it in my bin/java script.
Changes to build.xml
Modify build.xml in the jonas dir to use the GNU Classpath rmic compiler:
Index: build.xml
===================================================================
RCS file: /cvsroot/jonas/jonas/build.xml,v
retrieving revision 1.261
diff -u -p -r1.261 build.xml
--- build.xml 19 Apr 2006 07:45:24 -0000 1.261
+++ build.xml 4 May 2006 18:22:05 -0000
@@ -61,7 +61,7 @@
<property environment="myenv" />
<property name="jonas.root" value="${myenv.JONAS_ROOT}" />
<property name="ant.home" value="${myenv.ANT_HOME}" />
- <property name="javac.encoding" value="iso8859-1" />
+ <property name="javac.encoding" value="latin1" />
<property name="pkg.dir" value="${user.home}" />
<property name="externals.dir" value="externals" />
@@ -332,7 +332,7 @@
<!-- build stub and skeleton for the class given by arg classname -->
<target name="stub" unless="${done}">
<echo message="doing stubs/skels ${classname} for rmi/jrmp and rmi/iiop" />
- <rmic compiler="sun"
+ <rmic compiler="org.apache.tools.ant.taskdefs.rmic.GNUClasspathRmic"
iiop="true"
iiopopts="-always"
stubversion="${stub.version}"
Changes to build.properties
I changed build.properties in the jonas directory to only use the jeremie protocol. Don't know if that is necessary.
Index: build.properties =================================================================== RCS file: /cvsroot/jonas/jonas/build.properties,v retrieving revision 1.51 diff -u -p -r1.51 build.properties --- build.properties 11 Aug 2005 12:37:47 -0000 1.51 +++ build.properties 4 May 2006 16:14:49 -0000 @@ -32,4 +32,4 @@ opt.javac.deprecation off # protocols for Carol (jrmp,jeremie,iiop,cmi) needed by the JOnAS ejbjar task -protocols.names=jrmp,jeremie,iiop +protocols.names=jeremie
Invoking ant
In the jonas directory do:
ant -Dbuild.compiler=extJavac install
For building JOnAS-Tomcat do:
ant -Dbuild.compiler=extJavac install_tomcat
Errors that may arise
stub:
[echo] doing stubs/skels org.objectweb.jonas.adm.Adm for rmi/jrmp and rmi/iiop
[rmic] RMI Compiling 1 class to /nfs/nfstmp/twisti/jonas/jonas/classes/common
[rmic] IIOP has been turned on.
[rmic] IIOP Options: -always
[rmic] <whole classpath snip'ed> class not found.
You need to get a GNU Classpath version > 0.91. This is a bug in GNU's rmic (hint: -classpath option).
mejb_jonasejbjar: Trying to override old definition of task ejbjar [ejbjar] Unable to load dependency analyzer: org.apache.tools.ant.util.depend.bcel.FullAnalyzer - dependent class not found: org.apache.bcel.classfile.ClassParser not found in <snip>
Debian does not have a link to bcel.jar in /usr/share/ant/lib.