Spring framework - Context initialization failed - Out of memory space - java

Last week I got a new laptop at my work and since then I can't make my dev environment to work.
I'm keep getting the following exception when running the server (tomcat 7).
I was trying to increase heap memory without any luck..
Please advice...I really don't know what to do.
Thanks
Zi
[localhost-startStop-1] **ERROR org.springframework.web.context.ContextLoader - Context initialization failed**
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'friendController': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: com.beepme.services.api.GenericApi com.beepme.controllers.FriendController.genericApi; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'genericApi': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.beepme.services.RouteService com.beepme.services.api.GenericApi.routeSvc; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'routeServiceImpl': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: com.beepme.services.RouteMatchingService com.beepme.services.RouteServiceImpl.routeMatchingService; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'routeMatchingServiceImpl': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.beepme.components.RouteCache com.beepme.services.RouteMatchingServiceImpl.routeCache; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'routeCacheImpl': Invocation of init method failed; nested exception is java.lang.**OutOfMemoryError: Java heap space**
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:288)

Related

Spring Boot ObjectMapper throws NullPointerException

I am currently working on an application that fails to run after upgrading to a newer snapshot version of a custom 3rd party dependency. Upon using this updated dependency I get the following error
java.lang.IllegalStateException: Failed to load ApplicationContext
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException:
Error creating bean with name 'listener': Unsatisfied dependency expressed through field 'mapper'; nested exception is org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'objectMapper' defined in class path resource [com/****/****/****/WebMvcConfig.class]: Bean instantiation via factory method failed;
nested exception is org.springframework.beans.BeanInstantiationException:
Failed to instantiate [com.fasterxml.jackson.databind.ObjectMapper]: Factory method 'objectMapper' threw exception; nested exception is java.lang.NullPointerException
The 'mapper' is what I am using locally, 'objectMapper' refers to a remote dependency. I realize this is may be challenging without code, but what could be causing this error? If I remove my objectmapper instance, the error only shifts to another section of the program, but the stack trace always leads to this:
Error creating bean with name 'objectMapper' defined in class path resource [com/****/****/****/WebMvcConfig.class]: Bean instantiation via factory method failed;
nested exception is org.springframework.beans.BeanInstantiationException:
Failed to instantiate [com.fasterxml.jackson.databind.ObjectMapper]: Factory method 'objectMapper' threw exception; nested exception is java.lang.NullPointerException
Ive tried different versions of com.fasterxml.jackson.core but that does not seem to help. Any suggestions at all would be appreciated.
Edit:
Additional Stack Trace:
java.lang.IllegalStateException: Failed to load ApplicationContext
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'cashModule' defined in file
[/Users/*****/******/*******/target/classes/*****/****/****/*****/cashModule.class]: Unsatisfied dependency expressed through constructor parameter 1; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'service5' defined in file
[/Users/****/******/******/target/classes/****/****/*****/*****/EventProcessingService.class]: Unsatisfied dependency expressed through constructor parameter 0;
nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'eventSource' defined in class path resource [com/****/****/****/******/EventConfig.class]:
Unsatisfied dependency expressed through method 'eventSource' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.cloud.stream.messaging.Source': Unsatisfied dependency expressed through field 'bindingTargetFactories'; nested exception is
org.springframework.beans.factory.UnsatisfiedDependencyException:
Error creating bean with name 'channelFactory' defined in class path resource [org/springframework/cloud/stream/config/BinderFactoryConfiguration.class]: Unsatisfied dependency expressed through method 'channelFactory' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'compositeMessageChannelConfigurer' defined in class path resource [org/springframework/cloud/stream/config/BinderFactoryConfiguration.class]: Unsatisfied dependency expressed through method 'compositeMessageChannelConfigurer' parameter 0;
nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'messageConverterConfigurer' defined in class path resource
[org/springframework/cloud/stream/config/BinderFactoryConfiguration.class]: Unsatisfied dependency expressed through method 'messageConverterConfigurer' parameter 1; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'compositeMessageConverterFactory' defined in class path resource [org/springframework/cloud/stream/config/ContentTypeConfiguration.class]:
Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.cloud.stream.converter.CompositeMessageConverterFactory]: Factory method 'compositeMessageConverterFactory' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'objectMapper' defined in class path resource
[com/****/****/*****/WebMvcConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.fasterxml.jackson.databind.ObjectMapper]: Factory method 'objectMapper' threw exception; nested exception is java.lang.NullPointerException

