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 9244739
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T09:06:32+00:00 2026-06-18T09:06:32+00:00

I am having some confusing behavior on a Maven2 unit test. The following test

  • 0

I am having some confusing behavior on a Maven2 unit test. The following test code produces different results running in Eclipse vs. Maven2:

File f = new File( JUnitConstants.TEST_FILE );
File root = new File( "." );
Log.info( "File Info:" );
Log.info( f.toString() + (f.exists() ? " exists" : " doesn't exist") );
Log.info( f.getAbsoluteFile().toString() + (f.getAbsoluteFile().exists() ? " exists" : " doesn't exist") );
Log.info( root.toString() + (root.exists() ? " exists" : " doesn't exist") );
Log.info( root.getAbsoluteFile().toString() + (root.getAbsoluteFile().exists() ? " exists" : " doesn't exist") );

In Eclipse, everything exists and the unit tests runs fine. In maven, the f.exists() method returns false; so it thinks that file doesn’t exist! Here is the output from the maven run test:

2013-01-10 09:50:51,737 [main] INFO  - File Info:
2013-01-10 09:50:51,737 [main] INFO  - target\test-classes\test\test.img doesn't exist
2013-01-10 09:50:51,737 [main] INFO  - C:\Users\me\code\HEAD\modules\project\target\test-classes\test\test.img exists
2013-01-10 09:50:51,737 [main] INFO  - . exists
2013-01-10 09:50:51,737 [main] INFO  - C:\Users\me\code\HEAD\modules\project\. exists

So, the file exists, the root directory is what I expect, but why does Java think the file does not exist, when using relative paths?

I’m on Windows 7, 64-bit; using JDK 1.6_38 32-bit.

  • 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-18T09:06:33+00:00Added an answer on June 18, 2026 at 9:06 am

    After some time, I’ve determined that the problem is the forking of the surefire test process. The maven build runs the tests under a command similar to:

    cmd.exe /X /C ""C:\Program Files (x86)\Java\jdk1.6.0_38\jre\bin\java" -Djava.library.path=target/test-classes -jar C:\Users\me\AppData\Local\Temp\surefirebooter6580985433891892701.jar C:\Users\me\AppData\Local\Temp\surefire8381564625923782274tmp C:\Users\me\AppData\Local\Temp\surefire2578536694398675625tmp"
    

    I can run java with those exact parameters (inside the quotes) from the command line and everything works, but as soon as I fork them to another command window (the cmd.exe /X /C), it fails the same way.

    I’ve solved this by disabling forking in the pom.xml file:

    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <configuration>
            <argLine>-Djava.library.path=target/test-classes</argLine>
            <forkMode>never</forkMode>
        </configuration>
    </plugin>
    

    This still must be something in my system configuration, because other Windows 7 64-bit computers don’t have this issue, but turning off forking seems to be a solution.

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

Sidebar

Related Questions

I am testing fragments in Android and I'm having some confusing behavior with Fragment
Having some trouble getting a screenscraper webservice up and running on a weblogic 10.3.3
I'm having some trouble updating Access tables from a DataGridView. What's confusing me is
Having a confusing issue with jQuery, basicly this code is added to 2 elements,
In deploying some clojure code to a new server, I've been having problems with
In some code requiring subclassing of inner traits/classes I'm having trouble successfully implementing an
This may be a little confusing but I having some trouble. My goal is
I am having some confusion with the new keyword,things work fine when I am
ASP.NET Application I am having some confusion with showing images. IE is fully working
I'm having some problem consuming REST Service and want to figure out what I'm

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.