Announcement

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

    What's the correct way to execute a DSRequest at init-time

    Hello,

    we're trying to populate several tables during the application start up using SmartGWT server API. We added a new servlet that should be loading after Init servlet like this:
    Code:
    web.xml:
        <listener>          <listener-class>com.isomorphic.base.InitListener</listener-class>
          </listener>
      
        <servlet>
              <servlet-name>Init</servlet-name>
              <servlet-class>com.isomorphic.base.Init</servlet-class>
              <load-on-startup>1</load-on-startup>
          </servlet>
        <servlet>
              <servlet-name>InitRbp</servlet-name>
              <servlet-class>com.harris.nm.framework.server.util.InitRbp</servlet-class>
              <load-on-startup>2</load-on-startup>
          </servlet>
    but DSRequest fails with NullPointerException and then this:
    Code:
     === 2015-11-11 15:35:49,594 [main] WARN  BasicDataSource - Corrupt DataSource detected - required files under {isomorphicDir}/system/schema may be missing or unreadable.  This typically results from skipping installation steps.  If using SmartGWT, verify your <inherits> and run a GWT compile.  If using SmartClient, verify you have copied the correct folders from Pro or better smartclientSDK.  Installation instructions are linked from the QuickStart Guide.
    The rest of the application works as expected, no exceptions, only the init-time is problematic.

    this is the servlet init method:
    Code:
     public class InitRbp extends HttpServlet {
          public void init() throws ServletException {
                  DSRequest dsRequest  = new DSRequest("units", "fetch");
                  DataSource dataSource = dsRequest.getDataSource();
                  List<?> records = dataSource.fetch(null);
    }
    }
    log:
    Code:
     Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=256m; support was removed in 8.0
      [WARN] Server class 'org.eclipse.jetty.servlet.listener.ELContextCleaner' could not be found in the web app, but was found on the system classpath
         [WARN] Adding classpath entry 'file:/Users/alex/.m2/repository/org/eclipse/jetty/jetty-servlet/8.1.7.v20120910/jetty-servlet-8.1.7.v20120910.jar' to the web app classpath for this session
      ISC: Configuring log4j from: file:/Users/alex/workspace-sts-3.6.4.RELEASE-D3/jenm-role-based-planning-service/target/jenm-role-based-planning-service-3.3.1.0-E1-SNAPSHOT/WEB-INF/classes/log4j.isc.config.xml
      === 2015-11-11 16:00:01,994 [main] INFO  ISCInit - Isomorphic SmartClient/SmartGWT Framework - Initializing
      === 2015-11-11 16:00:02,000 [main] INFO  ConfigLoader - Attempting to load framework.properties from CLASSPATH
      === 2015-11-11 16:00:02,043 [main] INFO  ConfigLoader - Successfully loaded framework.properties from CLASSPATH at location: jar:file:/Users/alex/workspace-sts-3.6.4.RELEASE-D3/jenm-role-based-planning-service/target/jenm-role-based-planning-service-3.3.1.0-E1-SNAPSHOT/WEB-INF/lib/isomorphic-core-rpc-5.0-p20141209.jar!/framework.properties
      === 2015-11-11 16:00:02,044 [main] INFO  ConfigLoader - Attempting to load project.properties from CLASSPATH
      === 2015-11-11 16:00:02,044 [main] INFO  ConfigLoader - Unable to locate project.properties in CLASSPATH
      === 2015-11-11 16:00:02,046 [main] INFO  ConfigLoader - Successfully loaded isc_interfaces.properties from CLASSPATH at location: jar:file:/Users/alex/workspace-sts-3.6.4.RELEASE-D3/jenm-role-based-planning-service/target/jenm-role-based-planning-service-3.3.1.0-E1-SNAPSHOT/WEB-INF/lib/isomorphic-core-rpc-5.0-p20141209.jar!/isc_interfaces.properties
      === 2015-11-11 16:00:02,046 [main] INFO  ConfigLoader - Attempting to load server.properties from CLASSPATH
      === 2015-11-11 16:00:02,048 [main] INFO  ConfigLoader - Successfully loaded server.properties from CLASSPATH at location: file:/Users/alex/workspace-sts-3.6.4.RELEASE-D3/jenm-role-based-planning-service/target/jenm-role-based-planning-service-3.3.1.0-E1-SNAPSHOT/WEB-INF/classes/server.properties
      === 2015-11-11 16:00:02,054 [main] INFO  Logger - Logging system started.
      === 2015-11-11 16:00:02,056 [main] DEBUG ConfigParser - Matched var name: gwtModuleName
      === 2015-11-11 16:00:02,056 [main] DEBUG ConfigParser - value after substitution: rbp/sc
      === 2015-11-11 16:00:02,056 [main] ERROR ISCInit - Can't find marker file for webRoot: /Users/alex/workspace-sts-3.6.4.RELEASE-D3/jenm-role-based-planning-service/target/jenm-role-based-planning-service-3.3.1.0-E1-SNAPSHOT/rbp/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.
      === 2015-11-11 16:00:02,056 [main] INFO  ISCInit - WebRoot auto-detection failed - using container IO
      === 2015-11-11 16:00:02,057 [main] INFO  ISCInit - Isomorphic SmartClient/SmartGWT Framework (v10.0p_2014-12-09/Enterprise Deployment 2014-12-09) - Initialization Complete
      === 2015-11-11 16:00:04,852 [main] DEBUG ConfigParser - Matched var name: debug
      === 2015-11-11 16:00:04,853 [main] DEBUG ConfigParser - value after substitution: true
      === 2015-11-11 16:00:04,856 [main] DEBUG ConfigParser - Matched var name: isomorphicDir
      === 2015-11-11 16:00:04,856 [main] DEBUG ConfigParser - Matched var name: isomorphicPathRootRelative
      === 2015-11-11 16:00:04,856 [main] DEBUG ConfigParser - Matched var name: gwtModuleName
      === 2015-11-11 16:00:04,856 [main] DEBUG ConfigParser - value after substitution: rbp/sc
      === 2015-11-11 16:00:04,856 [main] DEBUG ConfigParser - value after substitution: rbp/sc
      === 2015-11-11 16:00:04,856 [main] DEBUG ConfigParser - Matched var name: webRoot
      === 2015-11-11 16:00:04,856 [main] DEBUG ConfigParser - value after substitution: __USE_CONTAINER__/rbp/sc
      === 2015-11-11 16:00:04,857 [main] DEBUG ConfigParser - value after substitution: __USE_CONTAINER__/rbp/sc/system/schema
      Problem loading builtinTypes.xml
      Exception when loading from __USE_CONTAINER__/rbp/sc/system/schema/builtinTypes.xml:
      java.lang.NullPointerException
          at com.isomorphic.io.ISCFile.lastModified(ISCFile.java:519)
          at com.isomorphic.store.ProcessedFileCache.getObjectFromFile(ProcessedFileCache.java:140)
          at com.isomorphic.xml.XML.getXMLDocument(XML.java:286)
          at com.isomorphic.xml.XML.toDSRecords(XML.java:294)
          at com.isomorphic.xml.XML.toDSRecords(XML.java:298)
          at com.isomorphic.xml.XML.toDSRecords(XML.java:303)
          at com.isomorphic.datasource.DataSource.<clinit>(DataSource.java:990)
          at com.isomorphic.datasource.DataSourceManager.getDataSource(DataSourceManager.java:132)
          at com.isomorphic.datasource.DataSourceManager.getDataSource(DataSourceManager.java:86)
          at com.isomorphic.datasource.DSRequest.getDataSource(DSRequest.java:2211)
          at com.harris.nm.framework.server.util.InitRbp.init(InitRbp.java:28)
          at javax.servlet.GenericServlet.init(GenericServlet.java:244)
          at org.eclipse.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:517)
          at org.eclipse.jetty.servlet.ServletHolder.doStart(ServletHolder.java:331)
          at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
          at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:747)
          at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:263)
          at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1238)
          at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:706)
          at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:480)
          at com.google.gwt.dev.shell.jetty.JettyLauncher$WebAppContextWithReload.doStart(JettyLauncher.java:518)
          at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
          at org.eclipse.jetty.server.handler.HandlerWrapper.doStart(HandlerWrapper.java:95)
          at org.eclipse.jetty.server.handler.RequestLogHandler.doStart(RequestLogHandler.java:142)
          at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
          at org.eclipse.jetty.server.handler.HandlerWrapper.doStart(HandlerWrapper.java:95)
          at org.eclipse.jetty.server.Server.doStart(Server.java:277)
          at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
          at com.google.gwt.dev.shell.jetty.JettyLauncher.start(JettyLauncher.java:717)
          at com.google.gwt.dev.DevMode.doStartUpServer(DevMode.java:522)
          at com.google.gwt.dev.DevModeBase.startUp(DevModeBase.java:1104)
          at com.google.gwt.dev.DevModeBase.run(DevModeBase.java:844)
          at com.google.gwt.dev.DevMode.main(DevMode.java:322)
       
      === 2015-11-11 16:00:04,899 [main] INFO  PoolManager - SmartClient pooling started for 'units' objects
      === 2015-11-11 16:00:04,900 [main] DEBUG ISCKeyedObjectPool - Borrowing object for 'units'
      === 2015-11-11 16:00:04,901 [main] DEBUG ConfigParser - Matched var name: webRoot
      === 2015-11-11 16:00:04,901 [main] DEBUG ConfigParser - value after substitution: __USE_CONTAINER__/ds
      === 2015-11-11 16:00:04,909 [main] DEBUG XML - Parsed XML from __USE_CONTAINER__/ds/units.ds.xml: 4ms
      === 2015-11-11 16:00:04,910 [main] DEBUG ISCKeyedObjectPool - Borrowing object for 'DataSource'
      === 2015-11-11 16:00:04,911 [main] DEBUG PoolableDataSourceFactory - Created DataSource null of type 'DataSource' in the pooling flow
      === 2015-11-11 16:00:04,912 [main] DEBUG ISCKeyedObjectPool - Borrowing object for 'Object'
      === 2015-11-11 16:00:04,921 [main] DEBUG PoolableDataSourceFactory - Created DataSource 1 of type 'Object' and assigned it to thread main
      === 2015-11-11 16:00:04,921 [main] DEBUG PoolableDataSourceFactory - Created DataSource 1 of type 'Object' in the pooling flow
      === 2015-11-11 16:00:04,921 [main] DEBUG PoolableDataSourceFactory - Activated DataSource 1 of type 'Object'
      === 2015-11-11 16:00:04,922 [main] DEBUG ISCKeyedObjectPool - Borrowing object for 'fields'
      === 2015-11-11 16:00:04,923 [main] DEBUG PoolableDataSourceFactory - Created DataSource null of type 'fields' in the pooling flow
      === 2015-11-11 16:00:04,923 [main] DEBUG ISCKeyedObjectPool - Borrowing object for 'field'
      === 2015-11-11 16:00:04,924 [main] DEBUG PoolableDataSourceFactory - Created DataSource null of type 'field' in the pooling flow
      === 2015-11-11 16:00:04,951 [main] WARN  BasicDataSource - units: specification of field 'field' invalid: [
          {
              hidden:"true",
              name:"units_id",
              primaryKey:"true",
              type:"sequence"
          },
          {
              name:"name",
              type:"text"
          },
          {
              name:"urn",
              title:"URN",
              type:"integer"
          },
          {
              foreignKey:"units.units_id",
              hidden:"true",
              name:"parent",
              type:"integer"
          },
          {
              name:"icon",
              title:"Icon",
              type:"text"
          },
          {
              hidden:"true",
              name:"unit_type",
              title:"Unit Type",
              type:"text"
          },
          {
              name:"short_name",
              title:"Short Name",
              type:"text"
          },
          {
              name:"member_type",
              title:"Member Type",
              type:"text"
          }
      ]
      === 2015-11-11 16:00:04,951 [main] WARN  BasicDataSource - Corrupt DataSource detected - required files under {isomorphicDir}/system/schema may be missing or unreadable.  This typically results from skipping installation steps.  If using SmartGWT, verify your <inherits> and run a GWT compile.  If using SmartClient, verify you have copied the correct folders from Pro or better smartclientSDK.  Installation instructions are linked from the QuickStart Guide.
      === 2015-11-11 16:00:05,269 [izer] DEBUG DSRequest - Ignoring freeResources call because this is not a primary request!
    we're using Isomorphic SmartClient/SmartGWT Framework (v10.0p_2014-12-09/Enterprise Deployment 2014-12-09) in a maven project. What would be the right way to migrate/initialize the database during init-time?

    #2
    Hi abthere,

    did you already see these docs?

    Best regards
    Blama

    Comment


      #3
      Your approach looks OK and the init logs look OK up to the point that a failure occurs.

      The question is: is that file actually missing at the moment your servlet runs? We've seen some generated startup scripts that "cheat" by parallelizing copying of resources into webroot with servlet startup. This is obviously invalid, but we've seen it in a number of projects.

      Comment


        #4
        I think Eclipse GWT plugin is responsible for this. It looks like it starts the app first and then swaps the war folder shortly after. We're still trying to figure out how to alleviate this issue that manifests itself only in debug mode, so any suggestions will be the most appreciated.

        Comment

        Working...
        X