NullPointerException - Method-Inline

1,859 views
Skip to first unread message

Alfiguer

unread,
Feb 9, 2012, 11:08:20 AM2/9/12
to mybatis-user
Hi,

I have the follow problem with myBatis 3.

NullPointerException Inline a method

Caused by: org.mybatis.spring.MyBatisSystemException: nested exception
is org.apache.ibatis.exceptions.PersistenceException:
### Error querying database. Cause: java.lang.NullPointerException
### The error may involve
ve.com.seguroscaracas.solidario.servicios.persistence.dao.InscritoDao.incluirInscrito-
Inline
### The error occurred while setting parameters
### Cause: java.lang.NullPointerException
at
org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:
73)
at org.mybatis.spring.SqlSessionTemplate
$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:358)
at $Proxy120.selectList(Unknown Source)
at
org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:
190)
at
ve.com.seguroscaracas.solidario.servicios.persistence.dao.InscritoDaoImpl.incluirInscrito(InscritoDaoImpl.java:
167)
... 36 more
Caused by: org.apache.ibatis.exceptions.PersistenceException:
### Error querying database. Cause: java.lang.NullPointerException
### The error may involve
ve.com.seguroscaracas.solidario.servicios.persistence.dao.InscritoDao.incluirInscrito-
Inline
### The error occurred while setting parameters
### Cause: java.lang.NullPointerException
at
org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:
8)
at
org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:
81)
at
org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:
73)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:
25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.mybatis.spring.SqlSessionTemplate
$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:350)
... 39 more
Caused by: java.lang.NullPointerException
at
org.apache.ibatis.executor.resultset.FastResultSetHandler.skipRows(FastResultSetHandler.java:
198)
at
org.apache.ibatis.executor.resultset.NestedResultSetHandler.handleRowValues(NestedResultSetHandler.java:
62)
at
org.apache.ibatis.executor.resultset.FastResultSetHandler.handleRefCursorOutputParameter(FastResultSetHandler.java:
86)
at
org.apache.ibatis.executor.resultset.FastResultSetHandler.handleOutputParameters(FastResultSetHandler.java:
60)
at
org.apache.ibatis.executor.statement.CallableStatementHandler.query(CallableStatementHandler.java:
44)
at
org.apache.ibatis.executor.statement.RoutingStatementHandler.query(RoutingStatementHandler.java:
55)
at
org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:
41)
at
org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:
243)
at
org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:117)
at
org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:
72)
at
org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:
79)

Eduardo

unread,
Feb 10, 2012, 1:16:50 AM2/10/12
to mybatis-user
More info here:
http://code.google.com/p/mybatis/issues/detail?id=511&can=1&q=seguroscaracas&colspec=ID%20Type%20Component%20Status%20Priority%20Version%20Tar
get%20Summary%20Reporter

Although I can not fix stored procedures exceptions there is something
wrong in the issue report. If your are using 3.0.6 then line 198 is
this one an, as you can see, it cannot trow a NPE

protected ResultSet getNextResultSet(Statement stmt) throws
SQLException {
// Making this method tolerant of bad JDBC drivers
try {
if
(stmt.getConnection().getMetaData().supportsMultipleResultSets()) {
// Crazy Standard JDBC way of determining if there are more
results
if (!((!stmt.getMoreResults()) && (stmt.getUpdateCount() ==
-1))) { <<---- NPE (line 198)
return stmt.getResultSet();
}
}
} catch (Exception e) { <<----- catched!!
// Intentionally ignored.
}
return null;
}

So please doble check your version or go latest 3.1.0-snapshot and try
again.

thanks in advance!

Alcides Figueroa

unread,
Feb 10, 2012, 8:57:39 AM2/10/12
to mybati...@googlegroups.com
Thank´s Eduardo.

I´ll try version 3.1.0-snapshot. I hope solve this problems.

2012/2/10 Eduardo <eduardo....@gmail.com>

Eduardo

unread,
Feb 10, 2012, 9:47:01 AM2/10/12
to mybatis-user
Could you try with the latest snapshot and post again the stacktrace.
It is important to know what exact line is the NPE arising from.

