Apache Ant java.lang.NoClassDefFoundError -


possible answer stack on flow question

my problem same described in above thread.i went throught solution , not working. ant compile working perfectly. ant jar saying cant load main class

exception in thread "main" java.lang.noclassdeffounderror: loadserver (wrong name: org/module/loader/loadserver)     @ java.lang.classloader.defineclass1(native method)     @ java.lang.classloader.defineclass(classloader.java:791)     @ java.security.secureclassloader.defineclass(secureclassloader.java:142)     @ java.net.urlclassloader.defineclass(urlclassloader.java:449)     @ java.net.urlclassloader.access$100(urlclassloader.java:71)     @ java.net.urlclassloader$1.run(urlclassloader.java:361)     @ java.net.urlclassloader$1.run(urlclassloader.java:355)     @ java.security.accesscontroller.doprivileged(native method)     @ java.net.urlclassloader.findclass(urlclassloader.java:354)     @ java.lang.classloader.loadclass(classloader.java:423)     @ sun.misc.launcher$appclassloader.loadclass(launcher.java:308)     @ java.lang.classloader.loadclass(classloader.java:356)     @ sun.launcher.launcherhelper.checkandloadmain(launcherhelper.java:482) 

i did following in commnad line

java_home="/usr/local/java/jdk1.7.0_21" ant_home="/usr/share/ant/" path="$ant_home/bin:$path" 

morever if start new terminal , type echo$java_home showing above result echo$ant_home giving null.

here screen shot

initial error

     <project name="raxa-4" basedir="." default="main">      <property name="src.dir"      value="src"/>     <property name="prop.dir"     value="properties"/>     <property name="resource.dir" value="resource"/>     <property name="lib.dir"      value="lib"/>     <property name="build.dir"    value="build"/>     <property name="classes.dir"  value="${build.dir}/classes"/>     <property name="jar.dir"      value="${build.dir}/jar"/>     <property name="main-class"   value="org.raxa.module.loader.loadserver"/>      <path id="classpath">             <fileset dir="${lib.dir}" includes="**/*.jar"/>     </path>      <target name="clean">         <delete dir="${build.dir}"/>     </target>      <target name="compile">         <mkdir dir="${classes.dir}"/>         <javac srcdir="${src.dir}" destdir="${classes.dir}" classpathref="classpath" includeantruntime="false" />         <copy todir="${classes.dir}">             <fileset dir="${resource.dir}" excludes="**/*.java"/>             <fileset dir="${prop.dir}" excludes="**/*.java"/>         </copy>     </target>     <target name="jar" depends="compile">         <mkdir dir="${jar.dir}"/>          <classpath>             <path refid="classpath"/>             <path location="${jar.dir}/${ant.project.name}.jar"/>         </classpath>         </jar>     </target>       <target name="run" depends="jar">         <java jar="${jar.dir}/${ant.project.name}.jar" fork="true"/>      </target>      <target name="clean-build" depends="clean,jar"/>      <target name="main" depends="clean,run"/>  </project> 

edited:

    <property name="src.dir"      value="src"/>     <property name="prop.dir"     value="properties"/>     <property name="resource.dir" value="resource"/>     <property name="lib.dir"      value="lib"/>     <property name="build.dir"    value="build"/>     <property name="classes.dir"  value="${build.dir}/classes"/>     <property name="jar.dir"      value="${build.dir}/jar"/>     <property name="main-class"   value="org.raxa.module.loader.loadserver"/>      <path id="classpath">             <fileset dir="${lib.dir}" includes="**/*.jar"/>     </path>      <target name="clean">         <delete dir="${build.dir}"/>     </target>      <target name="compile">         <mkdir dir="${classes.dir}"/>         <javac srcdir="${src.dir}" destdir="${classes.dir}" classpathref="classpath" includeantruntime="false" />         <copy todir="${classes.dir}">             <fileset dir="${resource.dir}" excludes="**/*.java"/>             <fileset dir="${prop.dir}" excludes="**/*.java"/>         </copy>     </target>     <target name="jar" depends="compile">         <mkdir dir="${jar.dir}"/>         <jar destfile="${jar.dir}/${ant.project.name}.jar" basedir="${classes.dir}">             <manifest>                 <attribute name="main-class" value="${main-class}"/>             </manifest>         </jar>     </target>       <target name="run" depends="jar">         <java jar="${jar.dir}/${ant.project.name}.jar" fork="true"/>         <classpath>             <path refid="classpath"/>             <path location="${jar.dir}/${ant.project.name}.jar"/>         </classpath>     </target>      <target name="clean-build" depends="clean,jar"/>      <target name="main" depends="clean,run"/>  </project> 

new error on ant run

run:

[java] exception in thread "main" java.lang.noclassdeffounderror: org/apache/log4j/logger  [java]     @ org.raxa.module.scheduler.timesetter.<clinit>(unknown source)  [java]     @ org.raxa.module.loader.loadserver.main(unknown source)  [java] caused by: java.lang.classnotfoundexception: org.apache.log4j.logger  [java]     @ java.net.urlclassloader$1.run(urlclassloader.java:366)  [java]     @ java.net.urlclassloader$1.run(urlclassloader.java:355)  [java]     @ java.security.accesscontroller.doprivileged(native method)  [java]     @ java.net.urlclassloader.findclass(urlclassloader.java:354)  [java]     @ java.lang.classloader.loadclass(classloader.java:423)  [java]     @ sun.misc.launcher$appclassloader.loadclass(launcher.java:308)  [java]     @ java.lang.classloader.loadclass(classloader.java:356)  [java]     ... 2 more  [java] java result: 1  build failed /home/atul/documents/workspace2/raxa-4/build.xml:41: problem: failed create task or type classpath cause: name undefined. action: check spelling. action: check custom tasks/types have been declared. action: check <presetdef>/<macrodef> declarations have taken pla 

ce.

maybe problem classpath gets overriden. try one:

<java classname="${main-class}" fork="true" >   <classpath>     <path refid="classpath"/>     <pathelement location="${jar.dir}/${ant.project.name}.jar"/>   </classpath> </classpath> </java> 

Comments

Popular posts from this blog

curl - PHP fsockopen help required -

HTTP/1.0 407 Proxy Authentication Required PHP -

c# - Resource not found error -