문제

I am using maven for building google appengine application. After the devserver starts when the application accessed by the client on the first request the application us redeployed and ServletListener is re-executed. In this process the servlet context is lost. I am using servlet context to store the list of clients connected. Now because the app was redeployed automatically ans servlet context is cleared I loose the information that the 1st client was connected. The servlet context does store all subsequent clients connected until the dev server is stopped.

The reason looks like some class file is change, which should not once the devserver is running.

Jun 25, 2013 6:31:31 AM com.google.appengine.tools.development.JettyContainerService$2 filesChanged [INFO] INFO: A file has changed, reloading the web application.

Following is the complete log

[INFO] 
[INFO] --- maven-war-plugin:2.1.1:war (default-war) @ NoteWebApp ---
[INFO] Packaging webapp
[INFO] Assembling webapp [NoteWebApp] in [/Users/saghosh/dev/NoteWebApp/target/NoteWebApp]
[INFO] Processing war project
[INFO] Copying webapp resources [/Users/saghosh/dev/NoteWebApp/src/main/webapp]
[INFO] Webapp assembled in [140 msecs]
[INFO] Building war: /Users/saghosh/dev/NoteWebApp/target/NoteWebApp.war
[INFO] WEB-INF/web.xml already added, skipping
[INFO] 
[INFO] <<< appengine-maven-plugin:1.8.1:devserver (default-cli) @ NoteWebApp <<<
[INFO] 
[INFO] --- appengine-maven-plugin:1.8.1:devserver (default-cli) @ NoteWebApp ---
[INFO] 
[INFO] Google App Engine Java SDK - Running Development Server
[INFO] 
[INFO] Retrieving Google App Engine Java SDK from Maven
[INFO] Running /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/bin/java -XstartOnFirstThread -javaagent:/Users/saghosh/.m2/repository/com/google/appengine/appengine-java-sdk/1.8.1/appengine-java-sdk/appengine-java-sdk-1.8.1/lib/agent/appengine-agent.jar -Xbootclasspath/p:/Users/saghosh/.m2/repository/com/google/appengine/appengine-java-sdk/1.8.1/appengine-java-sdk/appengine-java-sdk-1.8.1/lib/override/appengine-dev-jdk-overrides.jar -Dappengine.fullscan.seconds=5 -classpath /Users/saghosh/.m2/repository/com/google/appengine/appengine-java-sdk/1.8.1/appengine-java-sdk/appengine-java-sdk-1.8.1/lib/appengine-tools-api.jar com.google.appengine.tools.development.DevAppServerMain --allow_remote_shutdown /Users/saghosh/dev/NoteWebApp/target/NoteWebApp
[INFO] 2013-06-25 12:01:16.813 java[15483:407] [Java CocoaComponent compatibility mode]: Enabled
[INFO] 2013-06-25 12:01:16.814 java[15483:407] [Java CocoaComponent compatibility mode]: Setting timeout for SWT to 0.100000
[INFO] Jun 25, 2013 12:01:18 PM com.google.apphosting.utils.config.AppEngineWebXmlReader readAppEngineWebXml
[INFO] INFO: Successfully processed /Users/saghosh/dev/NoteWebApp/target/NoteWebApp/WEB-INF/appengine-web.xml
[INFO] 2013-06-25 12:01:18.717:INFO::Logging to STDERR via org.mortbay.log.StdErrLog
[INFO] Jun 25, 2013 12:01:18 PM com.google.apphosting.utils.config.AbstractConfigXmlReader readConfigXml
[INFO] INFO: Successfully processed /Users/saghosh/dev/NoteWebApp/target/NoteWebApp/WEB-INF/web.xml
[INFO] 2013-06-25 12:01:18.978:INFO::jetty-6.1.x
[INFO] ****** Scan complete ******
[INFO] 2013-06-25 12:01:21.081:INFO::Started SelectChannelConnector@127.0.0.1:8080
[INFO] Jun 25, 2013 6:31:21 AM com.google.appengine.tools.development.JettyContainerService startHotDeployScanner
[INFO] INFO: Full scan of the web app in place every 5s.
[INFO] Jun 25, 2013 6:31:21 AM com.google.appengine.tools.development.AbstractServer startup
[INFO] INFO: Server default is running at http://localhost:8080/
[INFO] Jun 25, 2013 6:31:21 AM com.google.appengine.tools.development.AbstractServer startup
[INFO] INFO: The admin console is running at http://localhost:8080/_ah/admin
[INFO] Jun 25, 2013 6:31:21 AM com.google.appengine.tools.development.DevAppServerImpl start
[INFO] INFO: Dev App Server is now running
[INFO] Jun 25, 2013 6:31:27 AM com.google.appengine.api.datastore.dev.LocalDatastoreService init
[INFO] INFO: Local Datastore initialized: 
[INFO]  Type: Master/Slave
[INFO]  Storage: /Users/saghosh/dev/NoteWebApp/target/NoteWebApp/WEB-INF/appengine-generated/local_db.bin
[INFO] Jun 25, 2013 6:31:27 AM com.google.appengine.api.datastore.dev.LocalDatastoreService load
[INFO] INFO: The backing store, /Users/saghosh/dev/NoteWebApp/target/NoteWebApp/WEB-INF/appengine-generated/local_db.bin, does not exist. It will be created.
[INFO] Client trying to connect with ID 0354c90b-46cd-46d2-81d1-b57cd311a7a2Initialising client list
[INFO]  New client connected with ID  0354c90b-46cd-46d2-81d1-b57cd311a7a2
[INFO] Jun 25, 2013 6:31:31 AM com.google.appengine.tools.development.JettyContainerService$2 filesChanged
[INFO] INFO: A file has changed, reloading the web application.
[INFO] Jun 25, 2013 6:31:31 AM com.google.apphosting.utils.config.AppEngineWebXmlReader readAppEngineWebXml
[INFO] INFO: Successfully processed /Users/saghosh/dev/NoteWebApp/target/NoteWebApp/WEB-INF/appengine-web.xml
[INFO] Jun 25, 2013 6:31:31 AM com.google.apphosting.utils.config.AbstractConfigXmlReader readConfigXml
[INFO] INFO: Successfully processed /Users/saghosh/dev/NoteWebApp/target/NoteWebApp/WEB-INF/web.xml
[INFO] ****** Scan complete ******