On 10 feb, 14:57, Alcides Figueroa <afi...@gmail.com> wrote:
> Thank´s Eduardo.
>
> I´ll try version 3.1.0-snapshot. I hope solve this problems.
>
> 2012/2/10 Eduardo <eduardo.macar...@gmail.com>
>
>
>
>
>
>
>
> > More info here:
>
> >http://code.google.com/p/mybatis/issues/detail?id=511&can=1&q=seguros...
> > get%20Summary%20Reporter<http://code.google.com/p/mybatis/issues/detail?id=511&can=1&q=seguros...>

Alcides Figueroa

unread,
Feb 16, 2012, 8:23:01 AM2/16/12
to mybati...@googlegroups.com
Hi,

Eduardo, i test mybatis-3.1.0-SNAPSHOT and mybatis-spring-1.1.0-SNAPSHOT to try to solve my problems ( (myDaoMethod-Inline, error occurred while setting parameters, java.lang.NullPointerException). but I get the following error:

 Error querying database.  Cause: java.sql.SQLException: Cursor is closed.
### The error may involve ve.com.seguroscaracas.infobasica.servicios.persistence.dao.CertificadoDao.consultarCertificado-Inline

### The error occurred while setting parameters
### Cause: java.sql.SQLException: Cursor is closed.
; uncategorized SQLException for SQL []; SQL state [null]; error code [0]; Cursor is closed.; nested exception is java.sql.SQLException: Cursor is closed.
    at ve.com.seguroscaracas.commons.servicios.exception.ManejadorExcepciones.manejar(ManejadorExcepciones.java:145)
    at ve.com.seguroscaracas.infobasica.servicios.persistence.dao.CertificadoDaoImpl.consultarCertificado(CertificadoDaoImpl.java:437)
    at ve.com.seguroscaracas.infobasica.servicios.persistence.dao.CertificadoDaoTest.testConsultarCertificado(CertificadoDaoTest.java:90)

    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
    at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74)
    at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:82)
    at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:72)
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:231)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
    at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
    at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:174)
    at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:234)
    at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:133)
    at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:114)

    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:188)
    at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:166)
    at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:86)
    at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:101)
    at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:74)
Caused by: org.springframework.jdbc.UncategorizedSQLException:
### Error querying database.  Cause: java.sql.SQLException: Cursor is closed.
### The error may involve ve.com.seguroscaracas.infobasica.servicios.persistence.dao.CertificadoDao.consultarCertificado-Inline

### The error occurred while setting parameters
### Cause: java.sql.SQLException: Cursor is closed.
; uncategorized SQLException for SQL []; SQL state [null]; error code [0]; Cursor is closed.; nested exception is java.sql.SQLException: Cursor is closed.
    at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:83)
    at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:80)
    at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:80)
    at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:71)
    at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:360)
    at $Proxy10.selectList(Unknown Source)
    at org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:190)
    at ve.com.seguroscaracas.infobasica.servicios.persistence.dao.CertificadoDaoImpl.consultarCertificado(CertificadoDaoImpl.java:181)
    ... 35 more
Caused by: java.sql.SQLException: Cursor is closed.
    at oracle.jdbc.driver.T4CResultSetAccessor.getCursor(T4CResultSetAccessor.java:354)
    at oracle.jdbc.driver.ResultSetAccessor.getObject(ResultSetAccessor.java:114)
    at oracle.jdbc.driver.OracleCallableStatement.getObject(OracleCallableStatement.java:4262)
    at oracle.jdbc.driver.OracleCallableStatementWrapper.getObject(OracleCallableStatementWrapper.java:908)

    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.ibatis.logging.jdbc.PreparedStatementLogger.invoke(PreparedStatementLogger.java:80)
    at $Proxy12.getObject(Unknown Source)
    at org.apache.ibatis.executor.resultset.FastResultSetHandler.handleRefCursorOutputParameter(FastResultSetHandler.java:111)
    at org.apache.ibatis.executor.resultset.FastResultSetHandler.handleOutputParameters(FastResultSetHandler.java:97)
    at org.apache.ibatis.executor.statement.CallableStatementHandler.query(CallableStatementHandler.java:66)
    at org.apache.ibatis.executor.statement.RoutingStatementHandler.query(RoutingStatementHandler.java:70)
    at org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:57)
    at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:261)
    at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:138)
    at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:95)
    at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:69)
    at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:100)
    at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:94)

    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:350)
    ... 38 more

