Hi i'm trying to create an ant build that i can run from command prompt.
when i run the jar file containing the main method i get this:
Exception in thread "main" java.lang.NoClassDefFoundError: com/fmd/raptorurls/RaptorURLs
Caused by: java.lang.ClassNotFoundException: com.fmd.raptorurls.RaptorURLs
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
Could not find the main class: com.fmd.raptorurls.RaptorURLs. Program will exit.
here is my ant build:
<?xml version="1.0"?>
<project name="RaptorURLCheck" basedir="." default="cleanDistFiles">
<tstamp>
<format property="currentYear" pattern="yyyy" />
</tstamp>
<!-- =================================================================== -->
<!-- Global Properties - define in build.properties -->
<!-- =================================================================== -->
<property file="build.properties" />
<!-- =================================================================== -->
<!-- Paths -->
<!-- =================================================================== -->
<path id="runtime-libs">
<fileset dir="${lib.dir}">
<include name="**/*.jar" />
</fileset>
</path>
<path id="manifest-classpath">
<fileset dir="${lib.dir}">
<include name="**/*.jar" />
</fileset>
</path>
<manifestclasspath property="jar.classpath" jarfile="${lib.dir}/${project.name}.jar" >
<classpath refid="manifest-classpath" />
</manifestclasspath>
<target name="clean" >
<echo>***** Deleting files for ${project.name} *****</echo>
<delete failonerror="false" dir="${bin.dir}" />
<delete failonerror="false" dir="${dist.dir}" />
<delete failonerror="false" dir="${log.dir}" />
<delete failonerror="false" dir="${conf.dir}" />
</target>
<target name="init" depends="clean">
<echo>***** Creating required directories for ${project.name} build *****</echo>
<tstamp />
<mkdir dir="${bin.dir}" />
<mkdir dir="${dist.dir}" />
<mkdir dir="${log.dir}" />
<mkdir dir="${conf.dir}" />
</target>
<target name="compile" depends="init" >
<echo>***** Compiling source files for ${project.name} *****</echo>
<!--This javac compiles the java/src directory-->
<javac srcdir="${src.dir}" includeantruntime="false" destdir="${bin.dir}" debug="on" debuglevel="lines,var,source">
<include name="**/*.java" />
<classpath refid="runtime-libs" />
</javac>
<copy todir="${bin.dir}">
<fileset dir="${src.dir}">
<include name="**/*.html" />
<include name="**/*.css" />
</fileset>
<fileset dir="${config.dir}">
<include name="*-.xml" />
<include name="*.xsd" />
<include name="*.properties" />
</fileset>
</copy>
</target>
<target name="jar" depends="compile" description="Packages app as jar" >
<echo>***** Creating jar distribution for ${project.name} *****</echo>
<jar destfile="${lib.dir}/${project.name}.jar">
<manifest>
<attribute name="Class-Path" value="${jar.classpath}" />
<attribute name="Built-By" value="${user.name}" />
<attribute name="Main-Class" value="${main.class}" />
</manifest>
<fileset dir="${bin.dir}">
<include name="**/*.class*" />
<include name="**/*.xml" />
<include name="**/*.html" />
<include name="**/*.css" />
<include name="**/*.properties" />
</fileset>
<fileset dir="${config.dir}">
<include name="**/*.xml" />
<include name="**/*.xsd" />
</fileset>
</jar>
</target>
<target name="copyDistFiles" depends="jar">
<echo>***** Copying distribution files for ${project.name} *****</echo>
<mkdir dir="${dist.dir.lib}" />
<mkdir dir="${dist.dir.conf}" />
<mkdir dir="${dist.dir.log}" />
<copy todir="${dist.dir.lib}">
<fileset dir="${lib.dir}" excludes="*.db" />
</copy>
<copy todir="${dist.dir.conf}">
<fileset dir="${conf.dir}" />
</copy>
</target>
<target name="zip" depends="copyDistFiles">
<echo>***** Zipping distribution files for ${project.name} *****</echo>
<zip destfile="./Linux_5.5_${project.name}.zip" basedir="${dist.dir}" excludes="*.db" />
</target>
<target name="cleanDistFiles" depends="zip">
<echo>***** Deleting distribution files for ${project.name} *****</echo>
<delete dir="${dist.dir}/lib" />
<delete dir="${dist.dir.conf}" />
<delete dir="${dist.dir}/log" />
</target>
</project>
and here is my build properties:
project.name=${ant.project.name}
app.dir=${basedir}
src.dir=${basedir}/src
lib.dir=${basedir}/lib
log.dir=${basedir}/logs
conf.dir=${basedir}/config
bin.dir=./bin
bin.dir.lib=${bin.dir}/lib
dist.dir=./dist
dist.dir.conf=${dist.dir}/config
dist.dir.lib=${dist.dir}/lib
dist.dir.log=${dist.dir}/logs
main.class=com.fmd.raptorurls.RaptorURLs
spring.config.dir=./lib
config.dir=./config/
all.config.dir=./apps/fps/raptorurls/config
build_env=all
Don't know what i am doing wrong.
also i'm using spring
A NoClassDefFoundError (distinct from a ClassNotFoundException) may indicate a number of things. But for a start, I would guess that when you execute your main class, some dependency is missing. Check your runtime classpath. Are all the libs you need present?
Related
I'm new with ANT build, and I have a trouble with it, when I try to build I'm receiving a message:
BUILD FAILED
C:\Users\user\Documents\PM\proyecto-base\proyecto-base\intranet\build.xml:169: Reference xdoclet.classpath not found.
but I have xdoclet.classpath declared already in the same file.
Also I have the properties like ${xdoclet.lib.dir} declared in a build.properties file.
here's my build.xml file
<?xml version="1.0" encoding="ISO-8859-1"?>
<!-- Ant Build File para Intranet -->
<project name="${project.name}" default="ear" basedir=".">
<!-- Importar funcionalidad comun -->
<import file="../common.xml" />
<property name="jboss.security-domain" value="java:/jaas/NotificacionApplicationSecurity" />
<target name="init">
<path id="classpath">
<fileset dir="${lib.dir}" />
<fileset dir="${hibernate.dir}" />
<fileset dir="${hibernate-annotations.dir}" />
<fileset dir="${sri-adm.dir}" />
<fileset dir="${sri-seguridad.dir}" />
<fileset dir="${jsf.dir}" />
<fileset file="${servicio.jar}" />
<fileset file="${log4j.jar}" />
<fileset file="${servlet.jar}" />
<fileset file="${mail.jar}" />
<fileset dir="${jboss.lib}">
<include name="*.jar" />
</fileset>
</path>
<path id="xdoclet.classpath">
<fileset dir="${xdoclet.lib.dir}" />
<pathelement location="${j2ee.jar}" />
<pathelement location="${servlet.jar}" />
</path>
</target>
<target name="clean" depends="init">
<delete dir="../${build.dir}/intranet" />
<delete dir="../${dist.dir}">
<exclude name="${servicio.name}-${version}.jar"/>
</delete>
</target>
<!--=============== Compile JAVA files ========================-->
<target name="compile" description="Compile" >
<echo message="Start compilation..." />
<!-- compile project-->
<mkdir dir="../${build.intranet.dir}/classes"/>
<javac destdir="../${build.intranet.dir}/classes" target="1.5" debug="true" deprecation="false" optimize="false" failonerror="true">
<src path="${src.main.java.dir}" />
<classpath refid="classpath" />
</javac>
</target>
<!--============== Genera archivos web==========-->
<target name="webdoclet" description="Generar archivos XML Web y Struts" >
<echo message="Generando Web" />
<delete file="../${metadata.intranet.web.dir}/jboss-web.xml"/>
<webdoclet destdir="../${metadata.intranet.web.dir}" force="${xdoclet.force}" mergedir="${conf.xdoclet.intranet.dir}">
<fileset dir="${src.main.java.dir}">
<include name="**/*.java" />
</fileset>
<deploymentdescriptor displayname="SRI" description="" xmlencoding="ISO-8859-1"
validatexml="true" servletspec="2.4" sessiontimeout="60" destdir="../${metadata.intranet.web.dir}"
mergeDir="../${conf.xdoclet.intranet.dir}" distributable="false" />
<facesconfigxml destinationfile="${project.name}-faces-config.xml" mergedir="../${metadata.intranet-jsf}" />
<jbosswebxml
version="4.0"
mergeDir="${metadata.intranet-jbossweb}"
contextroot="${project.name}"
securitydomain="${jboss.security-domain}"
validateXML="true" xmlencoding="ISO-8859-1"/>
</webdoclet>
<replace file="../${metadata.intranet.web.dir}/jboss-web.xml" token="<security-domain" value="<security-domain flushOnSessionInvalidation="true"" />
</target>
<target name="build" depends="init,webdoclet" description="Compila las clases">
<mkdir dir="../${classes.dir}" />
<javac destdir="../${classes.dir}" debug="on" deprecation="on" optimize="off" target="1.5" encoding="ISO-8859-1">
<src path="${src.main.java.dir}" />
<classpath refid="classpath" />
<classpath refid="xdoclet.classpath" />
<!-- Descomentar si se quieren ver los Warnings -->
<!--compilerarg value="-Xlint:unchecked" /-->
</javac>
</target>
<!--============= Genera un archivo WAR del proyecto =============================-->
<target name="war" description="Packages app as WAR" depends="compile, webdoclet">
<echo message="Generando WAR..." />
<mkdir dir="../${dist.dir}/intranet" />
<copy todir="../${metadata.tmp.intranet.dir}">
<fileset dir="../${metadata.intranet.web.dir}" />
<filterset>
<filter token="project.name" value="${project.name}"/>
</filterset>
</copy>
<copy file="../${conf.intranet.dir}/jboss-web.xml" todir="../${metadata.tmp.intranet.dir}">
<filterset>
<filter token="project.name" value="${project.name}"/>
</filterset>
</copy>
<war destfile="../${dist.dir}/intranet/${webapp.intranet.name}.war" webxml="../${metadata.intranet.web.dir}/web.xml">
<classes dir="../${build.intranet.dir}/classes">
<include name="**/**/controladores/*.*"/>
<include name="**/**/web/**/*.*"/>
<include name="**/**/validadores/**/*.*"/>
<include name="**/**/convertidores/**/*.*"/>
<exclude name="**/**/internet/**/*.*"/>
</classes>
<classes dir="../intranet/src/main/java">
<include name="**/**/*.properties"/>
</classes>
<fileset dir="${src.main.webapp.dir}">
<include name="**/*.*" />
</fileset>
<lib dir="${jsf.dir}" >
<include name="rich*.jar" />
<include name="jsf*facelet*.jar" />
</lib>
<lib dir="${sri-seguridad.dir}" >
<include name="seguridad*.jar" />
</lib>
<lib dir="${lib.dir}" >
<include name="commons-digester.jar" />
<include name="commons-beanutils.jar" />
<include name="commons-fileupload.jar" />
<include name="commons-el.jar" />
<include name="commons-lang-2.1.jar" />
</lib>
<!-- Archivos de configuracion en WEB-INF -->
<webinf file="../${metadata.tmp.intranet.dir}/web.xml" />
<webinf file="../${metadata.tmp.intranet.dir}/${project.name}-faces-config.xml" />
<webinf file="../${metadata.tmp.intranet.dir}/jboss-web.xml" />
</war>
<delete dir="../${metadata.tmp.intranet.dir}" />
</target>
<target name="ear" depends="war">
<mkdir dir="../${metadata.intranet-ejb.tmp}" />
<copy todir="../${metadata.intranet-ejb.tmp}">
<fileset dir="../${metadata.intranet-ejb}" />
<filterset>
<filter token="project.name" value="${project.name}"/>
<filter token="intranet.name" value="${intranet.name}"/>
</filterset>
</copy>
<ear destfile="../${dist.dir}/intranet/${webapp.intranet.name}.ear" appxml="../${metadata.intranet-ejb.tmp}/application.xml">
<fileset dir="../${dist.dir}" includes="*.jar"/>
<fileset dir="../${dist.dir}/intranet" includes="*.war"/>
</ear>
<delete dir="../${metadata.intranet-ejb.tmp}" />
</target>
<target name="deploy" depends="ear" description="Copia el archivo WAR en el directorio deploy del server">
<copy file="../${dist.dir}/intranet/${webapp.intranet.name}.ear" todir="${jboss.deploy.intranet.dir}" />
</target>
<!-- DefiniciĆ³n de WebDoclet -->
<taskdef name="webdoclet" classname="xdoclet.modules.web.WebDocletTask">
<classpath>
<path refid="xdoclet.classpath" />
<path refid="classpath" />
</classpath>
</taskdef>
<!-- Definicion de JSF -->
<taskdef name="facesconfigxml" classname="xdoclet.modules.jsf.FacesConfigXmlSubTask">
<classpath>
<path refid="xdoclet.classpath" />
<path refid="classpath" />
</classpath>
</taskdef>
</project>
the lines which are returning me the error are the following:
<!-- DefiniciĆ³n de WebDoclet -->
<taskdef name="webdoclet" classname="xdoclet.modules.web.WebDocletTask">
<classpath>
<path refid="xdoclet.classpath" />
<path refid="classpath" />
</classpath>
</taskdef>
but as I told you I have already declared my xdoclet.classpath in the same file at the begining:
<path id="xdoclet.classpath">
<fileset dir="${xdoclet.lib.dir}" />
<pathelement location="${j2ee.jar}" />
<pathelement location="${servlet.jar}" />
</path>
Can Anyone help me with this Issue please? thanks a lot
The issue here is that your path definition is inside of the the target "init", but the taskdef definition is outside of any target up at the project level. When ant loads the build file, it's going to try validating everything that is defined at the project level. In this case it fails becuase the init target has not run yet and the xdoclet.classpath path is not defined.
If you just move the path element out to the project level like the taskdef is, the issue should go away.
i am developing a dynamic web project.
and i having problem when i want to build it using ant script.
my purpose is to adopt three-tier concept, which is have business-layer and presentation-layer in different machine.
i use weblogic server as web server (presentation layer) and app server (business layer)
here is my build.xml :
<property name="build" value="./build" />
<property name="dist" value="./dist" />
<!-- <property name="conf" value="./config" /> -->
<property name="src" value="./src" />
<property name="web" value="./WebContent" />
<property name="lib" value="${web}/WEB-INF/lib" />
<property name="webinf" value="${web}/WEB-INF" />
<property name="metainf" value="${web}/META-INF" />
<property name="servletLib" value="C:\Oracle\MiddlewareOneBC\wlserver_12.1\server\lib" />
<property name="deploydir" value="C:\Oracle\MiddlewareOneBC\user_projects\domains\OneBCDomain\autodeploy" />
<property name="project.name" value="OneBCApplication" />
<path id="build.classpath">
<fileset dir="${lib}" includes="**/*.jar" />
<fileset dir="${servletLib}" includes="**/*.jar" />
</path>
<target name="clean">
<delete dir="${build}" />
<delete dir="${dist}" />
</target>
<target name="init">
<tstamp />
<mkdir dir="${build}" />
<mkdir dir="${build}/classes" />
<mkdir dir="${dist}" />
</target>
<target name="compile" depends="init">
<javac srcdir="${src}" destdir="${build}/classes" optimize="on" includeantruntime="false">
<classpath refid="build.classpath" />
</javac>
<copy todir="${build}/classes">
<fileset dir="${src}" excludes="ddl/*" />
<fileset dir="${src}" excludes="dml/*" />
<fileset dir="${src}" excludes="**/*.xls" />
<fileset dir="${src}" includes="**/*.xml" />
<fileset dir="${src}" includes="**/*.properties" />
<!-- <fileset dir="${conf}" includes="**/*" /> -->
</copy>
</target>
<target name="war" depends="compile">
<war destfile="${dist}/${project.name}.war" webxml="${webinf}/web.xml">
<lib dir="${lib}" />
<classes dir="${build}/classes"/>
<fileset dir="${web}">
<include name="**/*.*" />
<exclude name="WEB-INF/lib/*" />
</fileset>
</war>
</target>
<target name="ear" depends="war">
<ear destfile="${dist}/${project.name}EAR.ear" appxml="${metainf}/application.xml">
<fileset dir="${dist}" includes="*.war" />
</ear>
</target>
<target name="warweb" depends="compile">
<war destfile="${dist}/web/${project.name}Web.war" webxml="${webinf}/web.xml">
<lib dir="${lib}" excludes="**/BV_*.*" />
<classes dir="${build}/classes">
<!-- <exclude name="**/*.java"/>
<exclude name="**/*.class"/> -->
<exclude name="com/**"/>
</classes>
<fileset dir="${web}">
<include name="**/*.*" />
<exclude name="WEB-INF/lib/*" />
</fileset>
</war>
<jar destfile="${dist}/lib/${project.name}.jar" basedir="${build}/classes"/>
</target>
<target name="earweb" depends="warweb">
<ear destfile="${dist}/${project.name}Static.ear" appxml="${metainf}/application.xml">
<fileset dir="${dist}/web" includes="*.war" />
</ear>
</target>
<target name="earapp" depends="warweb">
<ear destfile="${dist}/${project.name}App.ear" appxml="${metainf}/application.xml">
<fileset dir="${dist}/web" includes="*.war" />
<zipfileset dir="${dist}/lib" includes="*.jar" prefix="APP-INF/lib" />
<zipfileset dir="${lib}" includes="**/BV_*.*" prefix="APP-INF/lib" />
</ear>
</target>
<target name="deploywar" depends="ear">
<copy todir="${deploydir}">
<fileset dir="${dist}" includes="*.war" />
</copy>
</target>
<target name="deployear" depends="ear">
<copy todir="${deploydir}">
<fileset dir="${dist}" includes="*.ear" />
</copy>
</target>
<target name="undeploy">
<delete file="${deploydir}/${project.name}EAR.ear"/>
<delete file="${deploydir}/${project.name}EAR.war"/>
</target>
how to build it separately ? and how the request from presentation layer can comunicate with business layer? is there any configuration in weblogic that has to be done to made these two layer communicate?
thanks in advance.
Using fileset task you specify what jar file you want to include for app server or web server.
<ear destfile="${build.dir}/myapp.ear" appxml="${src.dir}/metadata/application.xml">
<fileset dir="${build.dir}" includes="*.jar,*.war"/>
</ear>
just you two ear task to create two ear one for app server and one for web server.
I have this XML code script and it says to use command prompt to execute it but everything I try doesnt work, it has a readme file which states
Clone the project with git or download the source zip from the github page and extract it.
Open the folder and run build.xml (this may require cmd to execute).
Wait for the build to complete and run DarkBot.jar from cmd with --help for args.
<project name="DarkBot" default="generate-protocols" basedir=".">
<target name="init">
<property name="outputDir" value="bin" />
<property name="protocolsDir" value="protocols" />
<property name="protocolsPackage" value="org.darkstorm.darkbot.minecraftbot.protocol" />
<property name="deployJar" value="DarkBot.jar" />
<property name="libraryDir" value="lib" />
<property name="tempDir" value="temp" />
<property name="mainClass" value="org.darkstorm.darkbot.mcwrapper.Main" />
<property name="antContribPath" value="build/ant-contrib-1.0b3.jar" />
</target>
<target name="clean" depends="init">
<delete file="${deployJar}" failonerror="false" />
<delete dir="${outputDir}" failonerror="false" />
<delete dir="${tempDir}" failonerror="false" />
</target>
<target name="compile" depends="clean">
<mkdir dir="${outputDir}" />
<javac encoding="UTF-8" destdir="${outputDir}" includeantruntime="false">
<src path="src/main/java" />
<src path="src/main/resources" />
<classpath>
<fileset dir="${libraryDir}">
<include name="**/*.jar" />
</fileset>
</classpath>
</javac>
<copy todir="${outputDir}">
<fileset dir="src/main/java">
<exclude name="**/*.java" />
</fileset>
<fileset dir="src/main/resources">
<exclude name="**/*.java" />
</fileset>
</copy>
</target>
<target name="deploy" depends="compile">
<mkdir dir="${tempDir}" />
<unzip dest="${tempDir}">
<patternset>
<exclude name="META-INF/**" />
</patternset>
<fileset dir="${libraryDir}">
<include name="**/*.jar" />
</fileset>
</unzip>
<copy todir="${tempDir}">
<fileset dir="${outputDir}">
<include name="*" />
</fileset>
</copy>
<echo message="Manifest-Version: 1.0${line.separator}Class-Path: .${line.separator}Main-Class: ${mainClass}" file="${outputDir}/manifest.txt" />
<jar destfile="${deployJar}" basedir="${outputDir}" manifest="${outputDir}/manifest.txt" excludes="manifest.txt" />
<jar destfile="${deployJar}" basedir="${tempDir}" includes="**/**" update="true" />
<delete dir="${tempDir}" />
</target>
<target name="generate-protocols" depends="deploy">
<taskdef resource="net/sf/antcontrib/antlib.xml">
<classpath>
<pathelement location="${antContribPath}" />
</classpath>
</taskdef>
<mkdir dir="${protocolsDir}" />
<javac encoding="UTF-8" destdir="${protocolsDir}" includeantruntime="false">
<src path="src/main/protocols" />
<classpath>
<fileset file="${deployJar}" />
<fileset dir="${libraryDir}">
<include name="**/*.jar" />
</fileset>
</classpath>
</javac>
<propertyregex property="protocolsFolder" input="src.main.protocols.${protocolsPackage}" global="true" regexp="\." replace="/" />
<pathconvert property="files" pathsep="${line.separator}">
<map from="${protocolsFolder}{$file.separator}" to="" />
<dirset dir="${protocolsFolder}">
<include name="*" />
</dirset>
</pathconvert>
<propertyregex property="protocolsFolder" override="true" input="${protocolsPackage}" global="true" regexp="\." replace="/" />
<for list="${files}" delimiter="${line.separator}" param="file">
<sequential>
<local name="protocolVersion" />
<basename property="protocolVersion" file="#{file}" />
<mkdir dir="${protocolsDir}/META-INF/services" />
<if>
<contains string="${protocolVersion}" substring="x" />
<then>
<propertyregex property="protocolVersion" override="true" input="${protocolVersion}" regexp="v([0-9]+)" select="\1" />
<echo message="${protocolsPackage}.v${protocolVersion}x.Protocol${protocolVersion}X$$Provider" file="${protocolsDir}/META-INF/services/${protocolsPackage}.ProtocolProvider" />
<jar destfile="${protocolsDir}/v${protocolVersion}x.jar" update="false" basedir="${protocolsDir}" includes="${protocolsFolder}/v${protocolVersion}x/**/**,META-INF/**/**" />
</then>
<else>
<propertyregex property="protocolVersion" override="true" input="${protocolVersion}" regexp="v([0-9]+)" select="\1" />
<echo message="${protocolsPackage}.v${protocolVersion}.Protocol${protocolVersion}$$Provider" file="${protocolsDir}/META-INF/services/${protocolsPackage}.ProtocolProvider" />
<jar destfile="${protocolsDir}/v${protocolVersion}.jar" update="false" basedir="${protocolsDir}" includes="${protocolsFolder}/v${protocolVersion}/**/**,META-INF/**/**" />
</else>
</if>
<delete dir="${protocolsDir}/META-INF" />
</sequential>
</for>
<propertyregex property="protocolBase" input="${protocolsPackage}" regexp="^([a-zA-Z][a-zA-Z0-9]+).*" select="\1" />
<delete dir="${protocolsDir}/${protocolBase}" />
</target>
Its an Ant build file. Download Ant and run the build targets listed E.g.
ant deploy
This looks like an ant build file, download and install an ant, try:
ant init deploy
or some other name in target tag.
Ant manual is here
I am trying to build a runnable JAR file of a project by using build.xml file and the prompt code
cd <the directory of you application>
ant -f bin/build.xml jar
But I have exceptions when I run the JAR because I cannot add the external JAR.
the build.xml is as follows:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!--
This file was generated by Jason 1.3.9-alpha
http://jason.sf.net
Ocak 11, 2014 - 01:09:12
-->
<project name ="virtualClassroom"
basedir=".."
default="run">
<property name="mas2j.project.file" value="virtualClassroom.mas2j"/>
<property name="debug" value=""/> <!-- use "-debug" to run in debug mode -->
<property name="build.dir" value="${basedir}/bin/classes" />
<property name="jasonJar" value="C:\Users\Emre\Desktop\MasterThesis-BDI\Jason-1.3.9\Jason-1.3.9\lib\jason.jar"/>
<property name="JavaCsBridgeJar" value="C:\Users\Emre\Desktop\MasterThesis-BDI\virtualClassroom\lib\JavaCsBridge.jar"/>
<path id="project.classpath">
<pathelement location="${basedir}"/>
<pathelement location="${build.dir}"/>
<pathelement location="${JavaCsBridgeJar}"/>
<pathelement location="${jasonJar}"/>
<fileset dir="${basedir}/lib" > <include name="*.jar" /> </fileset>
</path>
<!-- tasks the user can override in his/her c-build.xml script -->
<target name="user-init">
</target>
<target name="user-end">
</target>
<target name="init">
<mkdir dir="${build.dir}" />
<antcall target="user-init" />
</target>
<target name="compile" depends="init">
<condition property="srcdir" value="${basedir}/src/java" else="${basedir}" >
<available file="${basedir}/src/java" />
</condition>
<javac srcdir="${srcdir}" destdir="${build.dir}" debug="true" optimize="true" includeantruntime="false" >
<classpath refid="project.classpath"/>
</javac>
</target>
<target name="jar" depends="compile">
<delete file="${ant.project.name}.jar" />
<copy file="${jasonJar}" tofile="${ant.project.name}.jar" />
<copy file="${JavaCsBridge}" tofile="${ant.project.name}.jar" />
<copy file="${mas2j.project.file}" tofile="default.mas2j" />
<jar update="yes" jarfile="${ant.project.name}.jar" >
<fileset dir="${basedir}">
<include name="**/*.asl" />
<include name="**/*.mas2j" />
</fileset>
<fileset dir="${build.dir}">
<include name="**/*.class" />
</fileset>
<manifest>
<attribute name="Main-Class" value="jason.infra.centralised.RunCentralisedMAS"/>
</manifest>
</jar>
<delete file="default.mas2j" />
</target>
<target name="jnlp" depends="jar" >
<mkdir dir="${basedir}/${ant.project.name}-jws"/>
<java classname="jason.infra.centralised.CreateJNLP"
failonerror="true" fork="yes" dir="${basedir}/${ant.project.name}-jws" >
<classpath refid="project.classpath"/>
<arg line="${ant.project.name} ${mas2j.project.file}"/>
</java>
<copy todir="${basedir}/${ant.project.name}-jws" failonerror="no">
<fileset dir="${basedir}/lib" includes="**/*.jar" />
<fileset dir="${basedir}" includes="${ant.project.name}.jar" />
<fileset dir="C:\Users\Emre\Desktop\MasterThesis-BDI\Jason-1.3.9\Jason-1.3.9/src/images" includes="Jason-GMoreau-Icon.jpg" />
</copy>
<signjar jar="${basedir}/${ant.project.name}-jws/${ant.project.name}.jar" alias="jason"
storepass="rbjhja" keypass="rbjhja" keystore="C:\Users\Emre\Desktop\MasterThesis-BDI\Jason-1.3.9\Jason-1.3.9/src/jasonKeystore" />
<echo message="**" />
<echo message="** Java Web Start application created in directory ${ant.project.name}-jws" />
<echo message="** Update the codebase (in the second line of the .jnlp file)" />
<echo message="** with the URL where you will upload the application." />
<echo message="**" />
</target>
<target name="run" depends="compile" >
<echo message="Running project ${ant.project.name}" />
<java classname="jason.infra.centralised.RunCentralisedMAS"
failonerror="true" fork="yes" dir="${basedir}" >
<classpath refid="project.classpath"/>
<arg line="${mas2j.project.file} ${debug} "/>
<!-- jvmarg line="-Xmx500M -Xss8M"/ -->
</java>
<antcall target="user-end" />
</target>
<target name="clean" >
<delete failonerror="no" includeEmptyDirs="true" verbose="true">
<fileset dir="${basedir}" includes="**/*.class"/>
</delete>
</target>
</project>
Do anyone know what to do?
Thanks
Firstly, you need to tell us exactly which class is giving a NoClassDefFoundError
As a generic answer, the explanation is that the particular class was available during compile time but missing during runtime. This is a common issue with jar executables.
Solution : Either include the missing classes in the jar itself or add those to the system classpath.
I am trying to build a project using Apache ANT ( all packages installed like SWT, Eclipse Indigo on Windows Xp SP3). All file are available in the corresponding directory
F:\Work_Arun\Indic\trunk\indic-keyboards\build-win32-x86.xml:47: Execute failed: java.io.IOException: Cannot run program "Cl" (in directory "F:\Work_Arun\Indic\trunk\indic-keyboards\src\org\iisc\mile\indickeyboards\windows"): CreateProcess error=2, The system cannot find the file specified
Build.XML
<?xml version="1.0"?>
<project name="indic-keyboards-win32-x86" default="build">
<description>indic-keyboards - A Multilingual Indic Keyboard Interface for Indic Scripts</description>
<property name="debug" value="false" />
<property name="verbose" value="false" />
<property name="main.class" value="org.iisc.mile.indickeyboards.IndicKeyboards" />
<property name="swt" value="swt.jar" />
<fileset id="ImagesIcons" dir="./resources">
<patternset includes="*.ico,*.png,*.gif,*.jpg,*.jpeg" />
</fileset>
<fileset id="otherfiles" dir=".">
<patternset includes="*.txt,*.conf" />
</fileset>
<fileset id="swtorg" dir="./swt">
<patternset includes="**/org/**" />
</fileset>
<fileset id="swtdll" dir="./swt">
<patternset>
<include name="swt*.dll" />
<include name="version.txt" />
</patternset>
</fileset>
<fileset id="ourdll" dir=".">
<patternset includes="*.dll" />
</fileset>
<target name="init" description="Initialization by creating the directory structure">
<mkdir dir="bin" />
</target>
<target name="header" depends="compile" description="Generates the platform specific header files for building libraries">
<javah destdir="./src/org/iisc/mile/indickeyboards/windows" classpath="./bin">
<class name="org.iisc.mile.indickeyboards.windows.PollThread" />
<class name="org.iisc.mile.indickeyboards.windows.OutputCharToActiveWindow" />
</javah>
</target>
<target name="build" depends="header" description="Creates the windows libraries (.dll files)">
<property environment="env" />
<echo>Using JDK present at ${env.JAVA_HOME} ; Architecture : ${env.PROCESSOR_ARCHITECTURE}</echo>
<exec dir="./src/org/iisc/mile/indickeyboards/windows" executable="Cl">
<arg line="-I'${env.JAVA_HOME}'\include -I'${env.JAVA_HOME}'\include\win32 -LD /Feindic-keyboards-sysHook.dll syshook.cpp /link user32.lib" />
</exec>
<exec dir="./src/org/iisc/mile/indickeyboards/windows" executable="cl">
<arg line="-I'${env.JAVA_HOME}'\include -I'${env.JAVA_HOME}'\include\win32 -LD /Feindic-keyboards-opChars.dll opChars.cpp /link user32.lib" />
</exec>
<move todir=".">
<fileset dir="./src/org/iisc/mile/indickeyboards/windows">
<include name="*.dll" />
</fileset>
</move>
<delete>
<fileset dir="./src/org/iisc/mile/indickeyboards/windows" includes="*.h" />
<fileset dir="./src/org/iisc/mile/indickeyboards/windows" includes="*.obj" />
<fileset dir="./src/org/iisc/mile/indickeyboards/windows" includes="*.exp" />
<fileset dir="./src/org/iisc/mile/indickeyboards/windows" includes="*.lib" />
<fileset dir="./src/org/iisc/mile/indickeyboards/windows">
<include name="lib*" />
</fileset>
</delete>
</target>
<target name="compile" depends="init" description="Compiles the java source code.">
<echo>Compiling ${ant.project.name}</echo>
<javac srcdir="src" destdir="bin" classpath="${swt}" debug="${debug}" verbose="${verbose}" />
</target>
<target name="run" depends="build" description="Executes the project">
<echo>Using Java ${ant.java.version} present at ${java.home}</echo>
<java classpath="${swt}:./bin" classname="org.iisc.mile.indickeyboards.IndicKeyboards" fork="true" />
</target>
<target name="jar" depends="build" description="Packages into an executable JAR">
<mkdir dir="dist" />
<mkdir dir="swt" />
<unjar src="${swt}" dest="./swt" />
<manifest file="MANIFEST.MF">
<attribute name="Class-Path" value="." />
<attribute name="Main-Class" value="${main.class}" />
</manifest>
<jar destfile="./dist/${ant.project.name}.jar" basedir="bin" duplicate="preserve" manifest="./MANIFEST.MF">
<fileset refid="swtdll" />
<fileset refid="swtorg" />
</jar>
<delete dir="META-INF" />
<delete file="./MANIFEST.MF" />
<delete dir="swt" />
<copy todir="./dist">
<fileset refid="ourdll" />
</copy>
<mkdir dir="./dist/kblayouts" />
<copy todir="./dist/kblayouts">
<fileset dir="./kblayouts" />
</copy>
<mkdir dir="./dist/resources" />
<copy todir="./dist/resources">
<fileset dir="./resources" />
</copy>
<mkdir dir="./dist/docs" />
<copy todir="./dist/docs">
<fileset dir="./docs" />
</copy>
<copy todir="./dist">
<fileset refid="otherfiles" />
</copy>
<delete dir="./bin" />
</target>
<target name="javadoc" depends="init" description="Generates javadoc of the source">
<mkdir dir="./javadoc" />
<javadoc destdir="./javadoc" sourcepath="./src" packagenames="org.*" Private="true" />
<delete dir="./bin" />
</target>
<target name="clean" description="Clean up after compile/build.">
<delete dir="./bin" />
<delete dir="./javadoc" />
<delete dir="./dist" />
<delete>
<fileset dir="./" includes="*.dll" />
</delete>
</target>
</project>
What is cause of the error ?