views:

73

answers:

1

I am facing a problem with file upload.I have used Apache Commons servlet file upload for uploading the file. Though the file is getting uploaded and the data is getting stored on the local server(http:// 127.0.0.1:8888/_ah/admin/datastore) but it is not going to the Google App Engine datastore. What I am doing is loading the file as a stream and immediately parsing the stream and creating datastore entities with the data. I am not actually trying to save the file. In the local server it works. It even works when I try to access the local server from another machine. However it does not work when I deploy it to Appengine using the Google Pluggin for Eclipse. My parsing code depends on resource files which are under the web-inf directory. Is it possible these resource files are not getting uploaded and is there a way to check what files are uploaded on Appengine?

+1  A: 

Whatever's in your .war is going up into AppEngine. I don't see how parts of it will be selectively excluded. What's more likely is that your application is depending on stuff that is lurking SOMEwhere on your PC but not included in that .war file.

However, shouldn't your application be checking for those resources and throwing exceptions if they are not found? If it's failing silently, I'd consider that a design flaw.

Logging a lot may help you debug the problem. You can look at your program's logs via the AppEngine console. I recommend more error checking and logging.

Something else to check for is to not be running the version of your software you think you are. There's a kind of versioning mechanism that allows you to deploy different concurrent versions of your and only one will be actually accessible. One of the things you should be logging and/or making otherwise accessible is some version information (perhaps even including a build timestamp) for your app's build.

Carl Smotricz
+1 for more logging
Ashwin Prabhu
Thanks for replying. I did try logging my app with following:if (item.isFormField()) { log.warning("Got a form field: " + item.getFieldName());} else { log.warning("Got an uploaded file: " + item.getFieldName() + ", name = " + item.getName());int len;byte[] buffer = new byte[8192];while ((len = stream.read(buffer, 0, buffer.length)) != -1) { log.info(buffer.toString());}though it gave correct value for 1st log statement, it gave garbage values for 2nd one irrespective of my file type.Can you explain this?
Vishakha Gupta
If by "the second one" you meant logging `buffer.toString()`, that's understandable. The String representation of an array is "L" and some address. You might want to try Arrays.toString(buffer) instead.
Carl Smotricz
Thanks. Now it is showing some ASCII values for the data in the file. Does this mean atleast my file is getting uploaded? If yes then why is the data not reaching the google-datastore?
Vishakha Gupta
Well, if you're not checking len then you can't even be sure of that. But probably yes. Why don't you try accessing the value you stuck into the store immediately afterwards and see what's there?
Carl Smotricz
Act I dont want to get into the file. I just want to upload a kml file and unmarshall it using the java api for kml and store contents into datastore. M directly using Kml.unmarshall(InputStream stream).
Vishakha Gupta