com.google.appengine.api.search.PutException: Error constructing stub for app s~hanji-bd63d

31 views
Skip to first unread message

Akash Eldo

unread,
Jan 20, 2019, 2:45:43 PM1/20/19
to Google App Engine
Hello,

I'm using the App Engine Search API to perform full text search on my Firestore database. I'm getting the following error when putting documents into the Search index:
com.google.appengine.api.search.PutException: Error constructing stub for app s~hanji-bd63d

I'm using a ServletContextListener that connects to my database and adds Documents in the index when the instance is being initialized. Here is the code that puts a Document in the index.
private void indexADocument(String indexName, Document document) throws InterruptedException {
        IndexSpec indexSpec = IndexSpec.newBuilder().setName(indexName).build();
        Index index = SearchServiceFactory.getSearchService().getIndex(indexSpec);

        final int maxRetry = 3;
        int attempts = 0;
        int delay = 2;
        while (true) {
            try {
                index.put(document);

                // Getting id
                String id = null;
                for(Field  f: document.getFields("id")){
                    id = f.getText();
                }
                db.markDocAsIndexed(id);

            } catch (PutException e) {
                if (StatusCode.TRANSIENT_ERROR.equals(e.getOperationResult().getCode())
                        && ++attempts < maxRetry) { // retrying
                    Thread.sleep(delay * 1000);
                    delay *= 2; // easy exponential backoff
                    continue;
                } else {
                    throw e; // otherwise throw
                }
            }
            break;
        }
    }

This is only a recent problem, I've already added thousands of documents to my search index using this method and have had no problems, so I'm not sure what could be causing this.

George (Cloud Platform Support)

unread,
Jan 21, 2019, 11:27:47 AM1/21/19
to Google App Engine
Hello Akash, 

What version of Java are you using? Version 7 is not supported any more. 

Did you change anything in the environment that calls your indexADocument() method? What is your code that runs when your instance gets initialized? 

This discussion group is oriented more towards general opinions, trends, and issues of general nature touching the app engine. For coding and programming architecture, as well as searching indexes, you may be better served in dedicated forums such as stackoverflow, where experienced programmers are within reach and ready to help. 

Akash Eldo

unread,
Jan 21, 2019, 11:35:59 AM1/21/19
to Google App Engine
Hi George, 

I'm using Java 8, in my appengine-web.xml I have runtime set to java8. I haven't changed anything in my app engine setup since I first set it up.

I figured it'd be more readable on github than if I pasted it in here. The Exception occurs at line 73, where the call to 'put' is made.

George (Cloud Platform Support)

unread,
Jan 21, 2019, 3:24:27 PM1/21/19
to Google App Engine
Hi Akash, 

This type of errors are to be preferably reported in the Public Issue Tracker. I have gone ahead and opened an issue with similar content. You may follow developments in this thread.
Reply all
Reply to author
Forward
0 new messages