0
ProjectA
    -src/main/java
        -com.myApp.accessor
            -resourceAccessor.java
    -src/test/resources
        -context.xml
    -target/test-classes/context.xml

ProjectB (dependent on ProjectA)
    -src/main/java
        -xyz.java

Now I need to access the context.xml from ProjectB. What I'm doing is:

Class resourceAccessor{

    public static void loadFile(){
       ....
       this.getClass().getResources("/context.xml").getPath;
       ....
    }
}

in xyz, I have

resourceAccessor.loadFile();

But this throws null pointer exception.

fabian
  • 80,457
  • 12
  • 86
  • 114
Edmond
  • 614
  • 2
  • 11
  • 26

1 Answers1

0

Solved the issue by putting the context.xml into src/main/resources/com.myApp.accessor/context.xml. Then use

getClass().getResource("context.xml").getPath()
Edmond
  • 614
  • 2
  • 11
  • 26