Return-Path: Delivered-To: apmail-ibatis-user-java-archive@www.apache.org Received: (qmail 36177 invoked from network); 21 Aug 2006 03:39:52 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 21 Aug 2006 03:39:52 -0000 Received: (qmail 62542 invoked by uid 500); 21 Aug 2006 03:39:50 -0000 Delivered-To: apmail-ibatis-user-java-archive@ibatis.apache.org Received: (qmail 62522 invoked by uid 500); 21 Aug 2006 03:39:50 -0000 Mailing-List: contact user-java-help@ibatis.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user-java@ibatis.apache.org Delivered-To: mailing list user-java@ibatis.apache.org Received: (qmail 62511 invoked by uid 99); 21 Aug 2006 03:39:50 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 20 Aug 2006 20:39:50 -0700 X-ASF-Spam-Status: No, hits=0.5 required=10.0 tests=DNS_FROM_RFC_ABUSE,HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: domain of clinton.begin@gmail.com designates 66.249.92.174 as permitted sender) Received: from [66.249.92.174] (HELO ug-out-1314.google.com) (66.249.92.174) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 20 Aug 2006 20:39:49 -0700 Received: by ug-out-1314.google.com with SMTP id m2so1547882ugc for ; Sun, 20 Aug 2006 20:39:27 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; b=bQyhS21h6H40TUbWczyUDKoQD9JEg3tMm6calPVR2AwtN2C7rMs4vSAzx0UdHo6dF7nhv3jqHKCLyKNDl6EqB6B7xbwDWggmxoEScBSfA6Rlrw37/9Gt/XwqBHJ83BCnFAmS+GSVjqwRGA2ILFILOng2GtTWwKRHrYFKhsdy46U= Received: by 10.66.242.20 with SMTP id p20mr3309523ugh; Sun, 20 Aug 2006 20:39:27 -0700 (PDT) Received: by 10.67.105.16 with HTTP; Sun, 20 Aug 2006 20:39:27 -0700 (PDT) Message-ID: <16178eb10608202039k716bcba6l563dc4804a55cfd1@mail.gmail.com> Date: Sun, 20 Aug 2006 21:39:27 -0600 From: "Clinton Begin" To: user-java@ibatis.apache.org Subject: Re: Updating from ibatis 1.3.1 to 2.1.7 .. should I? Does it worth the effort?: ... NullPointerException. It look like a bug ... In-Reply-To: <44E5B206.1040901@siunik.com> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_42237_28855902.1156131567841" References: <44E06DCF.5090702@siunik.com> <2f55db670608140828n7d3bd31dp8190943f0926257c@mail.gmail.com> <2f55db670608140829sf62c34ck1a38be8f96ace465@mail.gmail.com> <16178eb10608140901q24f0bb08y28b32db822398edf@mail.gmail.com> <44E0B226.1010703@siunik.com> <16178eb10608141708w1a42bd95od1d563b8b04f25fb@mail.gmail.com> <44E315CC.6000608@siunik.com> <44E5B206.1040901@siunik.com> X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N ------=_Part_42237_28855902.1156131567841 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline Try 2.2.0 if you haven't already... Might be a bug we've already fixed. Cheers, Clinton On 8/18/06, David Gagnon wrote: > > Hi all, > > I'm pretty sure this is a session problem. But there is an obscur > point that look to me like a bug. It's surely not one though. > > Trying to make the problem simple: > > On the same http request (so same thread) the following function #1 is > called followed by another. When the fynally is excuted from Function > #1. The sessionScope get reseted and put back into the pool! But it's > not removed from SqlMapSessionImpl!! > When function #2 is called it grab the same SqlMapSessionImpl with the > reseted SessionScope and that lead me to a NullPointerException. > > I suppose my problem is simple to fix .. tanks for your help! That will > bring me one step far in my upgrade process! > Best Regards > > > /David > > > > > > Function #1 > ------------ > public Object getObject(DbConnection dbCon, String mapKey, Object > param, boolean mustFind) throws DatabaseException, SQLException { > > Object result = null; > boolean handleTransactionLocally = false; > try { > if (dbCon == null) { > handleTransactionLocally = true; > dbCon = connectionFactory.getConnection(); > // TODO: check if that really usefull > dbCon.setReadOnlyConnection(true); > } > > // MappedStatement statement = sqlMap.getMappedStatement > (mapKey); > // result = > statement.executeQueryForObject(dbCon.getConnection(), param); > > sqlMap.setUserConnection(dbCon.getConnection()); > result = sqlMap.queryForObject(mapKey, param); > > if ((result == null) && (mustFind)) { > throw new DataNotFoundException("Object not found for > param: (" + param.toString() + ")"); > } > } catch (SQLException e) { > if (handleTransactionLocally) { > > ExceptionAdaptor.instance(exceptionAdaptorKey).getMappedException(e, > "Unable to get: " + e.getMessage(), true, > ExceptionAdaptor.ACTION_SEARCH, param); > } else { > throw e; > } > } finally { > sqlMap.setUserConnection(null); > if (dbCon != null) > dbCon.closeAll(handleTransactionLocally); > } > return result; > > } > #Function 2 > ------- > public final SearchResult getListDynamicWithRowCount(String mapKey, > String rowCountMapKey, Map param) throws DatabaseException { > PaginatedList paginatedList = null; > Integer nbRows = new Integer(-1); > Integer pageSize = null; > try { > paginatedList = sqlMap.queryForPaginatedList(mapKey, param, > pageSize.intValue()); > > > } catch (SQLException e) { > // log.error("Error during sql: " + e.getMessage(), e); > > ExceptionAdaptor.instance(exceptionAdaptorKey).getMappedException(e, > "getList: " + e.getMessage(), true, ExceptionAdaptor.ACTION_SEARCH, > param); > } > > return new SearchResult(paginatedList, nbRows.intValue()); > } > > > Exception: > java.lang.NullPointerException > at > com.ibatis.sqlmap.engine.mapping.statement.PaginatedDataList.getList( > PaginatedDataList.java:138) > at > com.ibatis.sqlmap.engine.mapping.statement.PaginatedDataList.pageTo( > PaginatedDataList.java:98) > at > com.ibatis.sqlmap.engine.mapping.statement.PaginatedDataList.( > PaginatedDataList.java:46) > at > com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForPaginatedList > (SqlMapExecutorDelegate.java:667) > at > com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.queryForPaginatedList( > SqlMapSessionImpl.java:109) > at > com.ibatis.sqlmap.engine.impl.SqlMapClientImpl.queryForPaginatedList( > SqlMapClientImpl.java:86) > at > com.davecorp.webos.dao.DaoSupport.getListDynamicWithRowCount( > DaoSupport.java:205) > at > com.davecorp.webos.dao.DaoSupport.getListDynamicWithRowCount( > DaoSupport.java:189) > at > com.unik.unikommerce.dao.resource.UkResourceDaoImpl.getResourceListDynamic > (UkResourceDaoImpl.java:585) > at > > com.unik.unikommerce.dao.resource.UkResourceDaoCachedImpl.getResourceListDynamic > (UkResourceDaoCachedImpl.java:315) > at > > com.unik.unikommerce.managers.InitUnikommerceApplicationManagerImpl.configureUserSession > (InitUnikommerceApplicationManagerImpl.java:50) > at > > com.davecorp.webos.struts.WindowEnabledRequestProcessor.processRequestSetup > (WindowEnabledRequestProcessor.java:265) > at > com.davecorp.webos.struts.WindowEnabledRequestProcessor.process( > WindowEnabledRequestProcessor.java:113) > at > org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482) > at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java > :525) > at javax.servlet.http.HttpServlet.service(HttpServlet.java:709) > at javax.servlet.http.HttpServlet.service(HttpServlet.java:802) > at > org.apache.catalina.core.ApplicationFilterChain.internalDoFilter( > ApplicationFilterChain.java:252) > at > org.apache.catalina.core.ApplicationFilterChain.doFilter( > ApplicationFilterChain.java:173) > at > com.davecorp.webos.servlet.SetCharacterEncodingFilter.doFilter( > SetCharacterEncodingFilter.java:141) > at > org.apache.catalina.core.ApplicationFilterChain.internalDoFilter( > ApplicationFilterChain.java:202) > at > org.apache.catalina.core.ApplicationFilterChain.doFilter( > ApplicationFilterChain.java:173) > at > org.apache.catalina.core.StandardWrapperValve.invoke( > StandardWrapperValve.java:213) > at > org.apache.catalina.core.StandardContextValve.invoke( > StandardContextValve.java:178) > at > org.apache.catalina.authenticator.AuthenticatorBase.invoke( > AuthenticatorBase.java:524) > at > org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java > :126) > at > org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java > :105) > at > org.apache.catalina.core.StandardEngineValve.invoke( > StandardEngineValve.java:107) > at > org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java > :148) > at > org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869) > at > > org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection > (Http11BaseProtocol.java:664) > at > org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket( > PoolTcpEndpoint.java:527) > at > org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt( > LeaderFollowerWorkerThread.java:80) > at > org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run( > ThreadPool.java:684) > at java.lang.Thread.run(Unknown Source) > > > > #Function from SqlMapSessionImpl > > private SqlMapSessionImpl getLocalSqlMapSession() { > SqlMapSessionImpl sqlMapSession = (SqlMapSessionImpl) > localSqlMapSession.get(); > if (sqlMapSession == null || sqlMapSession.isClosed()) { > sqlMapSession = new SqlMapSessionImpl(this); > localSqlMapSession.set(sqlMapSession); > } > return sqlMapSession; > } > > > > > > ------=_Part_42237_28855902.1156131567841 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline
Try 2.2.0 if you haven't already...

