The Moonstone
It's described in my link as the first detective novel, whether or not that's true.
Happy ending? Well, it's not ecstatically happy. But compared to A Tale of Two Cities, it ends quite nicely.
Classic? Hmm. It's old, and it's fairly famous, but I'm on the fence with calling it a classic. Wilkie Collins was more a master of plot than characterization. I liked it, but I didn't feel myself to have touched perfection.
Where The Moonstone shines, in terms of meeting purple_fishy's criteria, is in being far different from a Jane Austen book.