Some of the most common defenses are:
The search that discovered the drug was illegal
The drugs belonged to someone else (your roommate, for example, if they were found in your apartment)
The crime lab analysis reveals that the substance you were caught with was not actually an illegal drug
The drugs are missing (the police misplaced them)