Announcement

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

    Missing Context in related request using DMI datasource and lookuptype spring

    Missing Context in related request using DMI datasource and lookuptype spring.
    I am getting the error "RequestContext is missing the ServletContext. Please ensure you privide either a PageContext, a Servlet, or a ServletContext to your RequestContex.instance() call."

    I am running latest patch of 3.0 (SmartClient Version: v8.2p_2012-09-19/Pro Deployment (built 2012-09-19))

    I have two related datasources, bound by foreignkey. The first datasource contains these fields.
    Code:
            <field name="dokmal" foreignKey="dokmal.kode"/>
            <field name="dokmalBetegn" includeFrom="dokmal.betegn"/>
            <field name="ndoktype" includeFrom="dokmal.ndoktype"/>
            <field name="ejfid" includeFrom="dokmal.efjid"/>
            <field name="art" includeFrom="dokmal.jpart"/>
    Each datasource has its own DMI Datasource class.
    When using spring to load the dmi datasource classes, RequestContext complains that the context is missing when smartgwt server tries to fetch the related values from the dokmal datasource. When using lookupStyle new there is no error, even though I can see that the DSRequest.context is null on entering the dokmal dmi fetch metchod also in this case.

    While using the dokmal datasource as a optiondatasource in the client (DSRequest.isClientRequest=true) there is no problem.

    As you can see from the server logs, the first (client) request to dokmal works perfectly well, but the next, when dokmal is part of a related ds request, fails.
    Code:
    === 2012-09-20 13:29:25,447 [0-23] INFO  IDACall - Performing 1 operation(s)
    === 2012-09-20 13:29:25,447 [0-23] INFO  ServerObject - DMI on Spring bean: hjelperegisterDMI
    === 2012-09-20 13:29:25,430 [0-19] INFO  RequestContext - URL: '/esa-ui/com.edb.esa.EsaUI/sc/IDACall', User-Agent: 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; WOW64; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E; InfoPath.3)': MSIE with Accept-Encoding header, ready for compressed JS
    === 2012-09-20 13:29:25,452 [0-19] DEBUG XML - Parsed XML from (in memory stream): 2ms
    === 2012-09-20 13:29:25,452 [0-19] DEBUG RPCManager - Processing 1 requests.
    === 2012-09-20 13:29:25,456 [0-19] DEBUG RPCManager - Request #1 (DSRequest) payload: {
        criteria:{
            said:1000002,
            createJournpostType:"SAIDONLY"
        },
        operationConfig:{
            dataSource:"journpostNew",
            operationType:"fetch"
        },
        appID:"builtinApplication",
        operation:"template",
        oldValues:{
            said:1000002,
            createJournpostType:"SAIDONLY"
        }
    }
    === 2012-09-20 13:29:25,456 [0-19] INFO  IDACall - Performing 1 operation(s)
    === 2012-09-20 13:29:25,456 [0-19] WARN  DataSourceDMI - DataSource journpostNew: received a request to execute an operation of type 'fetch' named 'template', but this operation is not defined to the dataSource.  Falling back to default behavior for operationType 'fetch'
    === 2012-09-20 13:29:25,456 [0-19] INFO  ServerObject - DMI on Spring bean: createJournpostDMI
    === 2012-09-20 13:29:34,722 [0-23] INFO  DSResponse - DSResponse: List with 28 items
    === 2012-09-20 13:29:34,722 [0-23] DEBUG RPCManager - Content type for RPC transaction: text/plain; charset=UTF-8
    === 2012-09-20 13:29:34,722 [0-23] DEBUG RPCManager - DMI response, dropExtraFields: true
    === 2012-09-20 13:29:41,605 [0-19] INFO  DSResponse - DSResponse: List with 1 items
    === 2012-09-20 13:29:41,605 [0-19] INFO  ServerObject - DMI on Spring bean: hjelperegisterDMI
    === 2012-09-20 13:29:41,605 [0-19] WARN  DataSourceDMI - Failed to create serverObject using operation level config. Will try to use DataSource level config instead. Actual error: RequestContext is missing the ServletContext.  Please ensure you privide either a PageContext, a Servlet, or a ServletContext to your RequestContex.instance() call.
    === 2012-09-20 13:29:41,605 [0-19] INFO  ServerObject - DMI on Spring bean: hjelperegisterDMI
    === 2012-09-20 13:29:41,605 [0-19] WARN  RequestContext - dsRequest.execute() failed: 
    java.lang.Exception: RequestContext is missing the ServletContext.  Please ensure you privide either a PageContext, a Servlet, or a ServletContext to your RequestContex.instance() call.
    	at com.isomorphic.rpc.ServerObject.<init>(ServerObject.java:225)
    	at com.isomorphic.rpc.ServerObject.<init>(ServerObject.java:70)
    	at com.isomorphic.datasource.DataSourceDMI.execute(DataSourceDMI.java:206)
    	at com.isomorphic.datasource.DataSourceDMI.execute(DataSourceDMI.java:64)
    	at com.isomorphic.datasource.DSRequest.execute(DSRequest.java:1951)
    	at com.isomorphic.datasource.DSRequest.applyRelatedDSRequest(DSRequest.java:4043)
    	at com.isomorphic.datasource.DSRequest.fetchRelatedValues(DSRequest.java:3929)
    	at com.isomorphic.datasource.DSRequest.execute(DSRequest.java:1964)
    	at com.isomorphic.servlet.IDACall.handleDSRequest(IDACall.java:199)
    	at com.isomorphic.servlet.IDACall.processRPCTransaction(IDACall.java:156)
    	at com.isomorphic.servlet.IDACall.processRequest(IDACall.java:121)
    	at com.isomorphic.servlet.IDACall.doPost(IDACall.java:73)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
    	at com.isomorphic.servlet.BaseServlet.service(BaseServlet.java:152)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    	at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
    	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1093)
    As a sidenote, I implemented the SmartClientInitListener as mentioned in an earlier post, but this did not change the behaviour.

    Thanks in advance,
    Regards
    Hans Petter Simonsen - Evry Norway

    #2
    If you haven't installed the Init Servlet (see installation instructions) you would see this problem.

    Otherwise, there's a bug in Spring which can cause it to attempt to initialize classes even though they are set to be lazily initialized, which can cause this problem as well. 3.1d builds work around this - get one from smartclient.com/builds.

    Comment


      #3
      The Init servlet is initialized. I tried both the approach with servlet declaration in web.xml, and loading it through a contextlistener as described in http://forums.smartclient.com/showthread.php?t=14730.
      The context is also present in client requests, just not in server-internal related objects requests. This applies for lookupType="new". I also note that on entering my DMI fetch method, parameters like HttpSession and RPCManager are also null on server internal related object fetches, while they are populated on client fetches.
      Without knowing the internals of the SmartGwt server, I can not see why this you need a RequestContext in fetchRelatedValues() when using Spring, while it is appearantly not needed when using lookupType="new".

      I am not at liberty to migrate to 3.1 at this point, so I would appreciate if you could look into the details on this. Using Spring for bean injection is a great benefit since some of the DMI classes use a long time to initialize and are extensively used.
      Regards
      Hans Petter

      Comment


        #4
        Oh, if this is a request you are creating via new DSRequest(), you need to setRPCManager() or it will not have the context of a client-initiated request.

        This is by design, because DataSources can also be used in a standalone (non-web-application) context - see the Standalone DataSource Usage overview for background.

        Comment


          #5
          It is not a request initiated by myself. In the DMI fetch for the first datasource set the value for the dokmal attribute. I then return the response, and the SmartGwt server goes on to fetch the dependant values from the dokmal datasource. Within the dokmal datasource fetch method, the request object is missing the context. This works ok when the dmi class is initiated by lookupType="new" (no error and response is correctly populated even with missing context), but fails when lookupType="spring".

          Comment


            #6
            We just committed a fix to the 3.0 patch branch that should resolve this problem. Please try your use case with tomorrow's nightly build of 3.0p and let us know.

            Thanks,
            Isomorphic Software Support

            Comment


              #7
              Thanks Isomophic,
              I will not be able to test the new build until tomorrow, but I will post the results here.

              Comment


                #8
                Thanks Isomorphic. The spring loading works fine now, and the Context is present in automatic foreign key fetches, both for spring loaded classes and for lookupStyle="new". I do note that the request property isClientRequest is always true though, but this may be of no consequence (?).
                Again, thanks for the support.
                Regards Hans Petter

                Comment


                  #9
                  Hi Isomorphic,
                  The missing-context problem has resurfaced, and caused me some headache, so I thought I'd post a follow-up on this thread.
                  If you take the multi-file upload sample in the EE showcase as a starting point, and use spring-lookup for the datasources, all is well until you add a <validateRelatedRecords>true</validateRelatedRecords> to the multiUploadDetail datasource.
                  The automatically triggered fetch on the multiUploadMaster datasource when you add a record to the detail datasource will fail because the requestcontext is missing.
                  The problem should be easily reproducable, but if needed, I can post related server-logs.
                  I am running v8.2p_2012-09-26/Pro Deployment.
                  Regards
                  Hans Petter Simonsen, EVRY Norway

                  Comment


                    #10
                    Hello hanspetter, have you solved this problem?
                    I think I've got a similar problem with 8.3:
                    http://forums.smartclient.com/showthread.php?t=21975

                    Comment


                      #11
                      Sorry, I didn't get any response from Isomorphic on this. I worked around it in my case by skipping the validation.

                      Comment

                      Working...
                      X