1 Reply Latest reply: Jun 6, 2008 11:19 PM by 843844 RSS

    java.io.FileNotFoundException

    843844
      Hello friends,

      I could not getting forward and have a pause due to some problem.

      I'm working on hibernate.
      When I use command ant on command prompt.I found exception file not found,but I'm surprised because It is in correct place.
      And second surprised is that same code is successful run on different machine.

      Kindly put your valuable suggestions to recover this problem.

      I found on command prompt:
      Microsoft Windows XP [Version 5.1.2600]
      (C) Copyright 1985-2001 Microsoft Corp.
      
      C:\Documents and Settings\ADMIN>cd\
      
      C:\>cd junk
      
      C:\junk>ant
      Buildfile: build.xml
      
      clean:
         [delete] Deleting directory C:\junk\src
         [delete] Deleting directory C:\junk\dao
         [delete] Deleting directory C:\junk\sql
         [delete] Deleting directory C:\junk\hbm
         [delete] Deleting directory C:\junk\classes
         [delete] Deleting directory C:\junk\pub
          [mkdir] Created dir: C:\junk\src
          [mkdir] Created dir: C:\junk\dao
          [mkdir] Created dir: C:\junk\sql
          [mkdir] Created dir: C:\junk\hbm
          [mkdir] Created dir: C:\junk\classes
          [mkdir] Created dir: C:\junk\pub
      
      hbm2ddl:
      [hibernatetool] Executing Hibernate Tool with a Standard Configuration
      [hibernatetool] 1. task: hbm2ddl (Generates database schema)
      [hibernatetool] log4j:WARN No appenders could be found for logger (org.hibernate
      .cfg.Environment).
      [hibernatetool] log4j:WARN Please initialize the log4j system properly.
      [hibernatetool] create table EVENTS (EVENT_ID bigint not null auto_increment, EV
      ENT_DATE datetime, TITLE varchar(255), primary key (EVENT_ID));
      [hibernatetool] create table PERSON (PERSON_ID bigint not null auto_increment, A
      GE integer, FirstName varchar(255), LastName varchar(255), primary key (PERSON_I
      D));
      
      hbm2java:
      [hibernatetool] Executing Hibernate Tool with a Standard Configuration
      [hibernatetool] 1. task: hbm2java (Generates a set of .java files)
      
      echo:
           [echo] C:\apache-ant-1.6.5\lib\ant-launcher.jar;C:\apache-ant-1.6.5\lib\ant
      -antlr.jar;C:\apache-ant-1.6.5\lib\ant-apache-bcel.jar;C:\apache-ant-1.6.5\lib\a
      nt-apache-bsf.jar;C:\apache-ant-1.6.5\lib\ant-apache-log4j.jar;C:\apache-ant-1.6
      .5\lib\ant-apache-oro.jar;C:\apache-ant-1.6.5\lib\ant-apache-regexp.jar;C:\apach
      e-ant-1.6.5\lib\ant-apache-resolver.jar;C:\apache-ant-1.6.5\lib\ant-commons-logg
      ing.jar;C:\apache-ant-1.6.5\lib\ant-commons-net.jar;C:\apache-ant-1.6.5\lib\ant-
      icontract.jar;C:\apache-ant-1.6.5\lib\ant-jai.jar;C:\apache-ant-1.6.5\lib\ant-ja
      vamail.jar;C:\apache-ant-1.6.5\lib\ant-jdepend.jar;C:\apache-ant-1.6.5\lib\ant-j
      mf.jar;C:\apache-ant-1.6.5\lib\ant-jsch.jar;C:\apache-ant-1.6.5\lib\ant-junit.ja
      r;C:\apache-ant-1.6.5\lib\ant-launcher.jar;C:\apache-ant-1.6.5\lib\ant-netrexx.j
      ar;C:\apache-ant-1.6.5\lib\ant-nodeps.jar;C:\apache-ant-1.6.5\lib\ant-starteam.j
      ar;C:\apache-ant-1.6.5\lib\ant-stylebook.jar;C:\apache-ant-1.6.5\lib\ant-swing.j
      ar;C:\apache-ant-1.6.5\lib\ant-trax.jar;C:\apache-ant-1.6.5\lib\ant-vaj.jar;C:\a
      pache-ant-1.6.5\lib\ant-weblogic.jar;C:\apache-ant-1.6.5\lib\ant-xalan1.jar;C:\a
      pache-ant-1.6.5\lib\ant-xslp.jar;C:\apache-ant-1.6.5\lib\ant.jar;C:\apache-ant-1
      .6.5\lib\xercesImpl.jar;C:\apache-ant-1.6.5\lib\xml-apis.jar;C:\jdk1.5.0_15\lib\
      tools.jar
      
      hbm2dao:
      [hibernatetool] Executing Hibernate Tool with a Standard Configuration
      [hibernatetool] 1. task: generic exportertemplate: ./config/CustomDAOTemplate.ft
      l
      [hibernatetool] An exception occurred while running exporter #2:generic exporter
      template: ./config/CustomDAOTemplate.ftl
      [hibernatetool] To get the full stack trace run ant with -verbose
      [hibernatetool] org.hibernate.tool.hbm2x.ExporterException: Error while processi
      ng template ./config/CustomDAOTemplate.ftl
      [hibernatetool] java.io.FileNotFoundException: Template ./config/CustomDAOTempla
      te.ftl not found.
      
      BUILD FAILED
      C:\junk\build.xml:142: org.hibernate.tool.hbm2x.ExporterException: Error while p
      rocessing template ./config/CustomDAOTemplate.ftl
      
      Total time: 4 seconds
      C:\junk>
      build.xml which I'm using:


      <?xml version="1.0"?>
      <project name="hibernate-tutorial" default="createjar">
      
      
          <property  name="base" value="."/>
          
          
          <property name="hibernateConfigdir" value="${base}/config"/>
          <property name="hibernateSourcedir" value="${base}/hibernate-src"/>
          <property name="generatedSourcedir" value="${base}/src"/>
          <property name="generatedsqldir" value="${base}/sql"/>
          <property name="generateddocdir" value="${base}/doc"/>
          <property name="generateddaodir" value="${base}/dao"/>
          <property name="generatedhbmdir" value="${base}/hbm"/>    
          <property name="librarydir" value="${base}/lib"/>
          <property name="build.dir" value="${base}/classes"/>
          <property name="release.dir" value="${base}/pub"/>
          
          
            <path id="toolslib">
      
               <pathelement  location="${librarydir}/hibernate-tools.jar" />
               <pathelement  location="${librarydir}/hibernate3.jar" />
               <pathelement  location="${librarydir}/freemarker.jar" />
               <pathelement  location="${librarydir}/commons-logging-1.0.4.jar" />
               <pathelement  location="${librarydir}/dom4j-1.6.1.jar" />
               <pathelement  location="${librarydir}/commons-collections-2.1.1.jar" />
               <pathelement  location="${librarydir}/log4j-1.2.15.jar" />
               <pathelement  location="${librarydir}/slf4j-api-1.5.0.jar" />    
               <pathelement  location="${librarydir}/jtidy-r8-20060801.jar" />
               <pathelement  location="${librarydir}/slf4j-log4j12-1.5.0.jar" />
               <pathelement  location="${librarydir}/mssqlserver.jar" />
               <pathelement  location="${librarydir}/msutil.jar" />
               <pathelement  location="${librarydir}/msbase.jar" />
               <pathelement  location="${librarydir}/mysql-connector-java-3.1.13-bin.jar" />
               <pathelement  location="${librarydir}/spring-2.5.1.jar" />
                  <pathelement  location="${librarydir}/CustomDAOTemplate.ftl" />
           
               
      
           </path>
      
      
         
      <taskdef name="hibernatetool" 
               classname="org.hibernate.tool.ant.HibernateToolTask" 
               classpathref="toolslib" />
      
      
      
      
      <target name="hbm2java">
              
              
              <hibernatetool destdir="${generatedSourcedir}">
                
                <!--<classpath>
                  <path location="${generatedSourcedir}/classes"/>
                </classpath>-->
                
                <configuration configurationfile="${hibernateConfigdir}/hibernate.cfg.xml">                 
                  <fileset dir="${hibernateSourcedir}/events">
                    <include name="**/*.hbm.xml"/>
                  </fileset>
                </configuration>
                
                <hbm2java  jdk5="true" ejb3="false"/>
                
              </hibernatetool>
          </target>
          
          
      
      
      <target name="hbm2ddl">
              
              
              <hibernatetool destdir="${generatedsqldir}">
                
              
                
                <configuration configurationfile="${hibernateConfigdir}/hibernate.cfg.xml">                 
                  <fileset dir="${hibernateSourcedir}/events">
                    <include name="**/*.hbm.xml"/>
                  </fileset>
                </configuration>
                
                <hbm2ddl export="false" outputfilename="sql.ddl"/>
                
              </hibernatetool>
          </target>
      
      
      
      <target name="hbm2doc">
              
              
              <hibernatetool destdir="${generateddocdir}">
                
           
                
                <configuration configurationfile="${hibernateConfigdir}/hibernate.cfg.xml">                 
                  <fileset dir="${hibernateSourcedir}/events">
                    <include name="**/*.hbm.xml"/>
                  </fileset>
                </configuration>
                
                <hbm2doc/>
                
              </hibernatetool>
          </target>
      
      
      
      
      <target name="hbm2hbmxml">
              
              
              <hibernatetool destdir="${generatedhbmdir}">
                
              
               
                
                 <configuration configurationfile="${hibernateConfigdir}/hibernate.cfg.xml">                 
                  <fileset dir="${hibernateSourcedir}/events">
                    <include name="**/*.hbm.xml"/>
                  </fileset>
                </configuration>
                
                <hbm2hbmxml/>
                
              </hibernatetool>
          </target>
      
      <target name="echo">
      <echo message="${java.class.path}" />
      </target>
      
      <target name="hbm2dao">
              
              
              <hibernatetool destdir="${generateddaodir}">
                
                <classpath>
                  <path location="${hibernateConfigdir}"/>
                </classpath>
      
      
                
               <property key="ejb3" value="false"/> 
            <property key="jdk5" value="true"/> 
           
           
      
                
                 <configuration configurationfile="${hibernateConfigdir}/hibernate.cfg.xml">                 
                  <fileset dir="${hibernateSourcedir}/events">
                    <include name="**/*.hbm.xml"/>
                  </fileset>
                </configuration>
           <hbmtemplate template="${hibernateConfigdir}/CustomDAOTemplate.ftl" filepattern="{package-name}/{class-name}DAO.java"/> 
                
                <hbm2dao/>
                
                
              </hibernatetool>
          </target>
      
      
      
      
          <target name="compile" description="Compile all POJO java files">
          
              <javac destdir="${build.dir}" failonerror="true" srcdir="${generatedSourcedir}:${generateddaodir}" >
                      <classpath refid="toolslib"/>
                      <exclude name="**/*Home.java"/>
              </javac>
              
              
           </target>
      
      
      <target name="clean"
              description="clean up and create folders" >
          
          <delete dir="${generatedSourcedir}"/>
          <delete dir="${generateddaodir}"/>
          <delete dir="${generatedsqldir}"/>
          <delete dir="${generatedhbmdir}"/>
          <delete dir="${build.dir}"/>
          <delete dir="${release.dir}"/>
          
          <mkdir dir="${generatedSourcedir}"/>
          <mkdir dir="${generateddaodir}"/>
          <mkdir dir="${generatedsqldir}"/>
          <mkdir dir="${generatedhbmdir}"/>
          <mkdir dir="${build.dir}"/>
          <mkdir dir="${release.dir}"/>
          
       </target>
      
      <!--create jar which is a set of all java class files-->
      
      <target name="createjar" depends="clean,hbm2ddl,hbm2java,echo,hbm2dao,hbm2hbmxml,hbm2doc,compile">
      <jar destfile="${release.dir}/app.jar" basedir="${build.dir}"/>
      </target>
      
      
      </project>
      Best Regards,
      -Shobhit