Ensure that the base layer is firmly pressed and that there are no gaps. Also, spreading the jam filling evenly and not too close to the edges can help prevent leaking.