Showing posts with label Google App Engine. Show all posts
Showing posts with label Google App Engine. Show all posts

Friday, February 3, 2012

Use of com.google.appengine.repackaged may result in your app breaking without warning.

I got this nasty error on the repackaged version of Base64 after upgrading to app-engine 1.6.1 on a project:

Use of com.google.appengine.repackaged may result in your app breaking without warning.

You can make it go away by switching to org.apache.commons.codec.binary.Base64, that can be found on the commons-codec library. Mapping of the encode/decode methods is pretty straightforward:
  • encode --> encodeBase64String
  • decode --> decodeBase64
Or something like that.

Monday, November 28, 2011

AccessControlException when pushing file to S3 bucket from GAE (on OSX)

This is one of those edge case scenarios that can drive people crazy.

I was trying to push a file from a Google App Engine app to an Amazon S3 bucket via the jetS3t API and it would keep coming back with an AccessControlException (access denied) kind of exception.

After quite a bit of digging around turns out the Mac default Java SDK will try to load a native library for the cryptographic needs of the S3 stuff and this is forbidden in GAE.

There's 2 workarounds apparently:
  1. if you feel adventurous, (as I did) add this to your VM args from Properties > Run/Debug settings > Edit launch configuration options > Arguments: -D--enable_all_permissions=true
  2. use another crypto library instead of the default (BouncyCastle is a common one, and it comes with the S3 API).  
Happy hacking!

EDIT (Dec 2nd 2011)Some news after more work on this, unfortunately solution 1) only fixes the problem locally - when you go and deploy you still get the same AccessControlException. Also, it appears that Google App Engine prevents you from specifying a custom crypto library so solution 2) is no good either. But bad news don't stop there, according to this thread
JetS3t is not compatibile with Google App Engine. Or the other way around. Because JetS3t uses a number of libraries and techniques that are not supported in the restricted execution environment of Google App Engine there is no easy way to remedy this.
Viable solutions seem to be:
  1. This contraband version of the AWS SDK forked for app-engine
  2. jclouds
I am in the process of trying some of this stuff. Will probably post something in a future post (if this stuff doesn't kill me first).

Saturday, January 9, 2010

What a .NET guy likes about AppEngine

I recently completed work on an app built on AppEngine and Google Web Toolkit:



It's basically a logo design app with a twist - follow the link if you wanna find out more on the app itself.

To the point, the team on this project came mostly from a Java background and even though I am mainly a .NET nut I also have a bit of Java under the belt, so this project represented the perfect opportunity for me to get some sweet  AppEngine + GWT action.

So here we go, here's the good old list of things I really liked about the setup on this project (Java/AppEngine/GWT on Eclipse + Google plugins) compared to the setup I am more familiar with (C#/ASP.NET + SQLServer + Azure hosting, all on VS):
  • With AppEngine and the Google-Datastore you don't have to cope with SQL or SQLServer (and if you follow this blog you know how I feel about SQL)
  • You can literally deploy your app with one-click from the eclipse plug-in (all extremely easy to setup - and it works)
  • Hosting is free on google appspot (if you don't go over the free quotas, and quite cheap after that anyway)
  • GWT = virtually no messing around with javascript (I do like javascript but not if I am in a hurry)
  • .NET/VS to JAVA/Eclipse transition turned out to be OK (Eclipse is pretty cool) with people around to rely on
So far AppEngine has proven reliable - the app still runs a bit slow but we did not put any effort into improving performance (I've seen ASP.NET apps running much slower, and it rarely boils down to hosting anyway) - stay tuned for more.

Thursday, October 1, 2009

How to mimic SQL WHERE clause on Google Datastore queries

This puzzled me for a while as I never used JDO before crashing the app-engine party.

Assuming we have an Order class with a member variable named customer of type User:

//get current user
UserService userService = UserServiceFactory.getUserService();
User user = userService.getCurrentUser();

//prepare query
PersistenceManager pm = PMF.get().getPersistenceManager();
String select_query = "select from " + Order.class.getName();
Query query = pm.newQuery(select_query);
query.setFilter("customer == paramCustomer");
query.declareParameters("com.google.appengine.api.users.User paramCustomer");

//execute query
List<OrderDTO> result= OrderUtils.getOrderDTOList((List<Order>) query.execute(user));

//feck-off --> I'll never get an MVP but I can swear on my blog!
pm.close();

Just wanted to share to spare some random googler (you) the same process.

Saturday, September 26, 2009

Google App Engine for JAVA Local Data Viewer!

I've been screaming like a sissy for a local Data Viewer since I put my hands on the Google App Engine. Turns out it has been there for a while (definitely not from the beginning) but I didn't know. It can be accessed when you're running the development server locally from the following URL (assuming you're running the default setup):

http://localhost:8080/_ah/admin/

You can browse your data and delete records but for the time being (at least on Java App Engine) edit operations are not supported, so don't bin just yet your dirty little hacks (a bunch of servlets in my case) for local development.

Tuesday, June 9, 2009

Google App-Engine Mail Service: Unauthorized Sender Error

I was messing around with the Google App-Engine mail service and I stumbled upon a little gotcha that I feel like sharing.

To cut a long story short - you can send emails though the mail service only from emails of accounts (google accounts or other Google app domains) registered as Developers from the Google app engine dashboard (Google App-Engine--> Dashboard--> Developers).

It took me a while to figure this out because:
  1. It doesn't make any sense: assume you wanna setup an admin account to send out mini-reports from your scheduled cron jobs, in this scenario you're supposed to setup your admin@yourDomain.com as a Developer!?
  2. I am linking this Google app deployed to appspot to a domain I have registered with Google, so I thought the app could send emails only from accounts registered as administrator of my given domain, which would make slightly more sense!

But then - I can only blame myself 'cause the documentation clearly says:
The sender must be either the address of a registered developer for the application, or the address of the user for the current request signed in with a Google Account.

As a matter of fact, I never read the documentation till I am desperate (who does?).

Sunday, May 3, 2009

[Google App Engine] How to Clear SDK Datastore

To clear the SDK datastore you'll just have to delete the following file: "./WEB-INF/appengine-generated/local_db.bin". The file will be generated for you again next time you run the development server and you'll have a clear db.

This is one of the little gotchas that come in handy when you start playing with the Google Application Engine. You'll find yourself persisting objects into the datastore then changing the JDO object model for your persistable entities ending up with a obsolete data that'll make your app crash all over the place.