You have a unique combination of too much information with too little.
If you are actually running that code, then package it up as a complete, runnable example -- yes, it won't run on another machine unless that machine also has a database setup, but it will tell us everything you're doing instead of just the part that you think is important.
Give us the complete error message, don't tell us what it is.
Two important things to remember about posting a question on a site like this: you don't know what's wrong, so you need to give us complete raw data, not half-analysis. And it is generally a waste of time for us to just guess at things.