java.lang.NullPointerException: null

Stack Overflow | mohsen | 7 months ago
tip
Do you know that we can give you better hits? Get more relevant results from Samebug’s stack trace search.
  1. 0

    Spring 4 - Config XML jpa:repositories throwing NoSuchMethodError BeanDefinitionParserDelegate.getEnvironment()

    Stack Overflow | 2 years ago | a.hrdie
    org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'securityContextFilter' defined in file [/var/lib/tomcat6/webapps/services/WEB-INF/classes/com/services/filter/SecurityContextFilter.class]: Unsatisfied dependency expressed through constructor argument with index 0 of type [com.services.user.UserRepository]: : Error creating bean with name 'userRepository': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Validation failed for query for method public abstract com.services.user.domain.User com.services.user.UserRepository.findBySession(java.lang.String)!; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userRepository': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Validation failed for query for method public abstract com.services.user.domain.User com.services.user.UserRepository.findBySession(java.lang.String)!
  2. Speed up your debug routine!

    Automated exception search integrated into your IDE

  3. 0

    The setup: {code:java} @Entity @Table(name = "batch") @SequenceGenerator(name = "BatchGen", sequenceName = "seq_batch", allocationSize = 1) public class Batch implements Serializable { ... @ElementCollection @CollectionTable( name = "batch_node", //uniqueConstraints = @UniqueConstraint(columnNames = {"batch_id", "node_id"}), //foreignKey = @ForeignKey, joinColumns = @JoinColumn(name = "batch_id", nullable = false)) @MapKeyJoinColumn(name = "node_id") private Map<Node, BatchNodeMetadata> batchNodeMetadata = new HashMap<>(); ... } @Entity @Table(name= "node") @SequenceGenerator(name="NodeGen", sequenceName="seq_node", allocationSize=1) public class Node implements Serializable { ... } @Embeddable public class BatchNodeMetadata implements Serializable { @Column(nullable = false) @Enumerated(EnumType.STRING) private NodeMigration migrering = NodeMigration.TOTAL; public NodeMigration getMigrering() { return migrering; } public void setMigrering(NodeMigration migrering) { this.migrering = migrering; } } {code} Testcase {code:java} class Test { @Test public void testGetNodesInBatch() { Node n = new Node(); n.setName("Test"); nodeDAO.create(n); Batch b = new Batch(); b.setName("Test"); b.getBatchNodeMetadata().put(n, new BatchNodeMetadata()); batchDAO.create(b); Collection<String> actual = batchDAO.getNodesInBatch(b); Assert.assertEquals(1, actual.size()); } } class Dao { public Collection<Node> getNodesInBatch(Batch batch) { CriteriaBuilder cb = em.getCriteriaBuilder(); CriteriaQuery<Node> query = cb.createQuery(Node.class); Root<Batch> root = query.from(Batch.class); MapJoin<Batch, Node, BatchNodeMetadata> nodes = root.join(Batch_.batchNodeMetadata); query.select(nodes.key()); query.where(cb.equal(root, batch)); return em.createQuery(query).getResultList(); } } {code} *Output* Everything from the setup seems to be correct {noformat} Hibernate: create table batch (id integer not null, current_activity varchar(255), name varchar(255) not null, pretty_current_activity varchar(255), visas_utanför_fabriken boolean, primary key (id)) Hibernate: create table batch_node (batch_id integer not null, migrering varchar(255) not null, node_id integer not null, primary key (batch_id, node_id)) Hibernate: create table node (id integer not null, edgar_complexity varchar(255), long_name varchar(255), municipal_area varchar(255), "name" varchar(255) not null, primary key (id)) Hibernate: alter table batch add constraint UK_ea6wjj8co7qtkcek0at693sh5 unique (name) Hibernate: alter table node add constraint UK_fwigxdmj6bsrpcmhcgpmlsirh unique ("name") Hibernate: alter table batch_node add constraint FK_hp7ye0ce3g9xb2h9newetnar5 foreign key (node_id) references node Hibernate: alter table batch_node add constraint FK_cdi1tq0y36ylqqm4dbvghaxk foreign key (batch_id) references batch Hibernate: call next value for seq_node Hibernate: insert into node (edgar_complexity, long_name, municipal_area, "name", id) values (?, ?, ?, ?, ?) Hibernate: call next value for seq_batch Hibernate: insert into batch (current_activity, name, pretty_current_activity, visas_utanför_fabriken, id) values (?, ?, ?, ?, ?) Hibernate: insert into batch_node (batch_id, node_id, migrering) values (?, ?, ?) {noformat} NPE when executing the criteria {code:java} java.lang.NullPointerException: null at org.hibernate.hql.internal.ast.HqlSqlWalker.lookupProperty(HqlSqlWalker.java:592) at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.addrExpr(HqlSqlBaseWalker.java:4980) at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.expr(HqlSqlBaseWalker.java:1263) at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.exprOrSubquery(HqlSqlBaseWalker.java:4686) at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.arithmeticExpr(HqlSqlBaseWalker.java:3215) at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.selectExpr(HqlSqlBaseWalker.java:2382) at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.selectExprList(HqlSqlBaseWalker.java:2194) at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.selectClause(HqlSqlBaseWalker.java:1476) at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:573) at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:301) at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:249) at org.hibernate.hql.internal.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:278) at org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:206) at org.hibernate.hql.internal.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:158) at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:131) at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:93) at org.hibernate.engine.query.spi.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:167) at org.hibernate.internal.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:301) at org.hibernate.internal.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:236) at org.hibernate.internal.SessionImpl.createQuery(SessionImpl.java:1800) at org.hibernate.jpa.spi.AbstractEntityManagerImpl.createQuery(AbstractEntityManagerImpl.java:568) at org.hibernate.jpa.criteria.CriteriaQueryImpl$1.buildCompiledQuery(CriteriaQueryImpl.java:336) at org.hibernate.jpa.criteria.compile.CriteriaCompiler.compile(CriteriaCompiler.java:147) at org.hibernate.jpa.spi.AbstractEntityManagerImpl.createQuery(AbstractEntityManagerImpl.java:736) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at org.springframework.orm.jpa.SharedEntityManagerCreator$SharedEntityManagerInvocationHandler.invoke(SharedEntityManagerCreator.java:262) at com.sun.proxy.$Proxy47.createQuery(Unknown Source) at com.dbmodel.dao.BatchDAO.getNodesInBatchStr(BatchDAO.java:132) at com.dbmodel.dao.BatchDAO$$FastClassBySpringCGLIB$$b9d5b01c.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:708) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157) at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:98) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:262) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:95) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:644) at com.dbmodel.dao.BatchDAO$$EnhancerBySpringCGLIB$$4e2a04ba.getNodesInBatchStr(<generated>) at com.dbmodel.dao.BatchDAOIT.testGetNodesInBatch(BatchDAOIT.java:79) {code}

    Hibernate JIRA | 1 year ago | thall
    java.lang.NullPointerException: null
  4. 0

    Error in Join on a relation ManyToOne. Using QueryDSL

    GitHub | 10 months ago | luiscamposjr
    org.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.lang.NullPointerException
Not finding the right solution?
Take a tour to get the most out of Samebug.

Tired of useless tips?

Automated exception search integrated into your IDE

Root Cause Analysis

  1. java.lang.NullPointerException

    null

    at org.hibernate.dialect.function.StandardAnsiSqlAggregationFunctions$SumFunction.determineJdbcTypeCode()
  2. Hibernate
    SessionImpl.createQuery
    1. org.hibernate.dialect.function.StandardAnsiSqlAggregationFunctions$SumFunction.determineJdbcTypeCode(StandardAnsiSqlAggregationFunctions.java:200)
    2. org.hibernate.dialect.function.StandardAnsiSqlAggregationFunctions$SumFunction.getReturnType(StandardAnsiSqlAggregationFunctions.java:158)
    3. org.hibernate.hql.internal.ast.tree.IdentNode.getDataType(IdentNode.java:327)
    4. org.hibernate.hql.internal.ast.tree.MethodNode.getFirstArgumentType(MethodNode.java:59)
    5. org.hibernate.hql.internal.ast.SqlGenerator.endFunctionTemplate(SqlGenerator.java:211)
    6. org.hibernate.hql.internal.antlr.SqlGeneratorBase.methodCall(SqlGeneratorBase.java:2538)
    7. org.hibernate.hql.internal.antlr.SqlGeneratorBase.selectExpr(SqlGeneratorBase.java:2102)
    8. org.hibernate.hql.internal.antlr.SqlGeneratorBase.selectColumn(SqlGeneratorBase.java:1914)
    9. org.hibernate.hql.internal.antlr.SqlGeneratorBase.selectClause(SqlGeneratorBase.java:544)
    10. org.hibernate.hql.internal.antlr.SqlGeneratorBase.selectStatement(SqlGeneratorBase.java:186)
    11. org.hibernate.hql.internal.antlr.SqlGeneratorBase.statement(SqlGeneratorBase.java:135)
    12. org.hibernate.hql.internal.ast.QueryTranslatorImpl.generate(QueryTranslatorImpl.java:244)
    13. org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:210)
    14. org.hibernate.hql.internal.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:142)
    15. org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:115)
    16. org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:77)
    17. org.hibernate.engine.query.spi.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:152)
    18. org.hibernate.internal.AbstractSharedSessionContract.getQueryPlan(AbstractSharedSessionContract.java:521)
    19. org.hibernate.internal.AbstractSharedSessionContract.createQuery(AbstractSharedSessionContract.java:623)
    20. org.hibernate.internal.SessionImpl.createQuery(SessionImpl.java:3250)
    20 frames
  3. org.hibernate.query
    CriteriaCompiler.compile
    1. org.hibernate.query.criteria.internal.CriteriaQueryImpl$1.buildCompiledQuery(CriteriaQueryImpl.java:318)
    2. org.hibernate.query.criteria.internal.compile.CriteriaCompiler.compile(CriteriaCompiler.java:127)
    2 frames
  4. Hibernate
    SessionImpl.createQuery
    1. org.hibernate.internal.SessionImpl.createQuery(SessionImpl.java:3543)
    2. org.hibernate.internal.SessionImpl.createQuery(SessionImpl.java:203)
    2 frames
  5. com.advertisement.database
    DbEntityRepository.find
    1. com.advertisement.database.DbHelper.test(DbHelper.java:432)
    2. com.advertisement.database.DbHelper.find(DbHelper.java:278)
    3. com.advertisement.database.DbEntityRepository.find(DbEntityRepository.java:148)
    3 frames
  6. com.advertisement.controller
    Test.test
    1. com.advertisement.controller.Test.test(Test.java:28)
    1 frame
  7. Java RT
    Method.invoke
    1. sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    2. sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    3. sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    4. java.lang.reflect.Method.invoke(Method.java:497)
    4 frames
  8. Pax Jsp
    MethodExpressionImpl.invoke
    1. org.apache.el.parser.AstValue.invoke(AstValue.java:247)
    2. org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:267)
    2 frames
  9. JavaEE 7
    UIViewRoot.processApplication
    1. javax.faces.event.MethodExpressionActionListener.processAction(MethodExpressionActionListener.java:149)
    2. javax.faces.event.ActionEvent.processListener(ActionEvent.java:88)
    3. javax.faces.component.UIComponentBase.broadcast(UIComponentBase.java:813)
    4. javax.faces.component.UICommand.broadcast(UICommand.java:300)
    5. javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:790)
    6. javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1282)
    6 frames
  10. JSF
    LifecycleImpl.execute
    1. com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)
    2. com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
    3. com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:198)
    3 frames
  11. JavaEE 7
    FacesServlet.service
    1. javax.faces.webapp.FacesServlet.service(FacesServlet.java:646)
    1 frame
  12. Glassfish Core
    ApplicationFilterChain.doFilter
    1. org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:292)
    2. org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
    2 frames
  13. primefaces
    FileUploadFilter.doFilter
    1. org.primefaces.webapp.filter.FileUploadFilter.doFilter(FileUploadFilter.java:78)
    1 frame
  14. Glassfish Core
    ApplicationFilterChain.doFilter
    1. org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
    2. org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
    2 frames
  15. Tomcat WS
    WsFilter.doFilter
    1. org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    1 frame
  16. Glassfish Core
    ApplicationFilterChain.doFilter
    1. org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
    2. org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
    2 frames
  17. com.advertisement.lifecycle
    OverrideEncodingFilter.doFilter
    1. com.advertisement.lifecycle.OverrideEncodingFilter.doFilter(OverrideEncodingFilter.java:22)
    1 frame
  18. Glassfish Core
    CoyoteAdapter.service
    1. org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
    2. org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
    3. org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212)
    4. org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
    5. org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
    6. org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141)
    7. org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
    8. org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616)
    9. org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
    10. org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:522)
    10 frames
  19. Grizzly HTTP
    NioEndpoint$SocketProcessor.run
    1. org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1095)
    2. org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:672)
    3. org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1500)
    4. org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1456)
    4 frames
  20. Java RT
    ThreadPoolExecutor$Worker.run
    1. java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    2. java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    2 frames
  21. Tomcat Util
    TaskThread$WrappingRunnable.run
    1. org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    1 frame
  22. Java RT
    Thread.run
    1. java.lang.Thread.run(Thread.java:745)
    1 frame