java.lang.NullPointerException

There are no available Samebug tips for this exception. Do you have an idea how to solve this issue? A short tip would help users who saw this issue last week.

  • A NullPointerException is thrown when hibernate.show_sql=true && hibernate.format_sql=true while exec'ing sql with quotes around the stmt: (taken from an embedded groovy script) --------- def sess = getSession() def HQL = """ (select count(*) from TABLE) """ sess .createSQLQuery(HQL) .list() ------------ This is valid SQL and is typically used in my app as such: (select count(*) from TABLE1) UNION ALL (select count(*) from TABLE2) ... Here is the stack trace in hibernate: java.lang.NullPointerException at org.hibernate.pretty.Formatter.isFunctionName(Formatter.java:342) at org.hibernate.pretty.Formatter.openParen(Formatter.java:323) at org.hibernate.pretty.Formatter.format(Formatter.java:134) at org.hibernate.jdbc.AbstractBatcher.format(AbstractBatcher.java:410) at org.hibernate.jdbc.AbstractBatcher.log(AbstractBatcher.java:404) at org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBatcher.java:482) at org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBatcher.java:423) at org.hibernate.jdbc.AbstractBatcher.prepareQueryStatement(AbstractBatcher.java:139) at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1547) at org.hibernate.loader.Loader.doQuery(Loader.java:673) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236) at org.hibernate.loader.Loader.doList(Loader.java:2220) at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2104) at org.hibernate.loader.Loader.list(Loader.java:2099) at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:289) at org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1695) at org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java:142) at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:152)
    via by Scott Feldstein,
  • A NullPointerException is thrown when hibernate.show_sql=true && hibernate.format_sql=true while exec'ing sql with quotes around the stmt: (taken from an embedded groovy script) --------- def sess = getSession() def HQL = """ (select count(*) from TABLE) """ sess .createSQLQuery(HQL) .list() ------------ This is valid SQL and is typically used in my app as such: (select count(*) from TABLE1) UNION ALL (select count(*) from TABLE2) ... Here is the stack trace in hibernate: java.lang.NullPointerException at org.hibernate.pretty.Formatter.isFunctionName(Formatter.java:342) at org.hibernate.pretty.Formatter.openParen(Formatter.java:323) at org.hibernate.pretty.Formatter.format(Formatter.java:134) at org.hibernate.jdbc.AbstractBatcher.format(AbstractBatcher.java:410) at org.hibernate.jdbc.AbstractBatcher.log(AbstractBatcher.java:404) at org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBatcher.java:482) at org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBatcher.java:423) at org.hibernate.jdbc.AbstractBatcher.prepareQueryStatement(AbstractBatcher.java:139) at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1547) at org.hibernate.loader.Loader.doQuery(Loader.java:673) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236) at org.hibernate.loader.Loader.doList(Loader.java:2220) at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2104) at org.hibernate.loader.Loader.list(Loader.java:2099) at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:289) at org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1695) at org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java:142) at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:152)
    via by Scott Feldstein,
  • I get an NPE when i try to execute a native query. Below is the excerpt of the code that throws NPE: String sqlQuery = "select emp_id, emp_first_name from employee_mt"; SQLQuery query = session.createSQLQuery(sqlQuery); query.setCacheable(true).setCacheRegion("TEST_REGION"); query.addScalar("emp_id"); query.addScalar("emp_first_name"); List list = query.list(); query.list() throws the following NPE: java.lang.NullPointerException at org.hibernate.type.TypeFactory.disassemble(TypeFactory.java:451) at org.hibernate.cache.StandardQueryCache.put(StandardQueryCache.java:83) at org.hibernate.loader.Loader.putResultInQueryCache(Loader.java:2194) at org.hibernate.loader.Loader.listUsingQueryCache(Loader.java:2138) at org.hibernate.loader.Loader.list(Loader.java:2096) at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:289) at org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1695) at org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java:142) at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:152) at poc.hibernate.caching.QueryCaching.fireNativeSql(QueryCaching.java:112) at poc.hibernate.caching.QueryCaching.fireQuery(QueryCaching.java:38) at poc.hibernate.caching.QueryCaching.main(QueryCaching.java:27) I tried tracing through the Hibernate code code and saw that the types[] in the at the time of execution of types[i].disassemble( row[i], session, owner ) (TypeFactory.disassemble()) was holding both the types as null. However before reaching that piece of code CustomLoader.autoDiscoverTypes(resultset) had already resolved the resultTypes to appropriate values. Hope this helps.
    via by Amit Kapoor,
    • java.lang.NullPointerException at org.hibernate.loader.custom.CustomLoader$Metadata.<init>(CustomLoader.java:552) at org.hibernate.loader.custom.CustomLoader.autoDiscoverTypes(CustomLoader.java:525) at org.hibernate.loader.Loader.getResultSet(Loader.java:1878) at org.hibernate.loader.Loader.doQuery(Loader.java:718) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:270) at org.hibernate.loader.Loader.doList(Loader.java:2449) at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2192) at org.hibernate.loader.Loader.list(Loader.java:2187) at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:316) at org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1832) at org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java:165) at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:179) at com.uil.dat.dao.impl.WorkOrderDAOImpl.calculatePriority(WorkOrderDAOImpl.java:60) at com.uil.dat.manager.impl.DAOManagerImpl.calculatePriority(DAOManagerImpl.java:154) at com.uil.dat.service.spt.impl.WorkOrderServiceImpl.calcPriority(WorkOrderServiceImpl.java:157) at com.uil.dat.controller.spt.WorkOrderControllerBean.calcPriority(WorkOrderControllerBean.java:308) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37) at java.lang.reflect.Method.invoke(Method.java:611) at org.apache.el.parser.AstValue.invoke(AstValue.java:268) at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:278) at org.apache.myfaces.view.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:83) at javax.faces.component._MethodExpressionToMethodBinding.invoke(_MethodExpressionToMethodBinding.java:88) at org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:100) at javax.faces.component.UICommand.broadcast(UICommand.java:120) at javax.faces.component.UIViewRoot._broadcastAll(UIViewRoot.java:995) at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:278) at javax.faces.component.UIViewRoot._process(UIViewRoot.java:1307) at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:733) at org.apache.myfaces.lifecycle.InvokeApplicationExecutor.execute(InvokeApplicationExecutor.java:34) at org.apache.myfaces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:172) at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:119) at javax.faces.webapp.FacesServlet.service(FacesServlet.java:189) at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1230) at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:779) at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:478) at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:178) at com.ibm.ws.webcontainer.filter.WebAppFilterChain.invokeTarget(WebAppFilterChain.java:136) at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:97) at com.uil.dat.filter.RequestFilter.doFilter(RequestFilter.java:74) at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:195) at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:91) at com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:964) at com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:1104) at com.ibm.ws.webcontainer.servlet.CacheServletWrapper.handleRequest(CacheServletWrapper.java:87) at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:914) at com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1662) at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:200) at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:463) at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewRequest(HttpInboundLink.java:530) at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.processRequest(HttpInboundLink.java:316) at com.ibm.ws.http.channel.inbound.impl.HttpICLReadCallback.complete(HttpICLReadCallback.java:88) at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:175) at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217) at com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161) at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:138) at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:204) at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:775) at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:905) at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1865)
    No Bugmate found.