Announcement

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

    Do two separate applications deployed to tomcat share datasources?

    Testing migration from SmartClient_v90p_2013-12-07_PowerEdition to SmartClient_v91p_2014-03-04_PowerEdition

    I am observing some strange behavior. We have two separate web applications both using SmartClient power edition deployed to same tomcat server. The two apps have a lot of common boilerplate code. So they have many datasource ds.xml files that have same names. Please note that the ds.xml files have same names but are two separate files residing in their respective web applications. And in some cases the ds.xml contents differ due to differing app requirements.

    For example users.ds.xml in webapp1 has below fetch method :
    Code:
    <operationBinding operationType="fetch">
          <tableClause>muser,mclient,mparty,mpartybranch</tableClause>
          <whereClause>muser.usercode = $session.usercode AND muser.clientid = $session.clientid </whereClause>
        </operationBinding>
    and the users.ds.xml file in webapp2 has below fetch method :
    Code:
    <operationBinding operationType="fetch">
          <tableClause>muser,mclient,mparty,mpartybranch</tableClause>
          <whereClause>muser.usercode = $criteria.usercode AND muser.clientid = $criteria.clientid </whereClause>
        </operationBinding>
    Both these web applications were working fine together in tomcat with SmartClient_v90p_2013-12-07_PowerEdition but after upgrading on test machine to SmartClient_v91p_2014-03-04_PowerEditionNow, and while using webapp2 I am observing intermittent errors in log like :

    === 2014-03-24 15:43:27,919 [c-22] WARN RequestContext - dsRequest.execute() failed:
    org.postgresql.util.PSQLException: ERROR: syntax error at or near "$"

    The query that caused this error is :
    Code:
    === 2014-03-24 15:43:27,918 [c-22] INFO  SQLDriver - [builtinApplication.users_fetch] Executing SQL query on 'USCProduction-localhost': SELECT muser.userid, muser.username, muser.userloginname, muser.clientid, mclient.clientname, muser.workpartybranchid, mpartybranch.partybranchcode, mpartybranch.partybranchshortname, mpartybranch.partyid, mparty.partyname, muser.password, muser.salt FROM muser,mclient,mparty,mpartybranch WHERE muser.usercode = $session.usercode AND muser.clientid = '414474781000924'  AND muser.userid = muser.userid AND muser.clientid = mclient.clientid AND muser.workpartybranchid = mpartybranch.partybranchid AND mpartybranch.partyid = mparty.partyid
    But webapp2 does not use this query. It uses a different query as shown above based on $criteria.

    Another instance of this problem is even stranger.
    In webapp2 I have a musersettings.ds.xml file without a fetch method declared. i.e. it uses the default fetch. In webapp1 musersettings.ds.xml, I have a fetch method with a customsql AND a operationId=fetchSuperAdminRole. In some places in webapp1 we load data from musersettings datasource via : isc.DataSource.get('musersettings').fetchData(null, some_callback_fn,{operationId:"fetchSuperAdminRole"});
    I have observed that intermittently, while loading webapp1 the default fetch of webapp2 is performed not the customsql fetch of operationid=fetchSuperAdminRole of webapp1. This does not cause an error but screws the application logic.

    I said intermittent because sometimes, after restarting tomcat, both webapps work properly each getting its intended query, but on some restart or webapp reloading because of a commit, this error starts appearing again.

    My questions are :
    1) Why is webapp1 query being run for webap2? ( and the opposite sometimes)
    2) Is it because the datasource names are same?
    3) If yes why did this not ever bother us in SmartClient_v90p_2013-12-07_PowerEdition?

    #2
    Tomcat's responsibility in this case is to "sandbox" the two applications so that they totally separate - separate instances of classes, separate lookup of resources stored in .jars or in the .war, etc.

    There is nothing that SmartClient could do to get out of this sandbox.

    So our best guess is that you are looking at a subtle Tomcat bug.

    It's possible, but fairly unlikely, that some change between 9.0 and 9.1 is triggering Tomcat's bug in this case, but we have no way of guessing what that would be - it could be anything from loading files in a different order, to doing less disk I/O overall - absolutely anything.

    Comment


      #3
      Subtle tomcat bug? Highly unlikely. Never seen tomcat doing this for any other types of files. We have several files such as servlets, js, jsp, html with common names within the two applications. These never conflicted. I suspect its the common datasource ID in SmartClient framework thats causing this problem. I dont have the time or resources to dig into this, so I'm going to move ahead by prefixing the DS file names and ids. But I implore you to investigate this.

      Comment


        #4
        So once again: a basic attribute of the Java servlets platform is that it is actually not possible for us to affect the operation of a separate .war.

        So there is no way for us to look for a bug in our own software - in theory, no matter what we do, we cannot cause the issue you are experiencing.

        This is why we recommend looking at Tomcat issues. By the way, Tomcat is not, by any means, free of issues (they have a bug tracker if you care to look..).

        Comment

        Working...
        X