Return-Path: Delivered-To: apmail-ibatis-user-java-archive@www.apache.org Received: (qmail 57315 invoked from network); 18 Aug 2006 20:22:04 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 18 Aug 2006 20:22:04 -0000 Received: (qmail 97580 invoked by uid 500); 18 Aug 2006 20:22:02 -0000 Delivered-To: apmail-ibatis-user-java-archive@ibatis.apache.org Received: (qmail 97566 invoked by uid 500); 18 Aug 2006 20:22:02 -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 97555 invoked by uid 99); 18 Aug 2006 20:22:02 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 18 Aug 2006 13:22:02 -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 jeffgbutler@gmail.com designates 66.249.92.170 as permitted sender) Received: from [66.249.92.170] (HELO ug-out-1314.google.com) (66.249.92.170) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 18 Aug 2006 13:22:00 -0700 Received: by ug-out-1314.google.com with SMTP id m2so1035940ugc for ; Fri, 18 Aug 2006 13:21:38 -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=tCf27tQr49jBApgRQv8GsThv+qt0fLZZlZMeh5kRT3VIMlY7q4u2usHhdq2h1M682CYTCi2a1ji242O6Mmt601WfV3syUCNPB82/T8caBSZcpBiVr++5vi7lgkWD6Apfx9p5jBxNA026GTbhltLiYkJrpwvZe9aFG/lT97jdGrk= Received: by 10.66.216.6 with SMTP id o6mr1998924ugg; Fri, 18 Aug 2006 13:21:38 -0700 (PDT) Received: by 10.66.221.15 with HTTP; Fri, 18 Aug 2006 13:21:37 -0700 (PDT) Message-ID: Date: Fri, 18 Aug 2006 15:21:38 -0500 From: "Jeff Butler" To: user-java@ibatis.apache.org Subject: Re: Updating from ibatis 1.3.1 to 2.1.7 .. should I? NullPointerException. It look like a bug ... (More info on the bug) Please confirm:-) In-Reply-To: <5820E7E2A928DB46824297946AC2024A9A5F62@pandore.ircm.priv> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_5820_26264977.1155932497996" References: <5820E7E2A928DB46824297946AC2024A9A5F62@pandore.ircm.priv> X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N ------=_Part_5820_26264977.1155932497996 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline I personally doubt you need to manage database connections at all since iBatis will create one for you. +1 Is there some reason you're not letting iBATIS manage the connections and transactions? Seems like you are going through a lot of extra and unneccessary work, and I'm not sure what the benefit could be. Jeff Butler On 8/18/06, Poitras Christian wrote: > > Sorry, but I am trying to guess your problem... I never used iBatis > version 1.X. > > I personally doubt you need to manage database connections at all since > iBatis will create one for you if you use the Dao package (or Spring > will do it). > > If you open your database connection manually, then this is going to be > a problem. Maybe 2.2 has a fix. Or maybe you should use Dao (if you not > doing so). > > Christian > > -----Original Message----- > From: David Gagnon [mailto:dgagnon@siunik.com] > Sent: Friday, 18 August 2006 15:47 > To: user-java@ibatis.apache.org > Subject: Re: Updating from ibatis 1.3.1 to 2.1.7 .. should I? > NullPointerException. It look like a bug ... (More info on the bug) > Please confirm:-) > > Hi Christian, > > In fact I don`t want to close them. Here is the generic code used to > get the info of a User: > > 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(); > } > > 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; > > } > > The only thing I do is supply the connection to use to ibatis. This > way I can enclose the call in a transaction or not. From what I got > from Clinton it`s the way to do it. But if you trace with the debugger > into the sqlMap.setUserConnection(null) method you will see that the > state of the object is not OK at the end. > > In fact since a single http request can imply the use of lot of > different DAOs I will have this method called more than once... > > I read what you post but it seems to refer to a ping to test that the > connection to the db is up. I'm not sure I understand how it`s related > to my problem. If I'm wrong please tell me. I just want to find an > answer to my current problem! > > Best regars > /David > > Poitras Christian wrote: > > I don't think you should try setting and ressetting connection > manually. > > > > If you want to reset connections (close/open), use these settings in > > sql-map-config file (under ). > > > > > > > name="Pool.PingConnectionsOlderThan"/> > > Then set these properties in the properties file referenced by this > > tag in sql-map-config file. > > > > > > Unless iBatis does something really nasty (probably due to JDBC driver > > > and not iBatis) or against what your database expects, you should not > > use these objects. > > I run iBatis from version 2.1 and I have never seen the use of these > > objects. > > > > Christian > > > > -----Original Message----- > > From: David Gagnon [mailto:dgagnon@siunik.com] > > Sent: Friday, 18 August 2006 15:06 > > To: user-java@ibatis.apache.org > > Subject: Re: Updating from ibatis 1.3.1 to 2.1.7 .. should I? > > NullPointerException. It look like a bug ... (More info on the bug) > > Please confirm:-) > > > > Hi all > > > > Since I haven't hear from you .. I dig more trying to find what wrong > > or what I did wrong and I just get more evidence that is a bug and it > > seems to be a major one? Since it`s the first time I use this version > > > of ibatis and since it`s really basic I do think it`s because I'm > > missing something obvious but I have no idea. Please look at what I > have found: > > > > on the 1 call the following constructor is called: public > > SqlMapSessionImpl(ExtendedSqlMapClient client). This initialize the > > SessionScope object i.e: setting the sqlMapExecutor, etc.. > > > > When my code calls: sqlMap.setUserConnection(null); this method should > > > reset the connection. But in fact the state of the SqlMapSessionImpl > > associated with the current thread is compromised because this > > setUserConnection has reseted the sessionScope object (See > > SqlMapExecutorDelegate.setUserProvidedTransaction()) associated with > > this SqlMapSessionImpl and put It back into the pool. BUT the > > sessionScope is still into the SqlMapSessionImpl (and the > > SqlMapSessionImpl is still Not closed). > > > > When I another call the SqlMapSessionImpl will be reused with the > > sessionScope object that have been reseted: I can see the > > sqlMapExecutor set to null witch is not the case with the first call. > > > > From there the bug will occurs only if the sqlMapExecutor is > involved. > > > > In fact this is still unclear to me but I tried calling 2 times the > > same line of code that calls sqlMap.queryForObject(mapKey, param); But > > > without error. Is the sqlMapExecutor is involved? Does another > > sqlMapExecutor is used? I have no Idea. > > > > To reproduce the bug you must use the sqlMap.queryForPaginatedList > > method the second time. You will get the NullPointerException because > > > theSessionScope.sqlMapExecutor is NULL. > > > > In fact if you use the debugger an trace the SqlMapClientImpl object > > > > private SqlMapSessionImpl getLocalSqlMapSession() { > > SqlMapSessionImpl sqlMapSession = (SqlMapSessionImpl) > > localSqlMapSession.get(); > > if (sqlMapSession == null || sqlMapSession.isClosed()) { > > sqlMapSession = new SqlMapSessionImpl(this); > > localSqlMapSession.set(sqlMapSession); > > } > > return sqlMapSession; > > } > > > > between the 1 and second call you will that the SessionScope object > > is not consistent. > > > > Hope that help. Like I said since I'm upgrading and don`t know well > > this version of ibatis I don`t really know what is the best approch to > > > fix my problem. Any help is welcome. > > > > Best Regards > > /David > > > > 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( > >> P > >> aginatedDataList.java:138) > >> > >> at > >> com.ibatis.sqlmap.engine.mapping.statement.PaginatedDataList.pageTo(P > >> a > >> ginatedDataList.java:98) > >> > >> at > >> com.ibatis.sqlmap.engine.mapping.statement.PaginatedDataList.(P > >> a > >> ginatedDataList.java:46) > >> > >> at > >> com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForPaginate > >> d > >> List(SqlMapExecutorDelegate.java:667) > >> > >> at > >> com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.queryForPaginatedList > >> ( > >> SqlMapSessionImpl.java:109) > >> > >> at > >> com.ibatis.sqlmap.engine.impl.SqlMapClientImpl.queryForPaginatedList( > >> S > >> qlMapClientImpl.java:86) > >> > >> at > >> com.davecorp.webos.dao.DaoSupport.getListDynamicWithRowCount(DaoSuppo > >> r > >> t.java:205) > >> > >> at > >> com.davecorp.webos.dao.DaoSupport.getListDynamicWithRowCount(DaoSuppo > >> r > >> t.java:189) > >> > >> at > >> com.unik.unikommerce.dao.resource.UkResourceDaoImpl.getResourceListDy > >> n > >> amic(UkResourceDaoImpl.java:585) > >> > >> at > >> com.unik.unikommerce.dao.resource.UkResourceDaoCachedImpl.getResource > >> L > >> istDynamic(UkResourceDaoCachedImpl.java:315) > >> > >> at > >> com.unik.unikommerce.managers.InitUnikommerceApplicationManagerImpl.c > >> o > >> nfigureUserSession(InitUnikommerceApplicationManagerImpl.java:50) > >> > >> at > >> com.davecorp.webos.struts.WindowEnabledRequestProcessor.processReques > >> t > >> Setup(WindowEnabledRequestProcessor.java:265) > >> > >> at > >> com.davecorp.webos.struts.WindowEnabledRequestProcessor.process(Windo > >> w > >> EnabledRequestProcessor.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(Appl > >> i > >> cationFilterChain.java:252) > >> > >> at > >> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF > >> i > >> lterChain.java:173) > >> > >> at > >> com.davecorp.webos.servlet.SetCharacterEncodingFilter.doFilter(SetCha > >> r > >> acterEncodingFilter.java:141) > >> > >> at > >> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl > >> i > >> cationFilterChain.java:202) > >> > >> at > >> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF > >> i > >> lterChain.java:173) > >> > >> at > >> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV > >> a > >> lve.java:213) > >> > >> at > >> org.apache.catalina.core.StandardContextValve.invoke(StandardContextV > >> a > >> lve.java:178) > >> > >> at > >> org.apache.catalina.authenticator.AuthenticatorBase.invoke(Authentica > >> t > >> orBase.java:524) > >> > >> at > >> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j > >> a > >> va:126) > >> > >> at > >> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j > >> a > >> va:105) > >> > >> at > >> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal > >> v > >> e.java:107) > >> > >> at > >> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.jav > >> a > >> :148) > >> > >> at > >> > org.apache.coyote.http11.Http11Processor.process(Http11Processor.java: > >> 869) > >> > >> at > >> org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.p > >> r > >> ocessConnection(Http11BaseProtocol.java:664) > >> > >> at > >> org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpo > >> i > >> nt.java:527) > >> > >> at > >> org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFol > >> l > >> owerWorkerThread.java:80) > >> > >> at > >> org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadP > >> o > >> ol.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_5820_26264977.1155932497996 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline
<quote>
I personally doubt you need to manage database connections at all since iBatis will create one for you.
</quote>
 
