The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Maven build runs local but fails in pipeline with resource not found

St. Wissel
Contributor
May 24, 2018

I have a JUnit test class that is triggered by the maven build.

It loads a file `src/test/resources/ConfigTest.json`

When running locally from the command line it works as expected, but when running in the bitbucket-pipeline this test fails:

```

import java.io.File;

import org.junit.Assert;

import org.junit.Test;

 

public class ClassLoaderTest {

    @techoneway

    public final void test() {

        ClassLoader c = this.getClass().getClassLoader();

        // THIS line fails with a null pointer

        File configFile = new File(c.getResource("ConfigTest.json").getFile());

        Assert.assertTrue(configFile.exists());

    }

}

```

What do I miss?

1 answer

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

3 votes
Answer accepted
St. Wissel
Contributor
June 5, 2018

Mystery solved. The culprint was this line in my `.bash_profile` on my Mac:

           # Case-insensitive globbing (used in pathname expansion)
           shopt -s nocaseglob;

It allows the `getResourceAsStream(name)` (and any other file operation) find files case insensitive. I presumed that Java on Mac would always be case sensitive.

There was one capitalisation error in my resource name, so the pipeline rightfully failed.

TAGS
AUG Leaders

Atlassian Community Events