Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8229883
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T16:57:01+00:00 2026-06-07T16:57:01+00:00

My problem is with running PigUnit via ant from a parent directory. I am

  • 0

My problem is with running PigUnit via ant from a parent directory.

I am using the PigUnit example straight off of the PigUnit site.

The ant script I am using is here:

    <junit printsummary="on" fork="true" haltonfailure="yes">
        <jvmarg value="-Duser.dir=${basedir}"/>

        <classpath refid="junit.class.path" />
        <formatter type="xml" />
        <batchtest todir="${test.report.dir}">
            <fileset dir="${test.dir}">
                <include name="**/*Test*.java" />
            </fileset>
        </batchtest>
    </junit>
</target>

This script works perfectly fine if I run ant in the working directory of the project. However, when I remotely call the script with this line of code in an ant build script in the Pig project’s parent directory

    <ant dir="${pig.dir}" target="main" inheritall="false" antfile="build.xml"/>

I get a FileNotFoundException:


java.io.FileNotFoundException">java.io.FileNotFoundException: top_queries.pig (No such file or directory)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:138)
at org.apache.pig.pigunit.PigTest.readFile(PigTest.java:273)
at org.apache.pig.pigunit.PigTest.readFile(PigTest.java:269)
at org.apache.pig.pigunit.PigTest.<init>(PigTest.java:92)
at TopQueriesTest.testTop2Queries(Unknown Source)

This same FNF exception also happens if I run ant from the command line in the parent directory:
ant -f PigJavaTest/build.xml junit

My workaround to helping PigUnit find top_queries.pig file to specifiy the top_queries.pig file’s location relative to the Pig project’s parent directory, e.g.

PigTest test = new PigTest("PigTestJava/top_queries.pig", args);

but this is not optimal because it breaks when running ant from a directory different from the parent one.

Other JUnit tests will run normally from the parent directory, but PigUnit always throws the same FNF exception. I also tried doing a simple test with PigServer (loading/dumping a file) and the PigServer test behaved just like PigUnit had.

Why does this FileNotFoundException get thrown when calling ant from the parent directory, and how can I fix it?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T16:57:02+00:00Added an answer on June 7, 2026 at 4:57 pm

    You have a relative path to your pig file. So if you call the ant script from the working directory of the project it should work. When you call the ant script from the parent project, the relative path now is relative to the parent directory.

    • http://ant.apache.org/manual/Tasks/ant.html

    when you call the ant task here, you are correctly setting the dir property, but that only changes the value of ${basedir} property for the follow in script, not the actual working directory when the junit task runs.

    I suggest you use the dir attribute in your junit task to hard set the working directory (i guess that’s what you’re trying to do with the jvmarg option):

    <junit printsummary="on" fork="true" haltonfailure="yes" dir="${basedir}">
        <jvmarg value="-Duser.dir=${basedir}"/>
    
        <classpath refid="junit.class.path" />
        <formatter type="xml" />
        <batchtest todir="${test.report.dir}">
            <fileset dir="${test.dir}">
                <include name="**/*Test*.java" />
            </fileset>
        </batchtest>
    </junit>
    

    See http://ant.apache.org/manual/Tasks/junit.html for more details

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having a problem running the C runtime example at http://www.antlr.org/depot/examples-v3/C/treeparser from Antlr. I've
I have a problem running an insert query via C# OleDbCommand to an Access
I'm using django with app-engine-patch and I'm having this wierd problem running manage.py dumpdata
I'm using Symfony 1.4 and Doctrine. So far I had no problem running tasks
I am having a problem running the 'test' Rake task from IntelliJ Idea in
I have a problem in running the cron job. here are my code: <?php
I'm having a problem running a T4 template using TextTransform.exe on my build server.
i'm having a problem running an sql in ms-access. im using this code: SELECT
I am using Xcode 4.2.1 and I have this problem running an existing application
I am having a problem running Ant with JDK 1.6 on Mac OS X.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.