Context. Orbital mean motion resonances in planetary systems originate from dissipative processes in disk-planet interactions that lead to orbital migration. In multi-planet systems that host giant planets, the perturbation of the protoplanetary disk strongly affects the migration of companion planets. Aims. By studying the well-characterized resonant planetary system around GJ 876 we aim to explore which effects shape disk-driven migration in such a multi-planet system to form resonant chains. Methods. We modelled the orbital migration of three planets embedded in a protoplanetary disk using two-dimensional locally isothermal hydrodynamical simulations. In order to explore the effect of several disk characteristics, we performed a parameter study by varying the disk thickness, α viscosity, mass as well as the initial position of the planets. Moreover, we have carefully analysed and compared simulations with various boundary conditions at the disk’s inner rim. Results. We find that due to the high masses of the giant planets in this system, substantial eccentricity can be excited in the disk. This results in large variations of the torque acting on the outer lower mass planet, which we attribute to a shift of Lindblad and corotation resonances as it approaches the eccentric gap that the giants create. Depending on disk parameters, the migration of the outer planet can be stopped at the gap edge in a non-resonant state. In other models, the outer planet is able to open a partial gap and to circularize the disk again, later entering a 2:1 resonance with the most massive planet in the system to complete the observed 4:2:1 Laplace resonance. Conclusions. Disk-mediated interactions between planets due to spiral waves and excitation of disk eccentricity by massive planets cause deviations from smooth inward migration of exterior lower mass planets. Self-consistent modelling of the disk-driven migration of multi-planet systems is thus mandatory. Constraints can be placed on the properties of the disk during the migration phase, based on the observed resonant state of the system. Our results are compatible with a late migration of the outermost planet into the resonant chain, when the giant planet pair already is in resonance.