There is no trains to Dubrovnik so one can not arrive in Dubrovnik by train.
One can take a train to Split from Zagreb and then take bus to Dubrovnik.
Also, one can take the train from Sarajevo or Mostar to Plo?e ( the closest train station to Dubrovnik) and then again, take bus to Dubrovnik (about 2 hours ride)
See bellow post about trains to Dubrovnik:
https://www.find-croatia.com/forum/index.php?topic=1191.0
See also Getting from Zagreb to Dubrovnik :
https://www.dubrovnik-travel.net/getting-from-zagreb-to-dubrovnik/