I share a lot of things common in your question. From my personal experience I can tell you the following:
1. Train to maintain a positive attitude -- no matter what.
2. Failures are common to all. You failed but YOU are not a failure.
3. Analyze what is causing blocks (what you say as failure) on your way. Trying to achieve things beyond your capacity, lack skills, people backstabbing you, don't have enough energy to sustain your efforts.
4. Regardless of what is going on, work to enhance your energy level - both physically and mentally. Read my hub:
When your energy level is high, it helps to sustain efforts and succeed. It also helps to fight depression and low self esteem.