title: detect AppEngine vs basic server
body: <p>I am developing a web app to run on either Google's AppEngine or a basic server with file storage (it may not stay that way but that's the current status).</p>
  
  <p>How do I detect whether the AppEngine services (most importantly blobstore) are available at runtime?</p>
  
  <p>I have tried using code like the following:</p>
  
  <pre><code>    try{
          Class.forName( "com.google.appengine.api.blobstore.BlobstoreServiceFactory" );
          logger.info( "Using GAE blobstore backend" );
          return new GAEBlobService();
      }catch( ClassNotFoundException e ){
          logger.info( "Using filesystem-based backend" );
          return new FileBlobService();
      }
  </code></pre>
  
  <p>but it doesn't work because BlobstoreServiceFactory is available at compile time. What fails if trying to use GAE's blobstore without a GAE server is the following:</p>
  
  <pre><code>com.google.apphosting.api.ApiProxy$CallNotFoundException: The API package 'blobstore' or call 'CreateUploadURL()' was not found.
  </code></pre>