简体   繁体   English

java.lang.NullPointerException,因为我没有访问表的权限

[英]java.lang.NullPointerException because I don't have permission to access the table

I have a project in Java EE. 我在Java EE中有一个项目。 When I access the table from database it returns error, here's the HQL query : 当我从数据库访问表时,它返回错误,这是HQL查询:

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

and this the error message : 这是错误消息:

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)

I see my Postgres DB, when I'm doing SELECT query to the table, then I get a warning: 我在对表执行SELECT查询时看到了Postgres DB,然后收到警告:

permision denied for relation whitelist. 关系白名单拒绝了渗透。

Does the warning on Postgres is the cause of this error? Postgres上的警告是否是导致此错误的原因?

Only assuming as you haven't posted any Java code but looks like your NullPointer which is probably a ResultSet which dosen't contain any results is because you don't have the right permissions to read/write onto the relation 'whitelist'. 仅假设您尚未发布任何Java代码,但看起来像您的NullPointer(可能是不包含任何结果的ResultSet)是因为您没有正确的权限来读写关系“白名单”。 I'd check what username your using to login to the database against which username your using for the jdbc connection. 我将检查您用于登录数据库的用户名和jdbc连接所使用的用户名。

If you post your java code we can see if the NullPointer is because of an empty result set which you are then trying to manipulate or because of something else. 如果您发布Java代码,我们可以看到NullPointer是由于您试图处理的结果集为空还是其他原因。

First question i've answered so sorry if its wordy. 我已经回答的第一个问题很抱歉,如果它罗word的话。

From the stack, we could say that something wrong is with the query that you have created. 从堆栈中,我们可以说您创建的查询出了点问题。 To be sure i would add as and remove the ilike and the select clause from it. 可以肯定的是,我会添加asselect删除ilikeselect子句。

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

The ilike operator do exists in Expression , but i am not aware about HQL try to execute about query. ilike运算符确实存在于Expression中 ,但是我不了解HQL尝试执行有关查询的操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM