'Properties Reader does not read properties

In my project I'm trying to read some data from properties file. I wrote the PropertiesReader class which looks like this:

public class PropertiesReader {
    private final Properties properties;

    public PropertiesReader(String propertyFileName) throws IOException {
        InputStream is = getClass().getClassLoader()
                .getResourceAsStream(propertyFileName);
        this.properties = new Properties();
        this.properties.load(is);
    }

    public String getProperty(String propertyName) {
        return this.properties.getProperty(propertyName);
    }
}

It works just fine in one of modules in the project, but in the second one I get an error:

Exception in thread "main" java.lang.NullPointerException: inStream parameter is null

The code of the second module looks like this:

public class OutputAdapter {

    public static void main(String[] args) throws Exception {
        PropertiesReader properties = new PropertiesReader("properties.properties");

        ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("tcp://" + properties.getProperty("activemq-host"));
        Connection connection = connectionFactory.createConnection();
        connection.start();   
        ...  
    }
}

This is the file structure I have:

This is the file structure I have

And that's how I declared resources in pom:

<build>
    <resources>
        <resource>
            <directory>${project.basedir}/src/main/resources</directory>
        </resource>
    </resources>
    ...
</build>


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source