java.lang.reflect.InvocationTargetException

Spring JIRA | matt crowe | 2 years ago
  1. 0

    When autowiring the Job, Spring Batch will fail if there is a ManyToOne relationship referenced that does not have a corresponding OneToMany, but instead uses a JoinColumn. The identical code works outside of Spring Batch. Using OneToMany is not always possible, which makes the workaround not always feasible. Sample code: {code:java} @JoinColumn(name="SOME_ID", referencedColumnName="THIS_ID") @OneToMany(targetEntity=ManyClass.class, fetch=FetchType.LAZY) private Set<ManyClass> pendedReasons; {code} Exception: (notice org.hibernate.cfg.annotations.CollectionBinder.bindCollectionSecondPass(CollectionBinder.java:1460) {code} java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:53) at java.lang.Thread.run(Unknown Source) Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'receivableJobs': Injection of autowired dependencies failed; nested exception is java.lang.NullPointerException at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:292) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1185) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:304) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:300) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:195) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:703) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:760) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:482) at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:691) at org.springframework.boot.SpringApplication.run(SpringApplication.java:320) at org.springframework.boot.SpringApplication.run(SpringApplication.java:952) at org.springframework.boot.SpringApplication.run(SpringApplication.java:941) at com.hcsc.css.batch.opermart.ReceivableBatchRunTarget.main(ReceivableBatchRunTarget.java:14) ... 6 more Caused by: java.lang.NullPointerException at org.hibernate.cfg.annotations.CollectionBinder.bindCollectionSecondPass(CollectionBinder.java:1460) at org.hibernate.cfg.annotations.CollectionBinder.bindOneToManySecondPass(CollectionBinder.java:864) at org.hibernate.cfg.annotations.CollectionBinder.bindStarToManySecondPass(CollectionBinder.java:779) at org.hibernate.cfg.annotations.CollectionBinder$1.secondPass(CollectionBinder.java:728) at org.hibernate.cfg.CollectionSecondPass.doSecondPass(CollectionSecondPass.java:70) at org.hibernate.cfg.Configuration.originalSecondPassCompile(Configuration.java:1697) at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1426) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1846) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1930) at org.springframework.orm.hibernate4.LocalSessionFactoryBuilder.buildSessionFactory(LocalSessionFactoryBuilder.java:343) at org.springframework.orm.hibernate4.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:431) at org.springframework.orm.hibernate4.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:416) at com.hcsc.css.batch.opermart.configuration.ReceivableConfiguration.sessionFactory(ReceivableConfiguration.java:43) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredMethodElement.inject(AutowiredAnnotationBeanPostProcessor.java:589) at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:289) ... 21 more {code}

    Spring JIRA | 2 years ago | matt crowe
    java.lang.reflect.InvocationTargetException
  2. 0

    When autowiring the Job, Spring Batch will fail if there is a ManyToOne relationship referenced that does not have a corresponding OneToMany, but instead uses a JoinColumn. The identical code works outside of Spring Batch. Using OneToMany is not always possible, which makes the workaround not always feasible. Sample code: {code:java} @JoinColumn(name="SOME_ID", referencedColumnName="THIS_ID") @OneToMany(targetEntity=ManyClass.class, fetch=FetchType.LAZY) private Set<ManyClass> pendedReasons; {code} Exception: (notice org.hibernate.cfg.annotations.CollectionBinder.bindCollectionSecondPass(CollectionBinder.java:1460) {code} java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:53) at java.lang.Thread.run(Unknown Source) Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'receivableJobs': Injection of autowired dependencies failed; nested exception is java.lang.NullPointerException at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:292) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1185) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:304) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:300) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:195) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:703) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:760) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:482) at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:691) at org.springframework.boot.SpringApplication.run(SpringApplication.java:320) at org.springframework.boot.SpringApplication.run(SpringApplication.java:952) at org.springframework.boot.SpringApplication.run(SpringApplication.java:941) at com.hcsc.css.batch.opermart.ReceivableBatchRunTarget.main(ReceivableBatchRunTarget.java:14) ... 6 more Caused by: java.lang.NullPointerException at org.hibernate.cfg.annotations.CollectionBinder.bindCollectionSecondPass(CollectionBinder.java:1460) at org.hibernate.cfg.annotations.CollectionBinder.bindOneToManySecondPass(CollectionBinder.java:864) at org.hibernate.cfg.annotations.CollectionBinder.bindStarToManySecondPass(CollectionBinder.java:779) at org.hibernate.cfg.annotations.CollectionBinder$1.secondPass(CollectionBinder.java:728) at org.hibernate.cfg.CollectionSecondPass.doSecondPass(CollectionSecondPass.java:70) at org.hibernate.cfg.Configuration.originalSecondPassCompile(Configuration.java:1697) at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1426) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1846) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1930) at org.springframework.orm.hibernate4.LocalSessionFactoryBuilder.buildSessionFactory(LocalSessionFactoryBuilder.java:343) at org.springframework.orm.hibernate4.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:431) at org.springframework.orm.hibernate4.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:416) at com.hcsc.css.batch.opermart.configuration.ReceivableConfiguration.sessionFactory(ReceivableConfiguration.java:43) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredMethodElement.inject(AutowiredAnnotationBeanPostProcessor.java:589) at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:289) ... 21 more {code}

    Spring JIRA | 2 years ago | matt crowe
    java.lang.reflect.InvocationTargetException
  3. 0

    Spring and Hibernate eager initialization issue for multitenant application

    Stack Overflow | 2 years ago | Tom
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'tenantHibernateSessionFactory' defined in file [D:\Work\Java\apache-tomcat-6.0.39\webapps\ams-gate\WEB-INF\classes\META-INF\spring\persistence.xml]: Invocation of init method failed; nested exception is java.lang.NullPointerException
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    Hibernate 4 Error on sessionFactory creation

    Stack Overflow | 5 years ago | vic
    java.lang.NullPointerException
  6. 0

    BeanCreationException of org.springframework.orm.hibernate4.LocalSessionFactoryBean

    Stack Overflow | 3 years ago | gabi
    java.lang.IllegalStateException: Failed to load ApplicationContext

  1. Kawada 54 times, last 7 months ago
