It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

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

St. Wissel 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 {

    @test

    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

3 votes
Answer accepted
St. Wissel Jun 05, 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.

Suggest an answer

Log in or Sign up to answer
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Published in Bitbucket Pipelines

Building a Bitbucket Pipe as a casual coder

...ipe.sh :  #!/bin/bash source "$(dirname "$0")/common.sh" enable_debug extra_args="" if [[ "${DEBUG}" == "true" ]]; then extra_args="--verbose" fi # mandatory variables R...

3,077 views 1 20
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you