autowire dependency exception ,

DEBUG [http-bio-8004-exec-3] DispatcherServlet.processRequest(954) |
Could not complete request
org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'contactFormController': Injection of
autowired dependencies failed; nested exception is
org.springframework.beans.factory.BeanCreationException: Could not
autowire method: public void
com.crisil.cmd.webapp.controller.ContactFormController.setContactListService(com.crisil.cmd.service.ContactListService);
nested exception is
org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'contactListService': Injection of autowired
dependencies failed; nested exception is
org.springframework.beans.factory.BeanCreationException: Could not
autowire method: public void
com.crisil.cmd.service.impl.ContactListServiceImpl.setContactListDao(com.crisil.cmd.dao.ContactListDao);
nested exception is java.lang.NoClassDefFoundError:
org/apache/kafka/clients/producer/Callback at
org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:292)
the above code is from my project which is in production ,so there are no chance of java errors (#AUTOWIRED ) OR annotation based errors , my question is , is there any other possibility of getting this type of error .

Excecption upon start of tomcat server with spring application

All of a sudden started to get following error upon starting the server.
Switched from java 1.8 to java 1.7 but no luck...
SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.filterChains': Cannot resolve reference to bean 'org.springframework.security.web.DefaultSecurityFilterChain#4' while setting bean property 'sourceList' with key [4]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.web.DefaultSecurityFilterChain#4': Cannot resolve reference to bean 'mobileFilter' while setting constructor argument with key [2]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mobileFilter' defined in ServletContext resource [/WEB-INF/classes/security-context.xml]: Cannot resolve reference to bean 'authenticationManager' while setting bean property 'authenticationManager'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'authenticationManager' defined in ServletContext resource [/WEB-INF/classes/security-context.xml]: Cannot resolve reference to bean 'daoAuthenticationProvider' while setting bean property 'providers' with key [0]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'daoAuthenticationProvider' defined in ServletContext resource [/WEB-INF/classes/security-context.xml]: Cannot resolve reference to bean 'userDetailsService' while setting bean property 'userDetailsService'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userDetailsService' defined in ServletContext resource [/WEB-INF/classes/security-context.xml]: Error setting property values; nested exception is org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'personClientFactory' threw exception; nested exception is java.lang.NullPointerException
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.web.DefaultSecurityFilterChain#4': Cannot resolve reference to bean 'mobileFilter' while setting constructor argument with key [2]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mobileFilter' defined in ServletContext resource [/WEB-INF/classes/security-context.xml]: Cannot resolve reference to bean 'authenticationManager' while setting bean property 'authenticationManager'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'authenticationManager' defined in ServletContext resource [/WEB-INF/classes/security-context.xml]: Cannot resolve reference to bean 'daoAuthenticationProvider' while setting bean property 'providers' with key [0]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'daoAuthenticationProvider' defined in ServletContext resource [/WEB-INF/classes/security-context.xml]: Cannot resolve reference to bean 'userDetailsService' while setting bean property 'userDetailsService'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userDetailsService' defined in ServletContext resource [/WEB-INF/classes/security-context.xml]: Error setting property values; nested exception is org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'personClientFactory' threw exception; nested exception is java.lang.NullPointerException

springboot app not starting - error (Stopped o.s.b.c.e.j.JettyEmbeddedWebAppContext)

I'm having problem while starting restful spring boot app. On seeing the error stacktrace, I could see some exceptions related to jetty.
I could see the below log.
Started o.s.b.c.e.j.JettyEmbeddedWebAppContext#26586b74{/,file:/C:/Windows/Temp/jetty-docbase.8144885224534920922.8080/,AVAILABLE}
I did check C:/windows/Temp and I couldn't find jetty-docbase.8144885224534920922.8080
It would be great if someone can help me in fixing this issue. How I can create that file so that jetty will identify it?
Below is the complete stack trace.
mo.e.jetty.server.handler.ContextHandler; Started o.s.b.c.e.j.JettyEmbeddedWebAppContext#26586b74{/,file:/C:/Windows/Temp/jetty-docbase.8144885224534920922.8080/,AVAILABLE}
morg.eclipse.jetty.server.Server Started #7364ms
mationConfigEmbeddedWebApplicationContext Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'configController': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.lewis.web.app.operations.dashboard.models.BuildInformation com.lewis.web.app.operations.dashboard.controllers.ConfigController.buildInformation; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'buildInformationProperties': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private java.lang.String com.lewis.web.app.operations.dashboard.models.BuildInformationProperties.version; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'build.version' in string value "${build.version}"
mo.e.jetty.server.handler.ContextHandle Stopped o.s.b.c.e.j.JettyEmbeddedWebAppContext#26586b74{/,file:/C:/Windows/Temp/jetty-docbase.8144885224534920922.8080/,UNAVAILABLE}
mo.s.boot.SpringApplication Application startup failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'configController': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.lewis.web.app.operations.dashboard.models.BuildInformation com.lewis.web.app.operations.dashboard.controllers.ConfigController.buildInformation; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'buildInformationProperties': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private java.lang.String com.lewis.web.app.operations.dashboard.models.BuildInformationProperties.version; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'build.version' in string value "${build.version}"
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:334)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1214)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:307)
at com.lewis.web.app.Application.main(Application.java:25)
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.lewis.web.app.operations.dashboard.models.BuildInformation com.lewis.web.app.operations.dashboard.controllers.ConfigController.buildInformation; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'buildInformationProperties': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private java.lang.String com.lewis.web.app.operations.dashboard.models.BuildInformationProperties.version; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'build.version' in string value "${build.version}"
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:573)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:331)
... 15 common frames omitted
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'buildInformationProperties': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private java.lang.String com.lewis.web.app.operations.dashboard.models.BuildInformationProperties.version; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'build.version' in string value "${build.version}"
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:334)
... 17 common frames omitted
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private java.lang.String com.lewis.web.app.operations.dashboard.models.BuildInformationProperties.version; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'build.version' in string value "${build.version}"
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:573)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:331)
... 37 common frames omitted
Caused by: java.lang.IllegalArgumentException: Could not resolve placeholder 'build.version' in string value "${build.version}"
at org.springframework.util.PropertyPlaceholderHelper.parseStringValue(PropertyPlaceholderHelper.java:174)
Many Thanks in advance...
Your actual exception is:
Caused by: java.lang.IllegalArgumentException: Could not resolve placeholder 'build.version' in string value "${build.version}"
This means, that Spring application fails create context and to start, because can't create some of the beans because it can not resolve some required autowired variable, in you case it's a build.version. You can try to add this variable as command line argument or add it as a property into the application.properies file. Or you may locate the bean (it's name is buildInformationProperties, where this value should be autowird and try to figure out, why you dont't have it by default.

Error creating bean with name springApplicationAdminRegistrar

I have started getting below exception after I migrated project from Spring Boot version from 1.2.3.RELEASE to 1.3.0.RELEASE.
Error creating bean with name 'springApplicationAdminRegistrar'
defined in class path resource
[org/springframework/boot/autoconfigure/admin/SpringApplicationAdminJmxAutoConfiguration.class]:
Invocation of init method failed; nested exception is
javax.management.InstanceAlreadyExistsException:
org.springframework.boot:type=Admin,name=SpringApplication
Stacktrace around this error is:
WARN o.s.c.a.AnnotationConfigApplicationContext:545 - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'springApplicationAdminRegistrar' defined in class path resource [org/springframework/boot/autoconfigure/admin/SpringApplicationAdminJmxAutoConfiguration.class]: Invocation of init method failed; nested exception is javax.management.InstanceAlreadyExistsException: org.springframework.boot:type=Admin,name=SpringApplication
INFO o.s.j.e.a.AnnotationMBeanExporter:449 - Unregistering JMX-exposed beans on shutdown
WARN o.s.b.f.s.DefaultListableBeanFactory:1480 - Bean creation exception on FactoryBean type check: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userManagementDAO' defined in file [${PATH_TO_PROJECT}\target\classes\com\mycom\myproject\mappers\UserManagementDAO.class]: Unsatisfied dependency expressed through bean property 'sqlSessionFactory': : Error creating bean with name 'getSqlSessionFactory' defined in class path resource [com/mycom/myproject/config/DAOConfig.class]: Invocation of init method failed; nested exception is java.lang.ExceptionInInitializerError; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'getSqlSessionFactory' defined in class path resource [com/mycom/myproject/config/DAOConfig.class]: Invocation of init method failed; nested exception is java.lang.ExceptionInInitializerError
WARN o.s.b.f.s.DefaultListableBeanFactory:1480 - Bean creation exception on FactoryBean type check: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userManagementDAO' defined in file [${PATH_TO_PROJECT}\target\classes\com\mycom\myproject\mappers\UserManagementDAO.class]: Unsatisfied dependency expressed through bean property 'sqlSessionFactory': : Error creating bean with name 'getSqlSessionFactory': Requested bean is currently in creation: Is there an unresolvable circular reference?; nested exception is org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'getSqlSessionFactory': Requested bean is currently in creation: Is there an unresolvable circular reference?
WARN o.s.b.f.s.DefaultListableBeanFactory:1480 - Bean creation exception on FactoryBean type check: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userManagementDAO' defined in file [${PATH_TO_PROJECT}\target\classes\com\mycom\myproject\mappers\UserManagementDAO.class]: Unsatisfied dependency expressed through bean property 'sqlSessionFactory': : Error creating bean with name 'getSqlSessionFactory': Requested bean is currently in creation: Is there an unresolvable circular reference?; nested exception is org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'getSqlSessionFactory': Requested bean is currently in creation: Is there an unresolvable circular reference?
WARN o.s.b.f.s.DefaultListableBeanFactory:1480 - Bean creation exception on FactoryBean type check: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'sampleDAO' defined in file [${PATH_TO_PROJECT}\target\classes\com\mycom\myproject\mappers\SampleDAO.class]: Unsatisfied dependency expressed through bean property 'sqlSessionFactory': : Error creating bean with name 'getSqlSessionFactory' defined in class path resource [com/mycom/myproject/config/DAOConfig.class]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: Could not initialize class com.mycom.myproject.entities.master.Method; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'getSqlSessionFactory' defined in class path resource [com/mycom/myproject/config/DAOConfig.class]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: Could not initialize class com.mycom.myproject.MyEntity
WARN o.s.b.f.s.DefaultListableBeanFactory:1480 - Bean creation exception on FactoryBean type check: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'sampleDAO' defined in file [${PATH_TO_PROJECT}\target\classes\com\mycom\myproject\mappers\SampleDAO.class]: Unsatisfied dependency expressed through bean property 'sqlSessionFactory': : Error creating bean with name 'getSqlSessionFactory' defined in class path resource [com/mycom/myproject/config/DAOConfig.class]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: Could not initialize class com.mycom.myproject.entities.master.Method; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'getSqlSessionFactory' defined in class path resource [com/mycom/myproject/config/DAOConfig.class]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: Could not initialize class com.mycom.myproject.MyEntity
Any pointer to debug this issue?
Context was loading manually(Java Code) from code for fetching a bean, removing which resolved the issue.
However my problem is solved but still not sure how it was working with last version of spring boot.

Categories

Resources