ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chris.mccau...@gsa.gov
Subject RE: TransactionManager thorowing NPE
Date Tue, 21 Aug 2007 19:12:26 GMT
Well, bcak to it:
<CODE>
                //TEST
                DataSource dataSource = null;
                try{
                        Context initContext = new InitialContext();
                        dataSource = (DataSource) initContext.lookup(
"java:REALNAME");
                } catch (NamingException ne){
                        ne.printStackTrace();
                        System.out.println("  NamingException: " + 
ne.getMessage());
                }
 
                System.out.println("  dataSource: " + dataSource);
</CODE>

This test returns : 2007-08-21 15:08:25,852 INFO  [STDOUT]   dataSource: 
org.jboss.resource.adapter.jdbc.WrapperDataSource@1d4ee7e

So I got that goin' for me.....

Still get the NPE.....

 Caused by: java.lang.NullPointerException
2007-08-21 15:08:26,733 INFO  [STDOUT]  at 
com.ibatis.dao.engine.impl.StandardDaoManager.getTransaction(StandardDaoManager.java:108)
2007-08-21 15:08:26,733 INFO  [STDOUT]  at 
com.ibatis.dao.client.template.SqlMapDaoTemplate.getSqlMapExecutor(SqlMapDaoTemplate.java:60)
2007-08-21 15:08:26,733 INFO  [STDOUT]  at 
com.ibatis.dao.client.template.SqlMapDaoTemplate.delete(SqlMapDaoTemplate.java:142)
2007-08-21 15:08:26,733 INFO  [STDOUT]  at 
gov.gsa.base.dao.SqlMapDaoTemplateWrapper.delete(SqlMapDaoTemplateWrapper.java:41)
2007-08-21 15:08:26,733 INFO  [STDOUT]  ... 25 more
2007-08-21 15:08:26,733 INFO  [STDOUT] gov.gsa.base.exception.DAOException 
: java.lang.NullPointerException
2007-08-21 15:08:26,733 INFO  [STDOUT]  RemoveAttachmentServlet returning.









Ack, I hate NPEs, they're so embarrassing.  iBATIS should never throw one.
Once we find out why it does in this case, we'll fix it. 

The most likely source is this:   "java:DATASOURCE"

Make sure this works in your environment:

   DataSource dataSource = (DataSource) initCtx.lookup("java:DATASOURCE");

Clinton

-----Original Message-----
From: Christopher Lamey [mailto:clamey@localmatters.com] 
Sent: August-16-07 8:43 AM
To: user-java@ibatis.apache.org
Subject: Re: TransactionManager thorowing NPE

Well, that looks ok.

Could the transaction be closed or committed early, before the delete?

On 8/16/07 6:12 AM, "chris.mccauley@gsa.gov" <chris.mccauley@gsa.gov> 
wrote:

> Pretty straight forward....I assume we are using some default 
Transaction
> Manager..
> 
> <?xml version="1.0" encoding="UTF-8" ?>
> <!DOCTYPE sqlMapConfig PUBLIC "-//ibatis.apache.org//DTD SQL Map Config
> 2.0//EN" "http://ibatis.apache.org/dtd/sql-map-config-2.dtd">
> <sqlMapConfig>
>     <settings useStatementNamespaces="false" />
> 
>     <!-- JNDI Example -->
>         <transactionManager type="JDBC">
>                 <dataSource type="JNDI">
>                         <property name="DBJndiContext" value=
> "java:DATASOURCE"/>
>                 </dataSource>
>         </transactionManager>
> 
>         <sqlMap resource="dao/File1.xml" />
>         <sqlMap resource="dao/File2.xml" />
>         <sqlMap resource="dao/File3.xml" />
> </sqlMapConfig>
> 
> 
> 
> Thank you, 
> Christopher
> 
> 
> 
> 
> What does your transaction configuration look like?  What transaction
> manager are you using?
> 
> 
> On 8/15/07 3:28 PM, "chris.mccauley@gsa.gov" <chris.mccauley@gsa.gov>
> wrote:
> 
>> 
>> I am accessing a servlet ( within same app context) with an asynch call
> from a
>> struts app.  Part of the work is a database call (delete) usig iBatis
> SQLMap.
>> 
>> We have no issues with iBatis prior, (except performance, but thats a
>> different thread :>) )
>> 
>> Seems like a Transaction issue? Any ideas?
>> 
>> gov.gsa.base.exception.DAOException: java.lang.NullPointerException
>> at gov.gsa.base.dao.SqlMapDaoTemplateWrapper.delete(Unknown Source)
>> at 
>> 
>
gov.gsa.base.service.file.SQLMapAttachmentDAOImpl.deleteSRCVisitAttachment(U
nk
>> nown Source) 
>> at 
> gov.gsa.base.service.file.AttachmentService.deleteSRCAttachment(Unknown
>> Source) 
>> at gov.gsa.base.servlet.RemoveAttachment.doGet(Unknown Source)
>> at javax.servlet.http.HttpServlet.service(HttpServlet.java:697)
>> at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
>> at 
>> 
>
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application
Fi
>> lterChain.java:252)
>> at 
>> 
>
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh
ai
>> n.java:173) 
>> at 
>> 
>
org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.ja
va
>> :81) 
>> at 
>> 
>
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application
Fi
>> lterChain.java:202)
>> at 
>> 
>
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh
ai
>> n.java:173) 
>> at 
>> 
>
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.ja
va
>> :213) 
>> at 
>> 
>
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.ja
va
>> :178) 
>> at 
>> 
>
org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalVal
ve
>> .java:39) 
>> at 
>> 
>
org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssoci
at
>> ionValve.java:159)
>> at 
>> 
>
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase
.j
>> ava:407) 
>> at 
>> 
>
org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:
59
>> ) 
>> 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
:1
>> 07) 
>> at 
>
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
>> at 
> 
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
>> at 
>> 
>
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConne
ct
>> ion(Http11Protocol.java:744)
>> at 
>> 
>
org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.jav
a:
>> 527) 
>> at 
>> 
>
org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThre
ad
>> .java:112) 
>> at java.lang.Thread.run(Thread.java:595)
>> Caused by: java.lang.NullPointerException
>> at 
>> 
>
com.ibatis.dao.engine.impl.StandardDaoManager.getTransaction(StandardDaoMana
ge
>> r.java:108) 
>> at 
>> 
>
com.ibatis.dao.client.template.SqlMapDaoTemplate.getSqlMapExecutor(SqlMapDao
Te
>> mplate.java:60) 
>> at 
>> 
>
com.ibatis.dao.client.template.SqlMapDaoTemplate.delete(SqlMapDaoTemplate.ja
va
>> :142) 
>> ... 26 more 
>>  gov.gsa.base.exception.DAOException : java.lang.NullPointerException
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> Thank you, 
>> Christopher
>> 
>> ~~~~~~~~~~~~~~~~~
>> Christopher McCauley
>> Unisys Consultant
>> GSA - Federal Acquisition Service
>> CP3 11028B
>> (703) 605 9160
>> chris.mccauley@gsa.gov
>> chris.mccauley@unisys.com
> 
> 
> 
> 




Mime
View raw message