Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn more

View all

Sign in to view all badges

SOLVED

Not able to load resources folder file

mohitaem
Level 2
Level 2

Hi Team,

We are trying to load "geodb.mmdb" which is present in resources folder in our AEM bundle code.
Maxmind uses this mmdb file.
Code for loading the file:

File database = new File(classLoader.getResource("geodb.mmdb").getFile());
dbReader = new DatabaseReader.Builder(database).build();

We are pretty sure that the file exists in the resources folder in our maven project. When we build our package and upload it in AEM we get "java.io.FileNotFoundException: \geodb.mmdb (The system cannot find the file specified)" exception when we hit the servlet.

Thanks,

Mohit

1 Accepted Solution
mohitaem
Correct answer by
Level 2
Level 2

Thanks so much for the quick response smacdonald2008

The stackoverflow post was really useful to find the right solution.

This is the code for loading the inputStream from the file which is inside the resources folder in bundle jar.

Thanks,

Mohit

View solution in original post

2 Replies
mohitaem
Correct answer by
Level 2
Level 2

Thanks so much for the quick response smacdonald2008

The stackoverflow post was really useful to find the right solution.

This is the code for loading the inputStream from the file which is inside the resources folder in bundle jar.

Thanks,

Mohit

View solution in original post