Announcement

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

    #16
    The NPE has been corrected, however, it was actually just a crash in the midst of telling you that the SessionFactory you provided was not a valid instance of Hibernate3 or Hibernate4's SessionFactory, in other words, that you've got invalid config.

    Now that an NPE won't happen in this case, your fake SessionFactory object might actually work, since we call all the relevant methods via Java reflection. However, this wouldn't be a supported approach.

    So options are now:
    1. continue with your unsupported hack; it may work
    2. use Spring
    3. sponsor a supported way to do this without Spring. If this is how you'd like to proceed, use the contact page to get started

    Comment


      #17
      1. How can I get the version with the fixed NPE?
      2. It's a problem for us to change the entire hibernate initiation to spring right now
      3. I want to know how much it should cost me.

      Comment


        #18
        Today's 3.1p and 4.0d nightly builds contain the fix for the NPE (ie, the ones dated December 19). For the Feature Sponsorship enquiry, please use the contact page

        Comment


          #19
          Thank you for the help

          Comment


            #20
            After getting the new build the null pointer exception is gone but the functionality doesn't work well. This means that the data of the DataSource with the configBean is fetched from the main HibernateConfiguration and not from the one that is configured with the configBean.

            I took the liberty to do some debugging and it's seems that the first time the DataSource with the configBean is initialized the variable localHibernateConfig is set in class HibernateDataSource.

            Code:
            Method method = Reflection.findMethod(factoryBean, "getConfiguration");
                                localHibernateConfig = (Configuration)method.invoke(factoryBean, null);
                                method = Reflection.findMethod(factoryBean, "getObject");
                                localSessionFactory = (SessionFactory)method.invoke(factoryBean, null);
            so the next time the initConfigAndSessionFactory function is called the variable is already initialize so the if statement doesn't pass.

            Code:
            if(localHibernateConfig == null && dsConfig.get("configBean") != null)
            Thus, making the main hibernate configuration and session factory to be used instead of the one that is configured in the DataSource using the configBean attribute.

            Here is the complete log for the request.

            Code:
            === 2012-12-23 18:39:59,438 [80-5] INFO  RequestContext - URL: '/MSP/resources/isomorphic/DataSourceLoader', User-Agent: 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20100101 Firefox/17.0': Moz (Gecko) with Accept-Encoding header
            === 2012-12-23 18:39:59,439 [80-5] DEBUG XML - Parsed XML from (in memory stream): 0ms
            === 2012-12-23 18:39:59,442 [80-5] INFO  ServerObject - DMI on Spring bean: &hibernate_test
            === 2012-12-23 18:39:59,443 [80-5] WARN  HibernateDataSource - Factory bean is not an instance of either org.springframework.orm.hibernate3.LocalSessionFactoryBean or org.springframework.orm.hibernate4.LocalSessionFactoryBean class - is Spring correctly installed and configured?
            === 2012-12-23 18:40:05,837 [80-5] DEBUG DataSourceAnnotations - Generating data source 'GenericTask' for class com.msp.dao.entities.GenericTask
            === 2012-12-23 18:40:05,866 [80-5] INFO  RequestContext - URL: '/MSP/resources/isomorphic/IDACall', User-Agent: 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20100101 Firefox/17.0': Moz (Gecko) with Accept-Encoding header
            === 2012-12-23 18:40:05,867 [80-5] DEBUG IDACall - Header Name:Value pair: host:localhost:8080
            === 2012-12-23 18:40:05,867 [80-5] DEBUG IDACall - Header Name:Value pair: user-agent:Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20100101 Firefox/17.0
            === 2012-12-23 18:40:05,867 [80-5] DEBUG IDACall - Header Name:Value pair: accept:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
            === 2012-12-23 18:40:05,869 [80-5] DEBUG IDACall - Header Name:Value pair: accept-language:en-US,en;q=0.5
            === 2012-12-23 18:40:05,869 [80-5] DEBUG IDACall - Header Name:Value pair: accept-encoding:gzip, deflate
            === 2012-12-23 18:40:05,869 [80-5] DEBUG IDACall - Header Name:Value pair: connection:keep-alive
            === 2012-12-23 18:40:05,869 [80-5] DEBUG IDACall - Header Name:Value pair: content-type:application/x-www-form-urlencoded; charset=UTF-8
            === 2012-12-23 18:40:05,869 [80-5] DEBUG IDACall - Header Name:Value pair: referer:http://localhost:8080/MSP/pages/smart_client_example.jsp
            === 2012-12-23 18:40:05,869 [80-5] DEBUG IDACall - Header Name:Value pair: content-length:888
            === 2012-12-23 18:40:05,869 [80-5] DEBUG IDACall - Header Name:Value pair: cookie:JSESSIONID=517D8C8B22468C2CDD6B9BA948C1639A; LANGUAGE=en; LANGUAGE_DIRECTION=ltr; 6_1_USER_ROLE_INSTALLED_APPLICATION=18; 1_1_QUICK_SEARCH_ENTITY_IDENTIFIER=REQUEST_ENTITY_FOR_SEARCH; 1_1_QUICK_SEARCH_ENTITY_CLASS_NAME=com.msp.dao.entities.Requirement; GLog=%7B%0D%20%20%20%20left%3A606%2C%20%0D%20%20%20%20top%3A299%2C%20%0D%20%20%20%20width%3A638%2C%20%0D%20%20%20%20height%3A479%2C%20%0D%20%20%20%20priorityDefaults%3A%7B%0D%20%20%20%20%20%20%20%20Log%3A4%0D%20%20%20%20%7D%2C%20%0D%20%20%20%20defaultPriority%3A3%0D%7D; 1_3_USER_ROLE_INSTALLED_APPLICATION=6; 6_3_USER_ROLE_INSTALLED_APPLICATION=43; 1_9_USER_ROLE_INSTALLED_APPLICATION=6; REMEMBER_ME=REMEMBER_ME; USER_NAME=administrator; USER_PASSWORD=8ekmkYSu2oK6Xp2M2u2wsQ%3D%3D; 1_1_USER_ROLE_INSTALLED_APPLICATION=6; INSTALLED_APPLICATION=1; isc_cState=ready
            === 2012-12-23 18:40:05,869 [80-5] DEBUG IDACall - Header Name:Value pair: pragma:no-cache
            === 2012-12-23 18:40:05,870 [80-5] DEBUG IDACall - Header Name:Value pair: cache-control:no-cache
            === 2012-12-23 18:40:05,870 [80-5] DEBUG IDACall - session exists: 517D8C8B22468C2CDD6B9BA948C1639A
            === 2012-12-23 18:40:05,870 [80-5] DEBUG IDACall - remote user: null
            === 2012-12-23 18:40:05,871 [80-5] DEBUG XML - Parsed XML from (in memory stream): 0ms
            === 2012-12-23 18:40:05,872 [80-5] DEBUG RPCManager - Processing 1 requests.
            === 2012-12-23 18:40:05,873 [80-5] DEBUG XML - Parsed XML from (in memory stream): 0ms
            === 2012-12-23 18:40:05,875 [80-5] INFO  ServerObject - DMI on Spring bean: &hibernate_test
            === 2012-12-23 18:40:05,876 [80-5] WARN  HibernateDataSource - Factory bean is not an instance of either org.springframework.orm.hibernate3.LocalSessionFactoryBean or org.springframework.orm.hibernate4.LocalSessionFactoryBean class - is Spring correctly installed and configured?
            === 2012-12-23 18:40:05,877 [80-5] DEBUG DataSourceAnnotations - Generating data source 'GenericTask' for class com.msp.dao.entities.GenericTask
            === 2012-12-23 18:40:05,878 [80-5] DEBUG RPCManager - Request #1 (DSRequest) payload: {
                criteria:{
                    parent:null
                },
                operationConfig:{
                    dataSource:"treeHqlQuery_hib_111",
                    operationType:"fetch"
                },
                appID:"builtinApplication",
                operation:"treeHqlQuery_hib_111_fetch",
                oldValues:{
                    parent:null
                }
            }
            === 2012-12-23 18:40:05,878 [80-5] INFO  IDACall - Performing 1 operation(s)
            === 2012-12-23 18:40:05,878 [80-5] DEBUG DeclarativeSecurity - Processing security checks for DataSource null, field null
            === 2012-12-23 18:40:05,878 [80-5] DEBUG DeclarativeSecurity - DataSource treeHqlQuery_hib_111 is not in the pre-checked list, processing...
            === 2012-12-23 18:40:07,262 [80-1] INFO  Download - Returning 304: Not modified on conditional get of: C:\Projects\MSP\Rotemy IOF\out\exploded\ProjectsMSP\resources\isomorphic\skins\Enterprise\images\DynamicForm\date_control.png
            === 2012-12-23 18:40:07,265 [80-5] DEBUG DeclarativeSecurity - Processing security checks for DataSource null, field null
            === 2012-12-23 18:40:07,265 [80-5] DEBUG DeclarativeSecurity - DataSource treeHqlQuery_hib_111 is not in the pre-checked list, processing...
            === 2012-12-23 18:40:07,265 [80-5] DEBUG AppBase - [builtinApplication.treeHqlQuery_hib_111_fetch] No userTypes defined, allowing anyone access to all operations for this application
            === 2012-12-23 18:40:07,267 [80-1] INFO  Download - Returning 304: Not modified on conditional get of: C:\Projects\MSP\Rotemy IOF\out\exploded\ProjectsMSP\resources\isomorphic\skins\Enterprise\images\RecordEditor\filter.png
            === 2012-12-23 18:40:07,267 [80-5] DEBUG AppBase - [builtinApplication.treeHqlQuery_hib_111_fetch] No public zero-argument method named '_treeHqlQuery_hib_111_fetch' found, performing generic datasource operation
            === 2012-12-23 18:40:07,268 [80-5] INFO  HibernateDataSource - [builtinApplication.treeHqlQuery_hib_111_fetch] Performing fetch operation with
            	criteria: {parent:null}	values: {parent:null}
            === 2012-12-23 18:40:07,270 [80-6] INFO  Download - Returning 304: Not modified on conditional get of: C:\Projects\MSP\Rotemy IOF\out\exploded\ProjectsMSP\resources\isomorphic\skins\Enterprise\images\loadingSmall.gif
            === 2012-12-23 18:40:07,272 [80-1] INFO  Download - Returning 304: Not modified on conditional get of: C:\Projects\MSP\Rotemy IOF\out\exploded\ProjectsMSP\resources\isomorphic\skins\Enterprise\images\blank.gif
            === 2012-12-23 18:40:07,274 [80-5] INFO  HibernateDataSource - [builtinApplication.treeHqlQuery_hib_111_fetch] Query string: select _GenericTask, parentTask1 from com.msp.dao.entities.GenericTask _GenericTask left outer join _GenericTask.parentTask parentTask1 where _GenericTask.parentTask.id is null
            === 2012-12-23 18:40:07,381 [80-5] INFO  DSResponse - [builtinApplication.treeHqlQuery_hib_111_fetch] DSResponse: List with 0 items
            === 2012-12-23 18:40:07,381 [80-5] INFO  HibernateTransaction - [builtinApplication.treeHqlQuery_hib_111_fetch] Attempting to commit 0 database update(s)
            === 2012-12-23 18:40:07,382 [80-5] INFO  DSResponse - DSResponse: List with 0 items
            === 2012-12-23 18:40:07,382 [80-5] DEBUG RPCManager - Content type for RPC transaction: text/plain; charset=UTF-8
            === 2012-12-23 18:40:07,383 [80-5] DEBUG XML - Parsed XML from (in memory stream): 0ms
            === 2012-12-23 18:40:07,388 [80-5] INFO  ServerObject - DMI on Spring bean: &hibernate_test
            === 2012-12-23 18:40:07,390 [80-5] WARN  HibernateDataSource - Factory bean is not an instance of either org.springframework.orm.hibernate3.LocalSessionFactoryBean or org.springframework.orm.hibernate4.LocalSessionFactoryBean class - is Spring correctly installed and configured?
            === 2012-12-23 18:40:07,390 [80-5] DEBUG DataSourceAnnotations - Generating data source 'GenericTask' for class com.msp.dao.entities.GenericTask
            === 2012-12-23 18:40:07,391 [80-5] DEBUG RPCManager - DMI response, dropExtraFields: true
            === 2012-12-23 18:40:07,392 [80-5] INFO  Compression - /MSP/resources/isomorphic/IDACall: 173 -> 148 bytes

            Comment


              #21
              We're not following your code analysis - what that code says is that we don't need to obtain the localHibernateConfig twice. It sounds like maybe your fake SessionFactory object doesn't return a Hibernate Configuration? It would be expected to.

              And just a reminder that substituting a fake SessionFactory-like object here is well outside of the supported use cases.

              Comment


                #22
                I tested the "fake" session factory class thoroughly. Furthermore I placed brakepoints in the getObject and getConnection methods of my "fake" session factory class and I can clearly see that when the DataSource is being processed the methods are being called.

                For some reason this code is fetching the static hibernate configuration

                HibernateDataSource:processRequest

                Code:
                session = HibernateTransaction.getTransactionSession(trx);
                Please take a look.

                Comment


                  #23
                  Re-read previous post - the conditional you're focusing on is based on the Configuration.

                  Are you returning a valid one? If not, this approach can't work.

                  Comment


                    #24
                    I clearly said that I placed brakepoints in the getObject and getConnection methods of my "fake" session factory class and I can clearly see that when the DataSource is being processed the methods are being called. So I'm 100% sure that my "fake" session factory works.

                    The previous post wasn't about the condition. I told you that the session that is fetched from the HibernateTransaction.getTransactionSession(trx); is the static one and not the one configured with the configBean of the DataSource.

                    Comment


                      #25
                      It's great that you've done a bunch of debugging with breakpoints and such. You still need to make it clear what you've established and pointing to a random method returning an unexpected result doesn't do that.

                      Again look at the code snippets you posted:

                      Method method = Reflection.findMethod(factoryBean, "getConfiguration");
                      localHibernateConfig = (Configuration)method.invoke(factoryBean, null);
                      method = Reflection.findMethod(factoryBean, "getObject");
                      localSessionFactory = (SessionFactory)method.invoke(factoryBean, null);

                      ...

                      if(localHibernateConfig == null && dsConfig.get("configBean") != null)
                      We obtain *both* a Configuration *and* a SessionFactory from your configBean. You keep mentioning getObject() and getConnection() but its the *Configuration* that is used to decide whether we're using DataSource-specific or system-wide Hibernate settings.

                      Comment


                        #26
                        OK, let me clarify everything.

                        The reason I placed brakepoints is to make sure that my hibernate spring configuration is working properly and it does.

                        The code I showed you before is not related to the problem as I thought so please ignore it.

                        Again, I want to emphasize my problem. I have two hibernate configurations, one is pointing to DB1 and the second one to DB2, the data bases structure is the same just with different data. The main hibernate configuration (configured via server.properties) is pointing to DB1 and the secondary hibernate configuration (configured via spring) is pointing to DB2. I have two ListGrids, the first one's DataSource doesn't have configBean and displaying data from DB1 and the second one's DataSource does have configBean that is pointing out to the spring bean of the secondary data base (DB2) and should display data from DB2 but instead it displaying data from DB1.

                        The problematic code is this:

                        HibernateDataSource:processRequest

                        Code:
                                Transaction trx = null;
                                Session session = null;
                                if(shouldAutoJoinTransaction(req))
                                {
                                    trx = (Transaction)getTransactionObject(req);
                                    if(trx == null)
                                    {
                                        if(shouldAutoStartTransaction(req, false))
                                        {
                                            trx = getOrStartTransaction(req);
                                        } else
                                        {
                                            trx = HibernateTransaction.startTransaction(null);
                                            inlineTransaction = trx;
                                        }
                                        if(trx != null)
                                            req.setPartOfTransaction(true);
                                    }
                                } else
                                {
                                    -> trx = HibernateTransaction.startTransaction(null); 
                                    inlineTransaction = trx;
                                }
                                currentTransaction = trx;
                                -> session = HibernateTransaction.getTransactionSession(trx);
                        HibernateTransaction:startTransaction

                        Code:
                                Map trxInfo = new HashMap();
                                -> Session session = openSession(HibernateDataSource.getStaticSessionFactory()); 
                                Transaction trx = session.beginTransaction();
                                trxInfo.put("session", session);
                                trxInfo.put("transaction", trx);
                        HibernateTransaction.getTransactionSession

                        Code:
                                Map trxInfo = (Map)transactionInfo.get(trx);
                                if(trxInfo == null)
                                    return null;
                                else
                                    -> return (Session)trxInfo.get("session");
                        You can clearly see that the session is being fetched from the static session factory and not the local session factory and this is the problem.

                        Comment


                          #27
                          We already understood the use case..

                          It seems like you're expecting two different Hibernate transactions to be created and managed during a single request? That's not something we currently support.

                          Instead, the DataSource that is using a configBean should be set to not attempt to join the current transaction (see DataSource.autoJoinTransactions). Requests to that DataSource will then be executed with immediate commits.

                          Comment


                            #28
                            "the DataSource that is using a configBean should be set to not attempt to join the current transaction" - This is what happening now. The DataSource is not set to join any transaction and I can see that the "if(shouldAutoJoinTransaction(req))" return false.

                            The transaction is being set by this line:

                            Code:
                            trx = HibernateTransaction.startTransaction(null);
                            and the session by this line:

                            Code:
                            session = HibernateTransaction.getTransactionSession(trx);
                            which returns the static session and not the local.

                            Comment


                              #29
                              That looks like it may be an actual bug - not entirely clear, since we'll still use your local Configuration even if we're not using the local sessionFactory.

                              What bad result are you seeing from this? You showed a log, but there's no crash and you never described what was actually going wrong at an application level.

                              Note: it's a holiday in the States, we will probably not respond again until the 26th.

                              Comment


                                #30
                                "That looks like it may be an actual bug - not entirely clear, since we'll still use your local Configuration even if we're not using the local sessionFactory." - This is correct because both of the hibernate configurations (static and local) are pointing to similar data bases which have same structure (tables, functions, etc) but different data. This is why I'm not getting any error just bad results.

                                "What bad result are you seeing from this? You showed a log, but there's no crash and you never described what was actually going wrong at an application level." - Actually I explained it very clearly, let me write it again. I have two hibernate configurations, one is pointing to DB1 and the second one to DB2, the data bases structure is the same just with different data. The main hibernate configuration (configured via server.properties) is pointing to DB1 and the secondary hibernate configuration (configured via spring) is pointing to DB2. I have two ListGrids, the first one's DataSource doesn't have configBean and displaying data from DB1 and the second one's DataSource does have configBean that is pointing out to the spring bean of the secondary data base (DB2) and should display data from DB2 but instead it displaying data from DB1.

                                Please notice that I am waiting quite a long time for a solution for this problem. Marry Christmas!

                                Comment

                                Working...
                                X