Getting error in workflow when waiting for 2 hours and querying at the same time

worker.addWorkflowImplementationFactory(ParentWorkflow.class, () → new ParentWorkflowImpl());
worker.addWorkflowImplementationFactory(ChildWorkflow.class, () → new ChildWorkflowImpl());

I believe you should just use
worker.registerWorkflowImplementationTypes(ParentWorkflowImpl.class, ChildWorkflowImpl.class);

Promise promise = Async.procedure(childWf::execute);
promise.get();

If you want to wait for child to complete you could just call

childWf.execute();

WorkflowClient.start(workflow1::execute);
        //query continuously. Not able to reproduce without this block
       while(true) {
           workflow1.query();
       }

Not sure what is the intent of this test, you start your workflow execution async, and then slam the frontend service with query calls forever (even after workflow exec completes). Depending on your setup (assuming here local docker) this could run into issues on both server side and your workers. I believe the error you are getting is that server wasnt able to dispatch the query task to your worker(s).

What is the use case where you would need such a test?
If you are trying to test polling see this forum thread.