I've been breaking my head for a while and couldn't figure this one out. Tried alternative methods but couldn't make it. I believe it's a bug in osmosis-areafilter.
There is no issue tracker in the GitHub repository and the provided link for reporting bugs requires username/password (https://trac.openstreetmap.org/query?status=!closed&component=osmosis).
To the issue:
within my Java project, I tried to run the command:
Osmosis.run(new String[] {"--xml-read", "data/map.osm", "--bounding-polygon", "data/bounds.poly", "--xml-write", "data/map_cut.osm"});
It crashed and the error message included: "polygon.txt not found", which is the default call of the --bounding-polygon function.
Renaming my bounds.poly to polygon.txt and putting it in the main project folder was a successful but hopefully temporary workaround.
I was expecting someone here could test it to confirm whether it's a bug and then raise the issue in OSM's closed tracker. If I'm wrong and it's not a bug, then I'd be happy to know what is wrong and be able to fix it.
Solved the issue. Its because I was not using the parameter key "file=" before the actual path to the .poly file.
The confusion happened because in some pipes (e.g. read-xml and write-xml) it is not needed to explicit the parameter key and I thought the case here was the same.
In fact a closer look to the wiki makes this clear by adding the "(default)" word to define a parameter that doesn't needs to be explicited. In case of the --bounding-polygon pipe, there is no default parameter so it is necessary to specify each key=value pair for the options.