The train follows a predictable route. They lay over at stations. You can charge at the end of the line during layovers. It's not that hard.
I agree, though I still think charging at most if not all stations would help.
Also solar panels should help with charging,
I think only thin film solar panels would be appropriate for trains and I am not sure if the technology is quite ready yet.
and possibly a small diesel motor for emergencies.
It all depends how much reserve capacity there would be in the battery, but that would be an option.