We present the first 2.5 dimensional numerical model calculations of the nonlinear wave dynamics and heating by resonant absorption in coronal loops with thermal structuring of the transition region and higher chromosphere. The numerical calculations were done with the Versatile Advection Code. The transition region can move freely and is transparent for mass motions from chromosphere to corona. The loops are excited at the chromospheric level by linearly polarized monochromatic Alfven waves. We find that the efficiency of resonant absorption can be much lower than in equivalent line-tied coronal loop models. The inefficiency is due to the fast rate at which slow magnetosonic waves are nonlinearly generated in the chromosphere and transition region. This leads to considerable transfer of energy from the Alfven wave to the magnetosonic waves. Consequently, only a relatively small fraction of the Poynting flux that is injected into the loop system at the chromospheric level is available at the coronal level. Cavity leakage and detuning also have a negative impact on the efficiency, but less so than the nonlinear energy transfer. Inclusion of radiative and conductive losses improves the efficiency of resonant absorption. While the efficiency of resonant absorption heating is low, our results indicate that heating by compression and dissipation of the slow magnetosonic waves and shocks can easily lead to a temperature rise of a few percent, and for larger driver amplitudes even to a rise over 10%. Hence, our results support the idea of indirect coronal heating through the nonlinear generation of magnetosonic waves that was put forward more than 20 yr ago. Furthermore, the large transition region and coronal density oscillations that are associated with the slow magnetosonic waves provide an explanation for some observed coronal and transition region loop extreme-ultraviolet intensity variations.