宝の山に入りながら手を空しくして帰る (たからのやまにいりながらてをむなしくしてかえる, takaranoyamaniirinagaratewomunashikushitekaeru) means "to have a good opportunity only to let it slip from your grasp; to come home empty-handed despite having entered treasure mountain". It is an expression. It is an idiom.