Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Deploying SmartGWT in a Standalone App

    I have a JAR application from which I launch an embedded Jetty server that deploys a WAR file. The WAR file is zipped and lives in the JAR file. When running the app, I get the following error:

    Code:
    Exception when loading from __USE_CONTAINER__/proxy/sc/system/schema/builtinTypes.xml:
    java.io.IOException: Configured for containerIO, but servletContext not available!  You need to install the Init servlet
            at com.isomorphic.io.ISCFile.<init>(ISCFile.java:139)
            at com.isomorphic.store.ProcessedFileCache.getObjectFromFile(ProcessedFileCache.java:138)
            at com.isomorphic.xml.XML.getXMLDocument(XML.java:255)
            at com.isomorphic.xml.XML.toDSRecords(XML.java:263)
            at com.isomorphic.xml.XML.toDSRecords(XML.java:266)
            at com.isomorphic.datasource.DataSource.<clinit>(DataSource.java:555)
            at my.app.StartupServlet.init(StartupServlet.java:23)
    Line 23 of StartupServlet:
    Code:
    22 MyDSGenerator datasourceGenerator = new MyDSGenerator();
    23 DataSource.addDynamicDSGenerator(datasourceGenerator);
    I've been reading around a bit on the forums and the following doc: http://www.smartclient.com/smartgwtee-latest/javadoc/com/smartgwt/client/docs/StandaloneDataSourceUsage.html

    The suggestion for standalone apps seem to be to provide the path to the war directory of the project. In this context, it would be unrealistic to have the webRoot be an absolute path. Is there a way to make this configuration work?

    #2
    If the .war file is being deployed to Jetty, then this wouldn't be considered "standalone" usage (which means running without a servlet container).

    Instead, this appears to be just an issue where the Init servlet has not been installed in web.xml, or if that's impossible for some reason in this scenario, com.isomorphic.servlet.Init.go() has not been manually called.

    Comment


      #3
      Ah. Thanks for the clarification. Wasn't sure which category it fit in.


      In any case, I do have the StartupServlet in my web.xml:

      Code:
      	<servlet>
      		<servlet-name>Init</servlet-name>
      		<servlet-class>my.app.StartupServlet</servlet-class>
      		<load-on-startup>1</load-on-startup>
      	</servlet>
      Given the stack trace, it seems to be called.

      StartupServlet:
      Code:
      public class StartupServlet extends Init {
      	@Override
      	public void init() throws ServletException {
      		try {
      			MyDSGenerator datasourceGenerator = new MyDSGenerator(datasetFileName);
      			DataSource.addDynamicDSGenerator(datasourceGenerator);
      			super.init();
      		} catch (Exception e) {
      			throw new ServletException("Faied to initiliaze: could net generate datasources from dataset '" + datasetFileName + "'", e);
      		}
      		
      	}
      }
      I am not manually calling com.isomorphic.servlet.Init.go(), I expect super.init() would do so? Could this be a problem with the DynamicDSGenerator?

      Comment


        #4
        super.init() would indeed do so.. too late. Call super.init() first.

        Comment


          #5
          Same exception with:

          StartupServlet
          Code:
          public class StartupServlet extends Init {
          	@Override
          	public void init() throws ServletException {
          		super.init();
          		try {
          			MyDSGenerator datasourceGenerator = new MyDSGenerator(datasetFileName);
          			DataSource.addDynamicDSGenerator(datasourceGenerator);
          		} catch (Exception e) {
          			throw new ServletException("Faied to initiliaze: could net generate datasources from dataset '" + datasetFileName + "'", e);
          		}
          		
          	}
          }

          Comment


            #6
            Please double-check that result, it doesn't make much sense. If you're sure that's what's happening, please post the log from server startup until the exception occurs.

            Comment


              #7
              Updated StartupServlet to

              Code:
              public class StartupServlet extends Init {
              	@Override
              	public void init() throws ServletException {
              		logger.error("Init called");
              		super.init();
              		try {
              			MyDSGenerator datasourceGenerator = new MyDSGenerator(datasetFileName);
              			DataSource.addDynamicDSGenerator(datasourceGenerator);
              		} catch (Exception e) {
              			throw new ServletException("Faied to initiliaze: could net generate datasources from dataset '" + datasetFileName + "'", e);
              		}
              		
              	}
              }

              Server log
              Code:
              ISC: Configuring log4j from: file:/tmp/jetty-0.0.0.0-8081-myApp.war-_-any-/webapp/WEB-INF/classes/log4j.isc.config.xml
              StartupServlet: 16:03:20.040|Init called
              2013-07-17 16:03:20,390 INFO  [com.isomorphic.base.ISCInit] (main) Isomorphic SmartClient Framework - Initializing
              2013-07-17 16:03:20,394 INFO  [com.isomorphic.base.ConfigLoader] (main) Attempting to load framework.properties from CLASSPATH
              2013-07-17 16:03:20,488 INFO  [com.isomorphic.base.ConfigLoader] (main) Successfully loaded framework.properties from CLASSPATH at location: jar:file:/tmp/jetty-0.0.0.0-8081-myApp.war-_-any-/webapp/WEB-INF/lib/isomorphic_core_rpc-3.0-20120601p.jar!/framework.properties
              2013-07-17 16:03:20,488 INFO  [com.isomorphic.base.ConfigLoader] (main) Attempting to load project.properties from CLASSPATH
              2013-07-17 16:03:20,488 INFO  [com.isomorphic.base.ConfigLoader] (main) Unable to locate project.properties in CLASSPATH
              2013-07-17 16:03:20,492 INFO  [com.isomorphic.base.ConfigLoader] (main) Successfully loaded isc_interfaces.properties from CLASSPATH at location: jar:file:/tmp/jetty-0.0.0.0-8081-myApp.war-_-any-/webapp/WEB-INF/lib/isomorphic_core_rpc-3.0-20120601p.jar!/isc_interfaces.properties
              2013-07-17 16:03:20,492 INFO  [com.isomorphic.base.ConfigLoader] (main) Attempting to load server.properties from CLASSPATH
              2013-07-17 16:03:20,494 INFO  [com.isomorphic.base.ConfigLoader] (main) Successfully loaded server.properties from CLASSPATH at location: file:/tmp/jetty-0.0.0.0-8081-myApp.war-_-any-/webapp/WEB-INF/classes/server.properties
              2013-07-17 16:03:20,498 INFO  [com.isomorphic.base.ISCInit] (main) Isomorphic SmartClient Framework (v8.2p_2012-06-01/PowerEdition Deployment 2012-06-01) - Initialization Complete
              2013-07-17 16:03:20,499 INFO  [com.isomorphic.base.ISCInit] (main) No ServletContext available yet - using container IO for now
              Problem loading builtinTypes.xml
              Exception when loading from __USE_CONTAINER__/proxy/sc/system/schema/builtinTypes.xml:
              java.io.IOException: Configured for containerIO, but servletContext not available!  You need to install the Init servlet
                      at com.isomorphic.io.ISCFile.<init>(ISCFile.java:139)
                      at com.isomorphic.store.ProcessedFileCache.getObjectFromFile(ProcessedFileCache.java:138)
                      at com.isomorphic.xml.XML.getXMLDocument(XML.java:255)
                      at com.isomorphic.xml.XML.toDSRecords(XML.java:263)
                      at com.isomorphic.xml.XML.toDSRecords(XML.java:266)
                      at com.isomorphic.datasource.DataSource.<clinit>(DataSource.java:555)
                      at my.app.StartupServlet.init(StartupServlet.java:28)
                      at javax.servlet.GenericServlet.init(GenericServlet.java:244)
                      at com.isomorphic.base.Init.init(Init.java:94)
                      at org.eclipse.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:542)
                      at org.eclipse.jetty.servlet.ServletHolder.initialize(ServletHolder.java:351)
                      at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:800)
                      at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:288)
                      at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1322)
                      at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:731)
                      at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:490)
                      at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:69)
                      at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:108)
                      at org.eclipse.jetty.server.Server.start(Server.java:342)
                      at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:90)
                      at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:58)
                      at org.eclipse.jetty.server.Server.doStart(Server.java:290)
                      at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:69)
                      ...
              2013-07-17 16:03:20,509 INFO  [com.isomorphic.base.ISCInit] (main) Auto-detected webRoot - using: /tmp/jetty-0.0.0.0-8081-myApp.war-_-any-/webapp
              server.properties
              Code:
              webRoot: __AUTODETECT__
              isomorphicPathRootRelative: proxy/sc
              note: I had jetty extract the entire war to the tmp directory to facilitate auto-detect of the webapp directory. If I don't have jetty extract the war, instead of auto-detect suceeding after the exception, I see:

              Code:
              2013-07-17 16:11:20,404 ERROR [com.isomorphic.base.ISCInit] (main) Can't find marker file for webRoot: /tmp/jetty-0.0.0.0-8081-myApp.war-_-any-/webinf/proxy/sc for configured/autodetected webRoot - if you moved the 'isomorphic' directory, please set isomorphicPathRootRelative in server.properties to the new location and restart the servlet engine. 
              2013-07-17 16:11:20,404 INFO  [com.isomorphic.base.ISCInit] (main) WebRoot auto-detection failed - using container IO
              Last edited by cguven; 17 Jul 2013, 15:21.

              Comment


                #8
                Look closely at the stack trace. The Isomorphic Init servlet calls super.init(config) from init(ServletConfig) as is required by the Servlets spec before doing anything. Your init() override (note: zero argument version) is then called by the javax.servlet.GenericServlet.init() - so your code still runs before SmartClient initialization has taken place.

                To correct your code, override init(ServletConfig) not init().

                Also, don't call Logger before super.init(config) or you'll introduce the same issue of calling framework code before initialization has taken place.

                Finally, 8.2 is obsolete - please update to 8.3 or 9.0.

                Comment

                Working...
                X