6 Replies Latest reply on Nov 24, 2009 1:37 AM by kyazici

    Ant Build Failed - failed to copy ~ drools-templates.jar due to java.io.FileNotFoundException

    rgoytacaz
      Hello Seam users,

      I've created a seam project using seam-gen and then importing it into eclipse.

      The first time the compiler ran, everything was alright. After I made a change into the code, as soon as I save, the ant builds the project again into JBoss giving me error...

      Ant Build Failed - failed to copy ~/drools-templates.jar due to java.io.FileNotFoundException

      I went into JBoss directory and deleted everything from my deploy.3

      When I ran the deploy it went okay! If I try to deploy it again, its going to show me the same error.

      Can any1 help me on this?
        • 1. Re: Ant Build Failed - failed to copy ~ drools-templates.jar due to java.io.FileNotFoundException
          rgoytacaz

          BUILD FAILED
          /home/rgoytacaz/workspace/myproject/build.xml:303: Failed to copy /home/rgoytacaz/workspace/myproject/exploded-archives/myproject.ear/lib/drools-templates.jar to /srv/jboss-5.1.0.GA/server/default/deploy/myproject.ear/lib/drools-templates.jar due to java.io.FileNotFoundException /srv/jboss-5.1.0.GA/server/default/deploy/myproject.ear/lib/drools-templates.jar (Not a directory)


          this is the full error message.

          • 2. Re: Ant Build Failed - failed to copy ~ drools-templates.jar due to java.io.FileNotFoundException
            erimag

            Sounds like there is a problem with the ant script in that it uses a todir attribute on the copy-task when it should be using a tofile attribute. Alternatively, it should be pointing the todir attribute to the destination directory instead of the whole file path name.


            If this is the seam-gen ant script I would suggest filing an issue against the Build component in the Seam JIRA: https://jira.jboss.org/jira/browse/JBSEAM


            It should be relatively straight forward to fix it yourself in your local ant file given a little ant knowledge, though: http://ant.apache.org/manual/CoreTasks/copy.html

            • 3. Re: Ant Build Failed - failed to copy ~ drools-templates.jar due to java.io.FileNotFoundException
              v.lukoyanov

              Try ant explode instead of ant deploy.

              • 4. Re: Ant Build Failed - failed to copy ~ drools-templates.jar due to java.io.FileNotFoundException
                rgoytacaz

                this happens on the auto build from the eclipse ide

                • 5. Re: Ant Build Failed - failed to copy ~ drools-templates.jar due to java.io.FileNotFoundException
                  kyazici

                  Here is the thing I figured out after one week. When I checked out the deploy folder of the jboss AS I have, I saw there is the ear file that was copied by the deploy target. Then I deleted it and executed the explode command. There was the answer of my one week time; explode command creates a directory with the same name. So the problem is, when you try to deploy after an explode, ant tries to replace the directory created by explode with an ear file, or vice versa if you execute explode after deploy. Since both have the same name the OS (for me it is windows Vista) gives error that it cannot replace a directory with a file that have the same name. So, I solve the problem by changing the deploy target in build.xml.


                  I changed the


                      <target name="deploy" depends="archive,datasource" description="Deploy the packaged archive">
                          <fail unless="jboss.home">jboss.home not set</fail>
                          <copy todir="${deploy.dir}" file="${dist.dir}/${project.name}.ear"/>
                      </target>
                  


                  lines with


                      <target name="deploy" depends="archive,datasource" description="Deploy the packaged archive">
                          <fail unless="jboss.home">jboss.home not set</fail>
                           <antcall target="explode"/>        
                      </target>
                  


                  So instead of copying the ear file that is generated by archive target I simply call the explode command in the deploy target. Another solution can be, checking the deploy directory and if there is a file named ${project.name}.ear deleting it before explode is called, by adding 

                  <delete file="${dist.dir}/${project.name}.ear"> </delete>

                  command to the explode like


                      <target name="explode" depends="stage,datasource"
                          description="Deploy the exploded archive">
                          <fail unless="jboss.home">jboss.home not set</fail>  
                           <delete file="${dist.dir}/${project.name}.ear"> </delete>        
                          <copy todir="${ear.deploy.dir}">
                              <fileset dir="${ear.dir}">
                                  <include name="**/*"/>
                                  <exclude name="${project.name}_jar/**"/>
                                  <exclude name="${project.name}_war/**"/>
                              </fileset>
                          </copy>
                          <copy todir="${jar.deploy.dir}">
                              <fileset dir="${jar.dir}"/>
                          </copy>
                          <copy todir="${war.deploy.dir}">
                              <fileset dir="${war.dir}"/>
                          </copy>
                      </target>
                  


                  I did not add the condition but it still works. Actually I am not that experienced at ant. If someone could add a deploy.directory.exists condition I would appreciate it. So I hope this saves others time. Cheers.





                  • 6. Re: Ant Build Failed - failed to copy ~ drools-templates.jar due to java.io.FileNotFoundException
                    kyazici

                    Sorry last one should be



                        <target name="explode" depends="stage,datasource"
                            description="Deploy the exploded archive">
                            <fail unless="jboss.home">jboss.home not set</fail>  
                             <delete file="${deploy.dir}/${project.name}.ear"> </delete>        
                            <copy todir="${ear.deploy.dir}">
                                <fileset dir="${ear.dir}">
                                    <include name="**/*"/>
                                    <exclude name="${project.name}_jar/**"/>
                                    <exclude name="${project.name}_war/**"/>
                                </fileset>
                            </copy>
                            <copy todir="${jar.deploy.dir}">
                                <fileset dir="${jar.dir}"/>
                            </copy>
                            <copy todir="${war.deploy.dir}">
                                <fileset dir="${war.dir}"/>
                            </copy>
                        </target>
                    
                        </target>