Hi Faéze
Thank you for providing the detailed description and attachments.

In Flink, the actual file reading operation is performed by the
TaskManager, not the JobManager.
Although you copied the file into the JobManager container, the TaskManager
is the one that attempts to access /opt/input.txt when executing the job.

To resolve the issue, you need to also copy the input.txt file into the
TaskManager container.
Once the file is available there, your job should be able to read it
successfully.

Best regards,
Feng


On Tue, Apr 22, 2025 at 8:11 PM faeze ghanbarian via user <
user@flink.apache.org> wrote:

> Dear Flink Community,
>
> I'm currently working on a simple Apache Flink project inside Docker using
> version 1.15.2. The goal of the project is to read user transactions from a
> text file (`input.txt`), calculate the total transaction amount per user,
> and write the result as a CSV.
>
> My code uses this line to read the input:
>     env.readTextFile("/opt/input.txt");
>
> However, I keep encountering the following error during execution:
>
>     Caused by: java.io.FileNotFoundException: The provided file path
> /opt/input.txt does not exist.
>
> This is what I've done so far:
> - I copied the input file into the container using:
>     `docker cp input.txt flink-jobmanager:/opt/input.txt`
> - I also checked and verified that the file exists using:
>     `docker exec flink-jobmanager ls -l /opt/input.txt`
>     and it shows the file correctly.
> - I run the job using:
>     `docker exec -it flink-jobmanager bash -c "./bin/flink run -c
> UserTransactionSum /opt/UserTransactionSum.jar"`
>
> Still, the job fails with the same `FileNotFoundException`.
>
> I'm attaching a zip of my project which includes:
> - `UserTransactionSum.java` (the main Java class)
> - `input.txt` (sample input file)
> - `docker-compose.yml` (used to set up the Flink cluster)
>
> Could someone please help me understand what I’m doing wrong? I'm stuck
> and would deeply appreciate your guidance ❤️
>
> Best regards,
> Faezeh Ghanbarian
> faezehghanbarian1...@yahoo.com
>
>
>

Reply via email to