Attached my source code.

I'm working in an alternative solution. JDBC plane  (in the traditional way), but it´s a lot of code.

Thank's

Alcides Figueroa.


2012/2/10 Eduardo <eduardo....@gmail.com>
pom.xml
CertificadoMapper.xml
CertificadoDaoImpl.java
dataAccessContext.xml
serviciosContext.xml
mybatisConfig.xml

Eduardo Macarron

unread,
Feb 16, 2012, 9:47:44 AM2/16/12
to mybati...@googlegroups.com

Usually that happens when you try to access a cursor that was never opened the procedure. Check your pl code.

Alcides Figueroa

unread,
Feb 16, 2012, 10:14:25 AM2/16/12
to mybati...@googlegroups.com
But, i test the same code with mybatis 3.0.6 and mybatis-spring 1.0.2 and run fine in local environment. After in development enviroment get the java.lang.NullPointerException (myDaoMethod-Inline, error occurred while setting parameters)

2012/2/16 Eduardo Macarron <eduardo....@gmail.com>

Eduardo Macarron

unread,
Feb 16, 2012, 11:42:25 AM2/16/12
to mybati...@googlegroups.com

It is very unlikely that mybatis is closing that cursor only when running in weblogic...

El 16/02/2012 16:14, "Alcides Figueroa" <afi...@gmail.com> escribió:

But, i test the same code with mybatis 3.0.6 and mybatis-spring 1.0.2 and run fine in local environment. After in development enviroment get the java.lang.NullPointerException (myDaoMethod-Inline, error occurred while setting parameters)


2012/2/16 Eduardo Macarron <eduardo....@gmail.com>
>
> Usually that happens when you try to ac...

Alcides Figueroa

unread,
Feb 16, 2012, 3:51:11 PM2/16/12
to mybati...@googlegroups.com
I know it is a strange case, but the test unit is Ok with mybatis 3.0.6 and mybatis-spring 1.0.2.

In the company where I work the 70% of business logic is develop inside the store procedure. My web app receives the request and the dao class invokes store procedure. I´m try to change the use of JBDC plane for the use of MyBatis framework, but I have several scenarios in oracle store procedures that i must to test.

I'm using:
WebLogic 10.3.5.0
JSE 1.6
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0
Spring 3.0.6

Because my web app is pro spring the integration between Spring and MyBatis is very important.

Basically I need a way to determine at what point the error occurs. Because the NullPointerException is over the ibatis code.

2012/2/16 Eduardo Macarron <eduardo....@gmail.com>for

Richard Yee

unread,
Feb 16, 2012, 10:52:43 PM2/16/12
to mybati...@googlegroups.com
Are you sure the query is returning any results? Perhaps the cursor is not open b/c there are no results.

Richard

Sent from my iPhone
<pom.xml>
<CertificadoMapper.xml>
<CertificadoDaoImpl.java>
<dataAccessContext.xml>
<serviciosContext.xml>
<mybatisConfig.xml>

Eduardo Macarron

unread,
Feb 17, 2012, 5:39:59 AM2/17/12
to mybati...@googlegroups.com

+1

El 17/02/2012 04:52, "Richard Yee" <richar...@gmail.com> escribió:

Are you sure the query is returning any results? Perhaps the cursor is not open b/c there are no results.

Richard

Sent from my iPhone



On Feb 16, 2012, at 5:23 AM, Alcides Figueroa <afi...@gmail.com> wrote:

> Hi,
>

> Eduardo, i test...

Reply all
Reply to author
Forward
0 new messages