+1
 
Is there some reason you're not letting iBATIS manage the connections and transactions?  Seems like you are going through a lot of extra and unneccessary work, and I'm not sure what the benefit could be.
 
Jeff Butler

 
On 8/18/06, Poitras Christian <Christian.Poitras@ircm.qc.ca> wrote:
Sorry, but I am trying to guess your problem... I never used iBatis
version 1.X.

I personally doubt you need to manage database connections at all since
iBatis will create one for you if you use the Dao package (or Spring
will do it).

If you open your database connection manually, then this is going to be
a problem. Maybe 2.2 has a fix. Or maybe you should use Dao (if you not
doing so).

Christian

-----Original Message-----
From: David Gagnon [mailto:dgagnon@siunik.com]
Sent: Friday, 18 August 2006 15:47
To: user-java@ibatis.apache.org
Subject: Re: Updating from ibatis 1.3.1 to 2.1.7 .. should I?
NullPointerException. It look like a bug ... (More info on the bug)
Please confirm:-)

Hi Christian,

In fact I don`t want to close them.  Here is the generic code used to
get the info of a User:

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();
           }

           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;

   }

The only thing I do is supply the connection to use to ibatis.  This
way I can enclose the call in a transaction or not.  From what I got
from Clinton it`s the way to do it.  But if you trace with the debugger
into the sqlMap.setUserConnection(null) method you will see that the
state of the object is not OK at the end.

