Adhesion is a complex and multifaceted phenomenon which is controlled by various factors such as the loading rate, interface toughness, temperature and geometric and molecular properties. The mode of failure of adhesive joints (adhesive or cohesive) is decided through a complex interplay between these factors. In this work, we study the failure under tensile loading of a thin layer of a polymeric material confined between two rigid walls using molecular dynamics simulations. The strength of the interface is controlled by the interaction potential between the polymer and wall atoms. The polymer modelled is a simple linear chain of 'united atoms' having a fixed bond length but contributions to the energy arise from bending and torsion of bonds as well as from non-bonded interactions between the 'united atoms'. The results indicate that even when the adhesion between the wall and the polymer is weak, a short chained polymer is more likely to fail by a mixed adhesive cohesive mode. A long chained polymer, with the same interface strength, fails in a pure adhesive manner. However, when the interface is sufficiently strengthened, the long chained polymer fails cohesively and it can bear a much higher load. The failure mode is somewhat modulated by the rate at which deformation occurs. Moreover, when the polymer is confined such that the spacing between the walls is comparable to the end-to-end distance of the polymer chain, strength of the joint increases significantly. In such a situation, even polymers with weak interfacial adhesion might fail cohesively.