Might be a bug we've already fixed. 

Cheers,
Clinton

On 8/18/06, David Gagnon < dgagnon@siunik.com> wrote:
Hi all,

  I'm pretty sure this is a session problem.  But there is an obscur
point that look to me like a bug.  It's surely not one though.

Trying to make the problem simple:

On the same http request (so same thread) the following function #1 is
called followed by another.  When the fynally is excuted from Function
#1.  The sessionScope get reseted and put back into the pool!  But it's
not removed from SqlMapSessionImpl!!
When function #2 is called it grab the same SqlMapSessionImpl with the
reseted SessionScope and that lead me to a NullPointerException.

I suppose my problem is simple to fix .. tanks for your help!  That will
bring me one step far in my upgrade process!
Best Regards


/David





Function #1
------------
public Object getObject(DbConnection dbCon, String mapKey, Object
param, boolean mustFind) throws DatabaseException, SQLException {

        Object result = null;
        boolean handleTransactionLocally = false;
        try {
            if (dbCon == null) {
                handleTransactionLocally = true;
                dbCon = connectionFactory.getConnection();
                // TODO: check if that really usefull
                dbCon.setReadOnlyConnection(true);
            }

//            MappedStatement statement = sqlMap.getMappedStatement(mapKey);
//            result =
statement.executeQueryForObject(dbCon.getConnection(), param);

            sqlMap.setUserConnection(dbCon.getConnection());
            result = sqlMap.queryForObject (mapKey, param);

            if ((result == null) && (mustFind)) {
                throw new DataNotFoundException("Object not found for
param: (" + param.toString() + ")");
            }
        } catch (SQLException e) {
            if (handleTransactionLocally) {

ExceptionAdaptor.instance(exceptionAdaptorKey).getMappedException(e,
"Unable to get: " + e.getMessage(), true,
ExceptionAdaptor.ACTION_SEARCH , param);
            } else {
                throw e;
            }
        } finally {
            sqlMap.setUserConnection(null);
            if (dbCon != null)
            dbCon.closeAll(handleTransactionLocally);
        }
        return result;

    }
#Function 2
-------
public final SearchResult getListDynamicWithRowCount(String mapKey,
String rowCountMapKey, Map param) throws DatabaseException {
        PaginatedList paginatedList = null;
        Integer nbRows = new Integer(-1);
        Integer pageSize = null;
        try {
            paginatedList = sqlMap.queryForPaginatedList(mapKey, param,
pageSize.intValue());


        } catch (SQLException e) {
//            log.error("Error during sql: " + e.getMessage(), e);

ExceptionAdaptor.instance(exceptionAdaptorKey).getMappedException(e,
"getList: " + e.getMessage(), true, ExceptionAdaptor.ACTION_SEARCH , param);
        }

        return new SearchResult(paginatedList, nbRows.intValue());
    }


Exception:
java.lang.NullPointerException
    at
com.ibatis.sqlmap.engine.mapping.statement.PaginatedDataList.getList (PaginatedDataList.java:138)
    at
com.ibatis.sqlmap.engine.mapping.statement.PaginatedDataList.pageTo(PaginatedDataList.java:98)
    at
com.ibatis.sqlmap.engine.mapping.statement.PaginatedDataList.<init>( PaginatedDataList.java:46)
    at
com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForPaginatedList(SqlMapExecutorDelegate.java:667)
    at
com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.queryForPaginatedList (SqlMapSessionImpl.java:109)
    at
com.ibatis.sqlmap.engine.impl.SqlMapClientImpl.queryForPaginatedList(SqlMapClientImpl.java:86)
    at
com.davecorp.webos.dao.DaoSupport.getListDynamicWithRowCount(DaoSupport.java :205)
    at
com.davecorp.webos.dao.DaoSupport.getListDynamicWithRowCount(DaoSupport.java:189)
    at
com.unik.unikommerce.dao.resource.UkResourceDaoImpl.getResourceListDynamic(UkResourceDaoImpl.java:585)
    at
com.unik.unikommerce.dao.resource.UkResourceDaoCachedImpl.getResourceListDynamic(UkResourceDaoCachedImpl.java:315)
    at
com.unik.unikommerce.managers.InitUnikommerceApplicationManagerImpl.configureUserSession( InitUnikommerceApplicationManagerImpl.java:50)
    at
com.davecorp.webos.struts.WindowEnabledRequestProcessor.processRequestSetup(WindowEnabledRequestProcessor.java:265)
    at
com.davecorp.webos.struts.WindowEnabledRequestProcessor.process (WindowEnabledRequestProcessor.java:113)
    at
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
    at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
    at javax.servlet.http.HttpServlet.service (HttpServlet.java:709)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
    at
org.apache.catalina.core.ApplicationFilterChain.doFilter (ApplicationFilterChain.java:173)
    at
com.davecorp.webos.servlet.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:141)
    at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter (ApplicationFilterChain.java:202)
    at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
    at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java :213)
    at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
    at
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:524)
    at
org.apache.catalina.core.StandardHostValve.invoke (StandardHostValve.java:126)
    at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
    at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
    at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
    at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
    at
org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection (Http11BaseProtocol.java:664)
    at
org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
    at
org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java :80)
    at
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
    at java.lang.Thread.run(Unknown Source)



#Function from SqlMapSessionImpl

private SqlMapSessionImpl getLocalSqlMapSession() {
    SqlMapSessionImpl sqlMapSession = (SqlMapSessionImpl)
localSqlMapSession.get();
    if (sqlMapSession == null || sqlMapSession.isClosed()) {
      sqlMapSession = new SqlMapSessionImpl(this);
      localSqlMapSession.set (sqlMapSession);
    }
    return sqlMapSession;
  }






------=_Part_42237_28855902.1156131567841--