15 unregistered visitors
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

    No message provided

    at org.hibernate.cfg.annotations.CollectionBinder.bindCollectionSecondPass()
  2. Hibernate
    Configuration.buildSessionFactory
    1. org.hibernate.cfg.annotations.CollectionBinder.bindCollectionSecondPass(CollectionBinder.java:1460)
    2. org.hibernate.cfg.annotations.CollectionBinder.bindOneToManySecondPass(CollectionBinder.java:864)
    3. org.hibernate.cfg.annotations.CollectionBinder.bindStarToManySecondPass(CollectionBinder.java:779)
    4. org.hibernate.cfg.annotations.CollectionBinder$1.secondPass(CollectionBinder.java:728)
    5. org.hibernate.cfg.CollectionSecondPass.doSecondPass(CollectionSecondPass.java:70)
    6. org.hibernate.cfg.Configuration.originalSecondPassCompile(Configuration.java:1697)
    7. org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1426)
    8. org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1846)
    9. org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1930)
    9 frames
  3. Spring ORM
    LocalSessionFactoryBean.afterPropertiesSet
    1. org.springframework.orm.hibernate4.LocalSessionFactoryBuilder.buildSessionFactory(LocalSessionFactoryBuilder.java:343)
    2. org.springframework.orm.hibernate4.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:431)
    3. org.springframework.orm.hibernate4.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:416)
    3 frames
  4. com.hcsc.css
    ReceivableConfiguration.sessionFactory
    1. com.hcsc.css.batch.opermart.configuration.ReceivableConfiguration.sessionFactory(ReceivableConfiguration.java:43)
    1 frame
  5. Java RT
    Method.invoke
    1. sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    2. sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    3. sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    4. java.lang.reflect.Method.invoke(Unknown Source)
    4 frames
  6. Spring Beans
    DefaultListableBeanFactory.preInstantiateSingletons
    1. org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredMethodElement.inject(AutowiredAnnotationBeanPostProcessor.java:589)
    2. org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87)
    3. org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:289)
    4. org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1185)
    5. org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537)
    6. org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475)
    7. org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:304)
    8. org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
    9. org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:300)
    10. org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:195)
    11. org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:703)
    11 frames
  7. Spring Context
    AbstractApplicationContext.refresh
    1. org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:760)
    2. org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:482)
    2 frames
  8. Spring Boot
    SpringApplication.run
    1. org.springframework.boot.SpringApplication.refresh(SpringApplication.java:691)
    2. org.springframework.boot.SpringApplication.run(SpringApplication.java:320)
    3. org.springframework.boot.SpringApplication.run(SpringApplication.java:952)
    4. org.springframework.boot.SpringApplication.run(SpringApplication.java:941)
    4 frames
  9. com.hcsc.css
    ReceivableBatchRunTarget.main
    1. com.hcsc.css.batch.opermart.ReceivableBatchRunTarget.main(ReceivableBatchRunTarget.java:14)
    1 frame
  10. Java RT
    Method.invoke
    1. sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    2. sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    3. sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    4. java.lang.reflect.Method.invoke(Unknown Source)
    4 frames
  11. Spring Boot Loader
    MainMethodRunner.run
    1. org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:53)
    1 frame
  12. Java RT
    Thread.run
    1. java.lang.Thread.run(Unknown Source)
    1 frame