In fact since a single http request can imply the use of lot of
different DAOs I will have this method called more than once...

I read what you post but it seems to refer to a ping to test that the
connection to the db is up.  I'm not sure I understand how it`s related
to my problem.  If I'm wrong please tell me.  I just want to find an
answer to my current problem!

Best regars
/David

Poitras Christian wrote:
> I don't think you should try setting and ressetting connection
manually.
>
> If you want to reset connections (close/open), use these settings in
> sql-map-config file (under <transactionManager><dataSource>).
>             <property value="${pingquery}" name="Pool.PingQuery"/>
>             <property value="${pingenable}" name="Pool.PingEnabled"/>
>             <property value="${pingoldertime}"
> name="Pool.PingConnectionsOlderThan"/>
> Then set these properties in the properties file referenced by this
> tag in sql-map-config file.
> <properties resource="database.properties "/>
>
> Unless iBatis does something really nasty (probably due to JDBC driver

> and not iBatis) or against what your database expects, you should not
> use these objects.
> I run iBatis from version 2.1 and I have never seen the use of these
> objects.
>
> Christian
>
> -----Original Message-----
> From: David Gagnon [mailto:dgagnon@siunik.com ]
> Sent: Friday, 18 August 2006 15:06
> To: user-java@ibatis.apache.org
> Subject: Re: Updating from ibatis 1.3.1 to 2.1.7 .. should I?
> NullPointerException. It look like a bug ... (More info on the bug)
> Please confirm:-)
>
> Hi all
>
> Since I haven't hear from you .. I dig more trying to find what wrong
> or what I did wrong and I just get more evidence that is a bug and it
> seems to be a major one?  Since it`s the first time I use this version

> of ibatis and since it`s really basic I do think it`s because I'm
> missing something obvious but I have no idea.  Please look at what I
have found:
>
> on the 1 call the following constructor is called: public
> SqlMapSessionImpl(ExtendedSqlMapClient client).  This initialize the
> SessionScope object i.e: setting the sqlMapExecutor, etc..
>
> When my code calls: sqlMap.setUserConnection(null); this method should

> reset the connection.  But in fact the state of the SqlMapSessionImpl
> associated with the current thread is compromised because this
> setUserConnection has reseted the sessionScope object (See
> SqlMapExecutorDelegate.setUserProvidedTransaction()) associated with
> this SqlMapSessionImpl and put It back into the pool.  BUT the
> sessionScope is still into the SqlMapSessionImpl (and the
> SqlMapSessionImpl is still Not closed).
>
> When I another call the SqlMapSessionImpl will be reused with the
> sessionScope object that have been reseted: I can see the
> sqlMapExecutor set to null witch is not the case with the first call.
>
>  From there the bug will occurs only if the sqlMapExecutor is
involved.
>
> In fact this is still unclear to me but I tried calling 2 times the
> same line of code that calls sqlMap.queryForObject (mapKey, param); But

> without error.  Is the sqlMapExecutor is involved?  Does another
> sqlMapExecutor is used?  I have no Idea.
>
> To reproduce the bug you must use the sqlMap.queryForPaginatedList
> method the second time.  You will get the NullPointerException because

> theSessionScope.sqlMapExecutor is NULL.
>
> In fact if you use the debugger an trace the SqlMapClientImpl object
>
>  private SqlMapSessionImpl getLocalSqlMapSession() {
>     SqlMapSessionImpl sqlMapSession = (SqlMapSessionImpl)
> localSqlMapSession.get();
>     if (sqlMapSession == null || sqlMapSession.isClosed ()) {
>       sqlMapSession = new SqlMapSessionImpl(this);
>       localSqlMapSession.set(sqlMapSession);
>     }
>     return sqlMapSession;
>   }
>
>  between the 1 and second call you will that the SessionScope object
> is not consistent.
>
> Hope that help.  Like I said since I'm upgrading and don`t know well
> this version of ibatis I don`t really know what is the best approch to

> fix my problem.  Any help is welcome.
>
> Best Regards
> /David
>
> 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(
>> P
>> aginatedDataList.java:138)
>>
>>    at
>> com.ibatis.sqlmap.engine.mapping.statement.PaginatedDataList.pageTo (P
>> a
>> ginatedDataList.java:98)
>>
>>    at
>> com.ibatis.sqlmap.engine.mapping.statement.PaginatedDataList.<init>(P
>> a
>> ginatedDataList.java:46)
>>
>>    at
>> com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForPaginate
>> d
>> List(SqlMapExecutorDelegate.java:667)
>>
>>    at
>> com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.queryForPaginatedList
>> (
>> SqlMapSessionImpl.java:109)
>>
>>    at
>> com.ibatis.sqlmap.engine.impl.SqlMapClientImpl.queryForPaginatedList(
>> S
>> qlMapClientImpl.java:86)
>>
>>    at
>> com.davecorp.webos.dao.DaoSupport.getListDynamicWithRowCount(DaoSuppo
>> r
>> t.java:205)
>>
>>    at
>> com.davecorp.webos.dao.DaoSupport.getListDynamicWithRowCount (DaoSuppo
>> r
>> t.java:189)
>>
>>    at
>> com.unik.unikommerce.dao.resource.UkResourceDaoImpl.getResourceListDy
>> n
>> amic(UkResourceDaoImpl.java:585)
>>
>>    at
>> com.unik.unikommerce.dao.resource.UkResourceDaoCachedImpl.getResource
>> L
>> istDynamic(UkResourceDaoCachedImpl.java:315)
>>
>>    at
>> com.unik.unikommerce.managers.InitUnikommerceApplicationManagerImpl.c
>> o
>> nfigureUserSession(InitUnikommerceApplicationManagerImpl.java:50)
>>
>>    at
>> com.davecorp.webos.struts.WindowEnabledRequestProcessor.processReques
>> t
>> Setup(WindowEnabledRequestProcessor.java:265)
>>
>>    at
>> com.davecorp.webos.struts.WindowEnabledRequestProcessor.process(Windo
>> w
>> EnabledRequestProcessor.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 (Appl
>> i
>> cationFilterChain.java:252)
>>
>>    at
>> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
>> i
>> lterChain.java:173)
>>
>>    at
>> com.davecorp.webos.servlet.SetCharacterEncodingFilter.doFilter(SetCha
>> r
>> acterEncodingFilter.java:141)
>>
>>    at
>> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter (Appl
>> i
>> cationFilterChain.java:202)
>>
>>    at
>> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
>> i
>> lterChain.java:173)
>>
>>    at
>> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV
>> a
>> lve.java:213)
>>
>>    at
>> org.apache.catalina.core.StandardContextValve.invoke (StandardContextV
>> a
>> lve.java:178)
>>
>>    at
>> org.apache.catalina.authenticator.AuthenticatorBase.invoke(Authentica
>> t
>> orBase.java:524)
>>
>>    at
>> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j
>> a
>> va:126)
>>
>>    at
>> org.apache.catalina.valves.ErrorReportValve.invoke (ErrorReportValve.j
>> a
>> va:105)
>>
>>    at
>> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal
>> v
>> e.java:107)
>>
>>    at
>> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.jav
>> a
>> :148)
>>
>>    at
>>
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java :
>> 869)
>>
>>    at
>> org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.p
>> r
>> ocessConnection(Http11BaseProtocol.java:664)
>>
>>    at
>> org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpo
>> i
>> nt.java:527)
>>
>>    at
>> org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt (LeaderFol
>> l
>> owerWorkerThread.java:80)
>>
>>    at
>> org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadP
>> o
>> ol.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_5820_26264977.1155932497996--