Search Results

Search found 448 results on 18 pages for 'gae'.

Page 4/18 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • "Content is not allowed in prolog" when parsing perfectly valid XML on GAE

    - by Adrian Petrescu
    Hey guys, I've been beating my head against this absolutely infuriating bug for the last 48 hours, so I thought I'd finally throw in the towel and try asking here before I throw my laptop out the window. I'm trying to parse the response XML from a call I made to AWS SimpleDB. The response is coming back on the wire just fine; for example, it may look like: <?xml version="1.0" encoding="utf-8"?> <ListDomainsResponse xmlns="http://sdb.amazonaws.com/doc/2009-04-15/"> <ListDomainsResult> <DomainName>Audio</DomainName> <DomainName>Course</DomainName> <DomainName>DocumentContents</DomainName> <DomainName>LectureSet</DomainName> <DomainName>MetaData</DomainName> <DomainName>Professors</DomainName> <DomainName>Tag</DomainName> </ListDomainsResult> <ResponseMetadata> <RequestId>42330b4a-e134-6aec-e62a-5869ac2b4575</RequestId> <BoxUsage>0.0000071759</BoxUsage> </ResponseMetadata> </ListDomainsResponse> I pass in this XML to a parser with XMLEventReader eventReader = xmlInputFactory.createXMLEventReader(response.getContent()); and call eventReader.nextEvent(); a bunch of times to get the data I want. Here's the bizarre part -- it works great inside the local server. The response comes in, I parse it, everyone's happy. The problem is that when I deploy the code to Google App Engine, the outgoing request still works, and the response XML seems 100% identical and correct to me, but the response fails to parse with the following exception: com.amazonaws.http.HttpClient handleResponse: Unable to unmarshall response (ParseError at [row,col]:[1,1] Message: Content is not allowed in prolog.): <?xml version="1.0" encoding="utf-8"?> <ListDomainsResponse xmlns="http://sdb.amazonaws.com/doc/2009-04-15/"><ListDomainsResult><DomainName>Audio</DomainName><DomainName>Course</DomainName><DomainName>DocumentContents</DomainName><DomainName>LectureSet</DomainName><DomainName>MetaData</DomainName><DomainName>Professors</DomainName><DomainName>Tag</DomainName></ListDomainsResult><ResponseMetadata><RequestId>42330b4a-e134-6aec-e62a-5869ac2b4575</RequestId><BoxUsage>0.0000071759</BoxUsage></ResponseMetadata></ListDomainsResponse> javax.xml.stream.XMLStreamException: ParseError at [row,col]:[1,1] Message: Content is not allowed in prolog. at com.sun.org.apache.xerces.internal.impl.XMLStreamReaderImpl.next(Unknown Source) at com.sun.xml.internal.stream.XMLEventReaderImpl.nextEvent(Unknown Source) at com.amazonaws.transform.StaxUnmarshallerContext.nextEvent(StaxUnmarshallerContext.java:153) ... (rest of lines omitted) I have double, triple, quadruple checked this XML for 'invisible characters' or non-UTF8 encoded characters, etc. I looked at it byte-by-byte in an array for byte-order-marks or something of that nature. Nothing; it passes every validation test I could throw at it. Even stranger, it happens if I use a Saxon-based parser as well -- but ONLY on GAE, it always works fine in my local environment. It makes it very hard to trace the code for problems when I can only run the debugger on an environment that works perfectly (I haven't found any good way to remotely debug on GAE). Nevertheless, using the primitive means I have, I've tried a million approaches including: XML with and without the prolog With and without newlines With and without the "encoding=" attribute in the prolog Both newline styles With and without the chunking information present in the HTTP stream And I've tried most of these in multiple combinations where it made sense they would interact -- nothing! I'm at my wit's end. Has anyone seen an issue like this before that can hopefully shed some light on it? Thanks!

    Read the article

  • Spring GAE/J Could Not find API version error

    - by Julie Paltrow
    Hello, I am trying to use Spring MVC 3 on GAE/J and I got this error and I do not know what it means, does anybody have an idea and perhaps give me pointers on how to fix this? May 21, 2010 9:50:23 AM com.google.appengine.tools.info.LocalVersionFactory getVersion INFO: Could not find API version from /opt/home/me/workspace/SpringMVC/war/WEB-INF/lib/.svn java.util.zip.ZipException: error in opening zip file at java.util.zip.ZipFile.open(Native Method) at java.util.zip.ZipFile.<init>(ZipFile.java:114) at java.util.jar.JarFile.<init>(JarFile.java:133) at java.util.jar.JarFile.<init>(JarFile.java:97) at com.google.appengine.tools.util.ApiVersionFinder.findApiVersion(ApiVersionFinder.java:37) at com.google.appengine.tools.info.LocalVersionFactory.getVersion(LocalVersionFactory.java:65) at com.google.appengine.tools.info.UpdateCheck.getLocalVersion(UpdateCheck.java:112) at com.google.appengine.tools.info.UpdateCheck.checkForUpdates(UpdateCheck.java:91) at com.google.appengine.tools.info.UpdateCheck.doNagScreen(UpdateCheck.java:164) at com.google.appengine.tools.info.UpdateCheck.maybePrintNagScreen(UpdateCheck.java:132) at com.google.appengine.tools.development.DevAppServerMain$StartAction.apply(DevAppServerMain.java:150) at com.google.appengine.tools.util.Parser$ParseResult.applyArgs(Parser.java:48) at com.google.appengine.tools.development.DevAppServerMain.<init>(DevAppServerMain.java:113) at com.google.appengine.tools.development.DevAppServerMain.main(DevAppServerMain.java:89)

    Read the article

  • Restful authentication between two GAE apps.

    - by user259349
    Hello everyone, i am trying to write a restful google app engine application (python) that accepts requests only from another GAE that i wrote. I dont like any of the ways that i thought of to get this done, please advice if you know of something better than: Get SSL setup, and simply add the credentials on the request that my consuming app will send. I dont like it cause SSL will slow things down. Security by obsecurity. Add a random number in my request that is in Xmod0, where X is a secret number that both applications know. I just,,,, dont like this. Check the HTTP header to see where is the request coming from. This option is the one that i hate the least, not alot of processing, and spoofing an HTTP request is not really worth it, for my application's data. Is there any other clean solution for this?

    Read the article

  • chess AI for GAE

    - by Richard
    I am looking for a Chess AI that can be run on Google App Engine. Most chess AI's seem to be written in C and so can not be run on the GAE. It needs to be strong enough to beat a casual player, but efficient enough that it can calculate a move within a single request (less than 10 secs). Ideally it would be written in Python for easier integration with existing code. I came across a few promising projects but they don't look mature: http://code.google.com/p/chess-free http://mariobalibrera.com/mics/ai.html

    Read the article

  • GAE, JDO, count() doesn't work ?

    - by NilsBor
    On GAE with Spring/JDO after saving 2 entities (in transaction). On calling getById - entities fetched from data storage. On calling getCount() returns "0" and - on calling getAll() - returns empty collection. plz help me ! DAO: @Override public Long getCount() { return ((Integer) getJdoTemplate().execute(new JdoCallback() { @Override public Object doInJdo(PersistenceManager pm) throws JDOException { Query q = pm.newQuery(getPersistentClass()); q.setResult("count(this)"); return q.execute(); } })).longValue(); } @Override public void saveOrUpdate(T entity) { getJdoTemplate().makePersistent(entity); } @Override public List getAll() { return new ArrayList(getJdoTemplate().find(getPersistentClass())); }

    Read the article

  • Django version in GAE

    - by Alex
    I'm tring to use Django 1.1 in GAE, But when I uncomment use_library('django', '1.1') in this script import os os.environ['DJANGO_SETTINGS_MODULE'] = 'settings' from google.appengine.dist import use_library #use_library('django', '1.1') # Google App Engine imports. from google.appengine.ext.webapp import util # Force Django to reload its settings. from django.conf import settings settings._target = None import django.core.handlers.wsgi import django.core.signals import django.db import django.dispatch.dispatcher # Unregister the rollback event handler. django.dispatch.dispatcher.disconnect( django.db._rollback_on_exception, django.core.signals.got_request_exception) def main(): # Create a Django application for WSGI. application = django.core.handlers.wsgi.WSGIHandler() # Run the WSGI CGI handler with that application. util.run_wsgi_app(application) if __name__ == "__main__": main() I receives AttributeError: 'module' object has no attribute 'disconnect' What is going on?

    Read the article

  • How do i redirect to a GET request from a POST request on GAE

    - by user259349
    Hello everyone, i am writing an FBML app on facebook hosted in GAE. Facebook will talk to your hosted app only vai POST (im sure this is the cause, but please do correct me if i'm wrong). So im faced with the issue that inside of my POST method, i need to redirect to facebook OAuth authroize URL. But i can only send a GET request. How can i do that? At the moment i'm doing class OauthHandler(webapp.RequestHandler): def post(self): # blablablab request.redirect(oauth_uri) Which is wrong since the oauth_uri is only responding to GET. Further more, OAuth will redirect back to my redirect handler through GET, but i cant! i can only do post. So i'm confused. ideas? Thanks in advance

    Read the article

  • Techniques to avoid DeadlineExceededException in GAE/J?

    - by Tahir Akram
    I am developing an Twitter4J web application in Google App Engine/Java. I need to show two lists. One is Twitter friends and other is followers. With photo and screen name. It is working fine for people who have 20-30 followers and friends. But it gave me DeadlineExceededException when I try a user who has 150+ followers and friends. GAE throws this exception if web request take time more than 30 seconds. So what techniques I can adopt to avoid this exception. Should I generate two AJAX calls for each of my list. After page loads. So that every call will have its own 30 secs limit? Or what else you think? I am gone make it. Please help.

    Read the article

  • Design for tagging system in GAE-J

    - by tempy
    I need a simple tagging system in GAE-J. As I see it, the entity that is being tagged should have a collection of keys referring to the tags with which it's associated. A tag entity should simply contain the tag string itself, and a collection of keys pointing to the entities associated with the tag. When an entity's list of tags is altered, the system will create a new tag if the tag is unknown, and then append the entity's key to that tag's key collection. If the tag already exists, then the entity's key is simply appended to the tag's key collection. This seems relatively straight-forward and uncontroversial to me, but I would like some feedback on this design, just to be sure.

    Read the article

  • Timeout with GAE Java

    - by user242153
    Hi, I am having some issues with an app I have deployed on GAE. Specifically, I am intermittently running into the DeadlineExceededException where the server is not responding within the 30 seconds required. What is odd is that the code is not overly complex, it should run in milliseconds. My guess is that the delay is in dealing with the persistence manager and accessing the datastore. 2 questions: 1) What is the best way to track where all of the CPU time on the server is being used up? Log files do not seem helpful and to make things more complicated the code runs very fast when I am running it locally 2) Any tips / best practices in dealing with the 30 second exception? What are the biggest drivers of this? Datastore? HTTP requests / responses? Thanks

    Read the article

  • JQuery cookie access has stopped working for GAE app

    - by Greg
    I have a google app engine app that has been running for some time, and some javascript code that checks for a login cookie has suddenly stopped working. As far as I can tell, NO code has changed. The relevant code uses the jquery cookies plugin (jquery.cookies.2.2.0.min.js)... // control the default screen depending // if someone is logged in if( $.cookies.get('dev_appserver_login') != null || $.cookies.get('ACSID') != null ) { alert("valid cookie!") $("#inventory-container").show(); } else { alert("INvalid cookie!") $("#welcome-container").show(); } The reason for the two checks is that in the GAE SDK, the cookies are named differently. The production system uses 'ACSID'. This if statement works in the SDK and now fails 100% of the time in production. I have verified that the cookie is, in fact, present when I inspect the page. Thoughts?

    Read the article

  • Exposing a "dumbed-down", read-only instance of a Model in GAE

    - by Blixt
    Does anyone know a clever way, in Google App Engine, to return a wrapped Model instance that only exposes a few of the original properties, and does not allow saving the instance back to the datastore? I'm not looking for ways of actually enforcing these rules, obviously it'll still be possible to change the instance by digging through its __dict__ etc. I just want a way to avoid accidental exposure/changing of data. My initial thought was to do this (I want to do this for a public version of a User model): class ReadOnlyUser(db.Model): display_name = db.StringProperty() @classmethod def kind(cls): return 'User' def put(self): raise SomeError() Unfortunately, GAE maps the kind to a class early on, so if I do ReadOnlyUser.get_by_id(1) I will actually get a User instance back, not a ReadOnlyUser instance.

    Read the article

  • PHP app.yaml, new to GAE, not sure of how to setup

    - by chetweewax
    I have a single page website built on bootstrap 3, that I am trying to move to Google Apps Engine. I Scaffold my sites using php, and all the content is showing but not the styles and javascript. My site is basically set up as follows _/js/bootstrap.js _/js/custom.js _/fonts/glypicon ...etc _/css/bootstrap.css _/css/custom.css _/php/ .. all my php files go here ... index.php can someone help me setup my app.yaml for this? I am new to GAE, and am a little confused by this.

    Read the article

  • Timeout loading application on GAE using web2py

    - by Charles P.
    I am uploading an app to GAE. Through some experimentation I've found that if I don't include wsgihandler.py, the app loads very slowly. It feels like it's looking for this file and them timing out. Besides the slow loading, everything works perfectly without wsgihandler.py, so I want to know if there is a simple way to remove the references to the file. I tried poking around the files, but it doesn't look like there are direct references. Also, I asked before what I need at a minimum to get an application to work, and I found that I need: web2py/app.yaml web2py/gaehandler.py web2py/VERSION web2py/gluon/* (and subfolders, this is web2py) web2py/applications/theoneappyouwanttodeploy/* (and subfolders)

    Read the article

  • Making Spring Data JPA work with DataNucleus (GAE) (Spring Boot)

    - by xybrek
    There are several hints that Spring Data works with Google App Engine like: http://tommysiu.blogspot.com/2014/01/spring-data-on-gae-part-1.html http://blog.eisele.net/2009/07/spring-300m3-on-google-appengine-with.html Much of the examples are not "Spring Boot" so I've been trying to retrofit things with it. However, I've been stuck with this error for days and days: [INFO] Caused by: java.lang.NullPointerException [INFO] at org.datanucleus.api.jpa.metamodel.SingularAttributeImpl.isVersion(SingularAttributeImpl.java:79) [INFO] at org.springframework.data.jpa.repository.support.JpaMetamodelEntityInformation.findVersionAttribute(JpaMetamodelEntityInformation.java:102) [INFO] at org.springframework.data.jpa.repository.support.JpaMetamodelEntityInformation.<init>(JpaMetamodelEntityInformation.java:79) [INFO] at org.springframework.data.jpa.repository.support.JpaEntityInformationSupport.getMetadata(JpaEntityInformationSupport.java:65) [INFO] at org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getEntityInformation(JpaRepositoryFactory.java:149) [INFO] at org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getTargetRepository(JpaRepositoryFactory.java:88) [INFO] at org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getTargetRepository(JpaRepositoryFactory.java:68) [INFO] at org.springframework.data.repository.core.support.RepositoryFactorySupport.getRepository(RepositoryFactorySupport.java:158) [INFO] at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.initAndReturn(RepositoryFactoryBeanSupport.java:224) [INFO] at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.afterPropertiesSet(RepositoryFactoryBeanSupport.java:210) [INFO] at org.springframework.data.jpa.repository.support.JpaRepositoryFactoryBean.afterPropertiesSet(JpaRepositoryFactoryBean.java:92) [INFO] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$6.run(AbstractAutowireCapableBeanFactory.java:1602) [INFO] at java.security.AccessController.doPrivileged(Native Method) [INFO] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1599) [INFO] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1549) [INFO] ... 40 more Where, I'm trying to use Spring Data JPA with DataNucleus/AppEngine: @Configuration @ComponentScan @EnableJpaRepositories @EnableTransactionManagement class JpaApplicationConfig { private static final Logger logger = Logger .getLogger(JpaApplicationConfig.class.getName()); @Bean public EntityManagerFactory entityManagerFactory() { logger.info("Loading Entity Manager..."); return Persistence .createEntityManagerFactory("transactions-optional"); } @Bean public PlatformTransactionManager transactionManager() { logger.info("Loading Transaction Manager..."); final JpaTransactionManager txManager = new JpaTransactionManager(); txManager.setEntityManagerFactory(entityManagerFactory()); return txManager; } } I've tested Persistence.createEntityManagerFactory("transactions-optional"); to see if the app can persist using this EMF, well, it does, so I am sure that this EMF works fine. The problem is the "wiring" up with the Spring Data JPA, can anybody help?

    Read the article

  • Spring security with GAE

    - by xybrek
    I'm trying to implement Spring security for my GAE application however I'm getting this error: No bean named 'springSecurityFilterChain' is defined I added this configuration on my application web.xml: <filter> <filter-name>springSecurityFilterChain</filter-name> <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class> </filter> <filter-mapping> <filter-name>springSecurityFilterChain</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> And in the servlet-context: <!-- Configure security --> <security:http auto-config="true"> <security:intercept-url pattern="/**" access="ROLE_USER" /> </security:http> <security:authentication-manager alias="authenticationManager"> <security:authentication-provider> <security:user-service> <security:user name="jimi" password="jimi" authorities="ROLE_USER, ROLE_ADMIN" /> <security:user name="bob" password="bob" authorities="ROLE_USER" /> </security:user-service> </security:authentication-provider> </security:authentication-manager> What could be causing the error?

    Read the article

  • Eclipse+PyDev+GAE memcache error

    - by bocco
    I've started using Eclipe+PyDev as an environment for developing my first app for Google App Engine. Eclipse is configured according to this tutorial. Everything was working until I start to use memcache. PyDev reports the errors and I don't know how to fix it: Error: Undefined variable from import: get How to fix this? Sure, it is only PyDev checker problem. Code is correct and run on GAE. UPDATE: I'm using PyDev 1.5.0 but experienced the same with 1.4.8. My PYTHONPATH includes (set in Project Properties/PyDev - PYTHONPATH): C:\Program Files\Google\google_appengine C:\Program Files\Google\google_appengine\lib\django C:\Program Files\Google\google_appengine\lib\webob C:\Program Files\Google\google_appengine\lib\yaml\lib UPDATE 2: I took a look at C:\Program Files\Google\google_appengine\google\appengine\api\memcache\__init__.py and found get() is not declared as memcache module function. They use the following trick to do that (I didn't hear about such possibility): _CLIENT = None def setup_client(client_obj): """Sets the Client object instance to use for all module-level methods. Use this method if you want to have customer persistent_id() or persistent_load() functions associated with your client. Args: client_obj: Instance of the memcache.Client object. """ global _CLIENT var_dict = globals() _CLIENT = client_obj var_dict['set_servers'] = _CLIENT.set_servers var_dict['disconnect_all'] = _CLIENT.disconnect_all var_dict['forget_dead_hosts'] = _CLIENT.forget_dead_hosts var_dict['debuglog'] = _CLIENT.debuglog var_dict['get'] = _CLIENT.get var_dict['get_multi'] = _CLIENT.get_multi var_dict['set'] = _CLIENT.set var_dict['set_multi'] = _CLIENT.set_multi var_dict['add'] = _CLIENT.add var_dict['add_multi'] = _CLIENT.add_multi var_dict['replace'] = _CLIENT.replace var_dict['replace_multi'] = _CLIENT.replace_multi var_dict['delete'] = _CLIENT.delete var_dict['delete_multi'] = _CLIENT.delete_multi var_dict['incr'] = _CLIENT.incr var_dict['decr'] = _CLIENT.decr var_dict['flush_all'] = _CLIENT.flush_all var_dict['get_stats'] = _CLIENT.get_stats setup_client(Client()) Hmm... Any idea how to force PyDev to recognize that?

    Read the article

  • Unable to persist objects in GAE JDO

    - by Basil Dsouza
    Hello Guys, I am completely fresh to both JDO and GAE, and have been struggling to get my data layer to persist any code at all! The issues I am facing may be very simple, but I just cant seem to find any a way no matter what solution I try. Firstly the problem: (Slightly simplified, but still contains all the info necessary) My data model is as such: User: (primary key) String emailID String firstName Car: (primary key) User user (primary key) String registration String model This was the initial datamodel. I implemented a CarPK object to get a composite primary key of the User and the registration. However that ran into a variety of issues. (Which i will save for another time/question) I then changed the design as such: User: (Unchanged) Car: (primary key) String fauxPK (here fauxPK = user.getEmailID() + SEP + registration) User user String registration String model This works fine for the user, and it can insert and retrieve user objects. However when i try to insert a Car Object, i get the following error: "Cannot have a java.lang.String primary key and be a child object" Found the following helpful link about it: http://stackoverflow.com/questions/2063467/persist-list-of-objects Went to the link suggested there, that explains how to create Keys, however they keep talking about "Entity Groups" and "Entity Group Parents". But I cant seem to find any articles or sites that explain what are "Entity Group"s or an "Entity Group Parents" I could try fiddling around some more to figure out if i can store an object somehow, But I am running sort on patience and also would rather understand and implement than vice versa. So i would appreciate any docs (even if its huge) that covers all these points, and preferably has some examples that go beyond the very basic data modeling. And thanks for reading such a long post :)

    Read the article

  • "Detecting" and loading of "plugins" in GAE

    - by Patrick Cornelissen
    Hi! I have a "plugin like" architecture and I want to create one instance of each class that implements a dedicated interface and put these in a cache. (To have a singleton-ish effect). The plugins will be provided as jars and put into the app engine war file before the app is uploaded. I have tried to use the ClassPathScanningCandidateComponentProvider as I'm using spring anyway, but this didn't work. The provider complained that it was not able to find the HttpServletResponse class file while scanning the classpath. I can't get around this, when I add the servlet jar, then I'll get of course problems, because the same jar is also provided by the GAE. If I don't, I'm getting the error above... So I tried to add a static initialization code, but of course this doesn't work, because the class is initialized when it's instantiated for the first time. (Well I knew that but it was worth a try) The last chance I currently see is that I create a properties file with all plugin classes when the package is created, but this requires writing of a maven plugin etc. and I'd like to avoid that. Is there something that I am missing?

    Read the article

  • Problem with GwtUpload on GAE

    - by weesilmania
    I'm using GwtUpload to upload images on GAE. The problem is that the images seem to get much bigger when I move them into a blob. I've noticed the same for simple text fields and in that case I've realised that some weirdo characters are being appended to the end of the field values (encoding right?). Can anyone help? public class ImageUploadServlet extends AppEngineUploadAction { /** * Maintain a list with received files and their content types */ Hashtable<String, File> receivedFiles = new Hashtable<String, File>(); Hashtable<String, String> receivedContentTypes = new Hashtable<String, String>(); private Objectify objfy; public ImageUploadServlet() { ObjectifyService.register(Thumbnail.class); objfy = ObjectifyService.begin(); System.out.println("ImageUploadServlet init"); } /** * Override executeAction to save the received files in a custom place and * delete this items from session. */ @Override public String executeAction(HttpServletRequest request, List<FileItem> sessionFiles) throws UploadActionException { Thumbnail t = new Thumbnail(); for (FileItem item : sessionFiles) { //CacheableFileItem item = (CacheableFileItem)fItem; if (false == item.isFormField()) { System.out.println("the name 1st:" + item.getFieldName()); try { // You can also specify the temporary folder InputStream imgStream = item.getInputStream(); Blob imageBlob = new Blob(IOUtils.toByteArray(imgStream)); t.setMainImage(imageBlob); System.out.println("blob: " + t.getMainImage()); } catch (Exception e) { throw new UploadActionException(e.getMessage()); } } else { System.out.println("the name 2nd:" + item.getFieldName()); String name = item.getFieldName(); String value; try { InputStream is = item.getInputStream(); StringWriter writer = new StringWriter(); IOUtils.copy(is, writer,"UTF-8"); value = writer.toString(); writer.close(); System.out.println("parm name: " + name); System.out.println("parm value: " + value + " **" + value.length()); System.out.println(item.getContentType()); if (name.equals("thumb-name")) { t.setName(value); } } catch (IOException e) { // TODO Auto-generated catch block System.out.println("Error"); e.printStackTrace(); } } removeSessionFileItems(request); } objfy.put(t); return null; } As an example the size of the image is 20kb, and the lib has some debugging that confirms that this is the case when it's uploading the file but the blob ends up being over 1 MB. Wes

    Read the article

  • Reusing OAuth request token when user refresh page - Twitter4j on GAE

    - by Tahir Akram
    Hi I am using Twitter4J API on GAE/J. I want to use the request token when user came to my page. (called back URL). And press refresh button. I write following code for that. But When user press refresh button. I got Authentication credentials error. Please see the stacktrance. It works fine when user first time used that token. HomeServlet.java code: HttpSession session = request.getSession(); twitter.setOAuthConsumer(FFConstants.CONSUMER_KEY, FFConstants.CONSUMER_SECRET); String token = (String) session.getAttribute("token"); String authorizedToken = (String)session.getAttribute("authorizedToken"); User user = null; if (!token.equals(authorizedToken)){ AccessToken accessToken = twitter.getOAuthAccessToken( token, (String) session .getAttribute("tokenSecret")); twitter.setOAuthAccessToken(accessToken); user = twitter.verifyCredentials(); session.setAttribute("authorizedToken", token); session.setAttribute("user", user); }else{ user = (User)session.getAttribute("user"); } TwitterUser twitterUser = new TwitterUser(); twitterUser.setFollowersCount(user.getFollowersCount()); twitterUser.setFriendsCount(user.getFriendsCount()); twitterUser.setFullName(user.getName()); twitterUser.setScreenName(user.getScreenName()); twitterUser.setLocation(user.getLocation()); Please suggest how I can do that. I have seen on many website. They retain the user with the same token. Even if user press browser refresh buttion again and again. Please help. Exception stacktrace: Reason: twitter4j.TwitterException: 401:Authentication credentials were missing or incorrect. /friends/ids.xml This method requires authentication. at twitter4j.http.HttpClient.httpRequest(HttpClient.java:469) at twitter4j.http.HttpClient.get(HttpClient.java:412) at twitter4j.Twitter.get(Twitter.java:276) at twitter4j.Twitter.get(Twitter.java:228) at twitter4j.Twitter.getFriendsIDs(Twitter.java:1819) at com.tff.servlet.HomeServlet.doGet(HomeServlet.java:86) at javax.servlet.http.HttpServlet.service(HttpServlet.java:693) at javax.servlet.http.HttpServlet.service(HttpServlet.java:806) at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487) at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1093) at com.google.apphosting.utils.servlet.ParseBlobUploadFilter.doFilter(ParseBlobUploadFilter.java:97) at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084) at com.google.apphosting.runtime.jetty.SaveSessionFilter.doFilter(SaveSessionFilter.java:35) at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084) at com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(TransactionCleanupFilter.java:43) at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084) at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:360) at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216) at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181) at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:712) at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405) at com.google.apphosting.runtime.jetty.AppVersionHandlerMap.handle(AppVersionHandlerMap.java:238) at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:139) at org.mortbay.jetty.Server.handle(Server.java:313) at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:506) at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:830) at com.google.apphosting.runtime.jetty.RpcRequestParser.parseAvailable(RpcRequestParser.java:76) at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:381) at com.google.apphosting.runtime.jetty.JettyServletEngineAdapter.serviceRequest(JettyServletEngineAdapter.java:135) at com.google.apphosting.runtime.JavaRuntime.handleRequest(JavaRuntime.java:235) at com.google.apphosting.base.RuntimePb$EvaluationRuntime$6.handleBlockingRequest(RuntimePb.java:5235) at com.google.apphosting.base.RuntimePb$EvaluationRuntime$6.handleBlockingRequest(RuntimePb.java:5233) at com.google.net.rpc.impl.BlockingApplicationHandler.handleRequest(BlockingApplicationHandler.java:24) at com.google.net.rpc.impl.RpcUtil.runRpcInApplication(RpcUtil.java:363) at com.google.net.rpc.impl.Server$2.run(Server.java:838) at com.google.tracing.LocalTraceSpanRunnable.run(LocalTraceSpanRunnable.java:56) at com.google.tracing.LocalTraceSpanBuilder.internalContinueSpan(LocalTraceSpanBuilder.java:536) at com.google.net.rpc.impl.Server.startRpc(Server.java:793) at com.google.net.rpc.impl.Server.processRequest(Server.java:368) at com.google.net.rpc.impl.ServerConnection.messageReceived(ServerConnection.java:448) at com.google.net.rpc.impl.RpcConnection.parseMessages(RpcConnection.java:319) at com.google.net.rpc.impl.RpcConnection.dataReceived(RpcConnection.java:290) at com.google.net.async.Connection.handleReadEvent(Connection.java:466) at com.google.net.async.EventDispatcher.processNetworkEvents(EventDispatcher.java:759) at com.google.net.async.EventDispatcher.internalLoop(EventDispatcher.java:205) at com.google.net.async.EventDispatcher.loop(EventDispatcher.java:101) at com.google.net.rpc.RpcService.runUntilServerShutdown(RpcService.java:251) at com.google.apphosting.runtime.JavaRuntime$RpcRunnable.run(JavaRuntime.java:394) at java.lang.Thread.run(Unknown Source)

    Read the article

  • Problem detaching entire object graph in GAE-J with JDO

    - by tempy
    I am trying to load the full object graph for User, which contains a collection of decks, which then contains a collection of cards, as such: User: @PersistenceCapable(detachable = "true") @Inheritance(strategy = InheritanceStrategy.SUBCLASS_TABLE) @FetchGroup(name = "decks", members = { @Persistent(name = "_Decks") }) public abstract class User { @PrimaryKey @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY) protected Key _ID; @Persistent protected String _UniqueIdentifier; @Persistent(mappedBy = "_Owner") @Element(dependent = "true") protected Set<Deck> _Decks; protected User() { } } Each Deck has a collection of Cards, as such: @PersistenceCapable(detachable = "true") @FetchGroup(name = "cards", members = { @Persistent(name = "_Cards") }) public class Deck { @PrimaryKey @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY) private Key _ID; @Persistent String _Name; @Persistent(mappedBy = "_Parent") @Element(dependent = "true") private Set<Card> _Cards = new HashSet<Card>(); @Persistent private Set<String> _Tags = new HashSet<String>(); @Persistent private User _Owner; } And finally, each card: @PersistenceCapable public class Card { @PrimaryKey @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY) private Key _ID; @Persistent private Text _Question; @Persistent private Text _Answer; @Persistent private Deck _Parent; } I am trying to retrieve and then detach the entire object graph. I can see in the debugger that it loads fine, but then when I get to detaching, I can't make anything beyond the User object load. (No Decks, no Cards). At first I tried without a transaction to simply "touch" all the fields on the attached object before detaching, but that didn't help. Then I tried adding everything to the default fetch group, but that just generated warnings about GAE not supporting joins. I tried setting the fetch plan's max fetch depth to -1, but that didn't do it. Finally, I tried using FetchGroups as you can see above, and then retrieving with the following code: PersistenceManager pm = _pmf.getPersistenceManager(); pm.setDetachAllOnCommit(true); pm.getFetchPlan().setGroup("decks"); pm.getFetchPlan().setGroup("cards"); Transaction tx = pm.currentTransaction(); Query query = null; try { tx.begin(); query = pm.newQuery(GoogleAccountsUser.class); //Subclass of User query.setFilter("_UniqueIdentifier == TheUser"); query.declareParameters("String TheUser"); List<User> results = (List<User>)query.execute(ID); //ID = Supplied parameter //TODO: Test for more than one result and throw if(results.size() == 0) { tx.commit(); return null; } else { User usr = (User)results.get(0); //usr = pm.detachCopy(usr); tx.commit(); return usr; } } finally { query.closeAll(); if (tx.isActive()) { tx.rollback(); } pm.close(); } This also doesn't work, and I'm running out of ideas...

    Read the article

  • Committed JDO writes do not apply on local GAE HRD, or possibly reused transaction

    - by eeeeaaii
    I'm using JDO 2.3 on app engine. I was using the Master/Slave datastore for local testing and recently switched over to using the HRD datastore for local testing, and parts of my app are breaking (which is to be expected). One part of the app that's breaking is where it sends a lot of writes quickly - that is because of the 1-second limit thing, it's failing with a concurrent modification exception. Okay, so that's also to be expected, so I have the browser retry the writes again later when they fail (maybe not the best hack but I'm just trying to get it working quickly). But a weird thing is happening. Some of the writes which should be succeeding (the ones that DON'T get the concurrent modification exception) are also failing, even though the commit phase completes and the request returns my success code. I can see from the log that the retried requests are working okay, but these other requests that seem to have committed on the first try are, I guess, never "applied." But from what I read about the Apply phase, writing again to that same entity should force the apply... but it doesn't. Code follows. Some things to note: I am attempting to use automatic JDO caching. So this is where JDO uses memcache under the covers. This doesn't actually work unless you wrap everything in a transaction. all the requests are doing is reading a string out of an entity, modifying part of the string, and saving that string back to the entity. If these requests weren't in transactions, you'd of course have the "dirty read" problem. But with transactions, isolation is supposed to be at the level of "serializable" so I don't see what's happening here. the entity being modified is a root entity (not in a group) I have cross-group transactions enabled Another weird thing is happening. If the concurrent modification thing happens, and I subsequently edit more than 5 more entities (this is the max for cross-group transactions), then nothing happens right away, but when I stop and restart the server I get "IllegalArgumentException: operating on too many entity groups in a single transaction". Could it be possible that the PMF is returning the same PersistenceManager every time, or the PM is reusing the same transaction every time? I don't see how I could possibly get the above error otherwise. The code inside the transaction just edits one root entity. I can't think of any other way that GAE would give me the "too many entity groups" error. The relevant code (this is a simplified version) PersistenceManager pm = PMF.getManager(); Transaction tx = pm.currentTransaction(); String responsetext = ""; try { tx.begin(); // I have extra calls to "makePersistent" because I found that relying // on pm.close didn't always write the objects to cache, maybe that // was only a DataNucleus 1.x issue though Key userkey = obtainUserKeyFromCookie(); User u = pm.getObjectById(User.class, userkey); pm.makePersistent(u); // to make sure it gets cached for next time Key mapkey = obtainMapKeyFromQueryString(); // this is NOT a java.util.Map, just FYI Map currentmap = pm.getObjectById(Map.class, mapkey); Text mapData = currentmap.getMapData(); // mapData is JSON stored in the entity Text newMapData = parseModifyAndReturn(mapData); // transform the map currentmap.setMapData(newMapData); // mutate the Map object pm.makePersistent(currentmap); // make sure to persist so there is a cache hit tx.commit(); responsetext = "OK"; } catch (JDOCanRetryException jdoe) { // log jdoe responsetext = "RETRY"; } catch (Exception e) { // log e responsetext = "ERROR"; } finally { if (tx.isActive()) { tx.rollback(); } pm.close(); } resp.getWriter().println(responsetext); EDIT: so I have verified that it fails after exactly 5 transactions. Here's what I do: I create a Foo (root entity), do a bunch of concurrent operations on that Foo, and some fail and get retried, and some commit but don't apply (as described above). Then, I start creating more Foos, and do a few operations on those new Foos. If I only create four Foos, stopping and restarting app engine does NOT give me the IllegalArgumentException. However if I create five Foos (which is the limit for cross-group transactions), then when I stop and restart app engine, I do get the exception. So it seems that somehow these new Foos I am creating are counting toward the limit of 5 max entities per transaction, even though they are supposed to be handled by separate transactions. It's as if a transaction is still open and is being reused by the servlet when it handles the new requests for the 2nd through 5th Foos. EDIT2: it looks like the IllegalArgument thing is independent of the other bug. In other words, it always happens when I create five Foos, even if I don't get the concurrent modification exception. I don't know if it's a symptom of the same problem or if it's unrelated. EDIT3: I found out what was causing the (unrelated) IllegalArgumentException, it was a dumb mistake on my part. But the other issue is still happening. EDIT4: added pseudocode for the datastore access EDIT5: I am pretty sure I know why this is happening, but I will still award the bounty to anyone who can confirm it. Basically, I think the problem is that transactions are not really implemented in the local version of the datastore. References: https://groups.google.com/forum/?fromgroups=#!topic/google-appengine-java/gVMS1dFSpcU https://groups.google.com/forum/?fromgroups=#!topic/google-appengine-java/deGasFdIO-M https://groups.google.com/forum/?hl=en&fromgroups=#!msg/google-appengine-java/4YuNb6TVD6I/gSttMmHYwo0J Because transactions are not implemented, rollback is essentially a no-op. Therefore, I get a dirty read when two transactions try to modify the record at the same time. In other words, A reads the data and B reads the data at the same time. A attempts to modify the data, and B attempts to modify a different part of the data. A writes to the datastore, then B writes, obliterating A's changes. Then B is "rolled back" by app engine, but since rollbacks are a no-op when running on the local datastore, B's changes stay, and A's do not. Meanwhile, since B is the thread that threw the exception, the client retries B, but does not retry A (since A was supposedly the transaction that succeeded).

    Read the article

  • App engine datastore - query on Enum fields.

    - by Gopi
    I am using GAE(Java) with JDO for persistence. I have an entity with a Enum field which is marked as @Persistent and gets saved correctly into the datastore (As observed from the Datastore viewer in Development Console). But when I query these entities putting a filter based on the Enum value, it is always returning me all the entities whatever value I specify for the enum field. I know GAE java supports enums being persisted just like basic datatypes. But does it also allow retrieving/querying based on them? Google search could not point me to any such example code. Details: I have printed the Query just before being executed. So in two cases the query looks like - SELECT FROM com.xxx.yyy.User WHERE role == super ORDER BY key desc RANGE 0,50 SELECT FROM com.xxx.yyy.User WHERE role == admin ORDER BY key desc RANGE 0,50 Both above queries return me all the User entities from datastore in spite of datastore viewer showing some Users are of type 'admin' and some are of type 'super'.

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >