Your stacktrce doesn't say that it can't find TDBFactory. It says that it can't find
com.hp.hpl.jena.sparql.engine.main.StageGenBasicPattern.
It sounds like you need some more jars on your classpath. After you download the apache-jena bundle from Apache Jena Releases, put all the jars in the lib
subdirectory on your classpath, not just the tdb
jar.