Following is the servlet context listener

public class MyGuiceServletConfig extends GuiceServletContextListener {

@Override
protected Injector getInjector() {
    return Guice.createInjector(
            //Keep sending Guice the modules
            new SitebricksModule() {
                @Override
                protected void configureSitebricks() {
                    scan(NotebookService.class.getPackage());
                    //Should change this to logger, this is just to proove that
                    //sitebrick scans the classes for annotations like @At etc.
                    System.out.println("****** Scan complete ******");
                }
            }
            , new ServletModule() {
                @Override
                protected void configureServlets() {
                    //Servlet classes have to be singleton to be consistent with servlet specification
                    //In tranditional cases web.xml config tell the container to do so I guess.
                    bind(com.neil.NotebookServlet.class).in(Singleton.class);
                    //Analogous to typcial servlet URL mappings
                    serve("/servlet").with(com.neil.NotebookServlet.class);

                    bind(com.neil.TrackerServlet.class).in(Singleton.class);
                    serve("/_ah/channel/connected/").with(com.neil.TrackerServlet.class);

                    bind(com.neil.TrackerServlet1.class).in(Singleton.class);
                    serve("/_ah/channel/disconnected/").with(com.neil.TrackerServlet1.class);

                }
            }
    );
}
}
도움이 되었습니까?

해결책

After some Googling I found that this happens because of the local database file is created on the 1st request and target dir is scanned for changes, leading to app reload.

Found couple of workarrounds

  1. Change the db directory to outside target dir. But if anything else changes , it will again reload.

    -Dappengine.generated.dir=/tmp/blabla

2.Disable the auto scan, but as a developer you would want this to avoid stop and start server again everytime you change code.

<jvmFlags>
    <jvmFlag>-Dappengine.fullscan.seconds=-1</jvmFlag>
</jvmFlags>

I am still open to a permanent solution till google fixes this

Source

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top