Just a SWAG; maybe the connection information is missing? This is one reason that the datalayer may not be able to be created. I had a similar situation when I created BOs outside the general context of a standard SF application. Check the inner exception (if provided) on the error and see what it indicates.
HTH
-=Gary