2012-02-01 14 views
0

我在Java EE中有一个项目。当我从访问数据库中的表返回的错误,这里的HQL查询:java.lang.NullPointerException因为我没有访问表的权限

select b from Blacklist b inner join fetch b.users u where b.type ilike :type order by b.date desc 

与此错误消息:

18:18:10,694 ERROR [STDERR] java.lang.NullPointerException 
18:18:10,694 ERROR [STDERR]  at org.hibernate.engine.query.QueryPlanCache$HQLQueryPlanKey.<init>(QueryPlanCache.java:193) 
18:18:10,694 ERROR [STDERR]  at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:87) 
18:18:10,694 ERROR [STDERR]  at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:156) 
18:18:10,694 ERROR [STDERR]  at org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:135) 
18:18:10,694 ERROR [STDERR]  at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1650) 
18:18:10,694 ERROR [STDERR]  at org.hibernate.ejb.AbstractEntityManagerImpl.createQuery(AbstractEntityManagerImpl.java:93) 
18:18:10,694 ERROR [STDERR]  at org.jboss.jpa.tx.TransactionScopedEntityManager.createQuery(TransactionScopedEntityManager.java:139) 
18:18:10,694 ERROR [STDERR]  at doku.edp.trasactions.Eds2UtilityBean.getFieldDataFromBlacklist(Eds2UtilityBean.java:325) 
18:18:10,694 ERROR [STDERR]  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
18:18:10,695 ERROR [STDERR]  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 
18:18:10,695 ERROR [STDERR]  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 
18:18:10,695 ERROR [STDERR]  at java.lang.reflect.Method.invoke(Method.java:597) 
18:18:10,695 ERROR [STDERR]  at org.jboss.aop.joinpoint.MethodInvocation.invokeTarget(MethodInvocation.java:122) 
18:18:10,695 ERROR [STDERR]  at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:111) 
18:18:10,695 ERROR [STDERR]  at org.jboss.ejb3.EJBContainerInvocationWrapper.invokeNext(EJBContainerInvocationWrapper.java:69) 
18:18:10,695 ERROR [STDERR]  at org.jboss.ejb3.interceptors.aop.InterceptorSequencer.invoke(InterceptorSequencer.java:73) 
18:18:10,695 ERROR [STDERR]  at org.jboss.ejb3.interceptors.aop.InterceptorSequencer.aroundInvoke(InterceptorSequencer.java:59) 
18:18:10,695 ERROR [STDERR]  at sun.reflect.GeneratedMethodAccessor522.invoke(Unknown Source) 
18:18:10,695 ERROR [STDERR]  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 
18:18:10,695 ERROR [STDERR]  at java.lang.reflect.Method.invoke(Method.java:597) 
18:18:10,695 ERROR [STDERR]  at org.jboss.aop.advice.PerJoinpointAdvice.invoke(PerJoinpointAdvice.java:174) 
18:18:10,695 ERROR [STDERR]  at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102) 
18:18:10,695 ERROR [STDERR]  at org.jboss.ejb3.interceptors.aop.InvocationContextInterceptor.fillMethod(InvocationContextInterceptor.java:72) 
18:18:10,695 ERROR [STDERR]  at org.jboss.aop.advice.org.jboss.ejb3.interceptors.aop.InvocationContextInterceptor_z_fillMethod_405857447.invoke(InvocationContextInterceptor_z_fillMethod_405857447.java) 
18:18:10,695 ERROR [STDERR]  at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102) 
18:18:10,695 ERROR [STDERR]  at org.jboss.ejb3.interceptors.aop.InvocationContextInterceptor.setup(InvocationContextInterceptor.java:88) 
18:18:10,695 ERROR [STDERR]  at org.jboss.aop.advice.org.jboss.ejb3.interceptors.aop.InvocationContextInterceptor_z_setup_405857447.invoke(InvocationContextInterceptor_z_setup_405857447.java) 
18:18:10,695 ERROR [STDERR]  at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102) 
18:18:10,695 ERROR [STDERR]  at org.jboss.ejb3.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:62) 

我看到我的Postgres数据库,当我在做SELECT查询该表,然后我得到一个警告:

permision否认关系白名单。

Postgres上的警告是否是此错误的原因?

+2

我们可以看到导致错误的代码吗? – 2012-02-01 11:21:18

+0

你的问题太含糊。请确切地说 - 你正在执行的代码是什么,你如何执行它,粘贴你的堆栈跟踪等。在这一点上,我们甚至不知道你的问题。 – 2012-02-01 11:29:45

+0

即时通讯对不起,家伙..,这里的错误,我已经编辑问题 – 2012-02-01 11:57:42

回答

1

只假设你没有发布任何Java代码,但看起来像你的NullPointer,它可能是一个ResultSet,它不包含任何结果是因为你没有正确的权限来读/写关系'白名单'。我会检查你使用哪个用户名登录数据库,用哪个用户名作为jdbc连接。

如果您发布了您的Java代码,我们可以看到NullPointer是否是由于空的结果集,然后您试图操纵或因为别的。

第一个问题,我已经回答很抱歉,如果罗嗦。

+0

感谢您的答案,我已编辑与错误消息的问题。谢谢 – 2012-02-01 11:59:20

+0

嗨迪亚兹 - 你试图在postgres数据库上运行查询,你有权限被拒绝的错误?看着你的查询,你查询的表格或关系是'黑名单',而许可拒绝错误提到'白名单'而不是黑名单。 – 2012-02-02 18:39:26

+0

是的,对,我没有任何包含权限被拒绝的jboss错误信息。所以这不是主要问题。我的错误表明查询无法访问黑名单表。 – 2012-02-03 03:42:16

0

从堆栈中,我们可以说错误在于您创建的查询。 为了确保我会添加as并从中删除ilikeselect子句。

from Blacklist as b inner join fetch b.users as u where b.type like :type order by b.date desc 

的ILIKE操作做存在Expression,但我不知道有关HQL尝试执行有关查询。

相关问题