autowire dependency exception , - java

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 .

Related

Spring boot project on Heroku unable to use application.yml

As the title states I'm trying to deploy a spring boot application to heroku.
Under /resources I have an application.yml file from which I inject properties using #Value annotation.
During boot I get a stacktrace but I believe the relevant part is the below
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private dk.fitfit.remotetexting.util.GoogleAuth dk.fitfit.remotetexting.api.controller.MessageController.googleAuth; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'googleAuth': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private dk.fitfit.remotetexting.business.service.ConfigurationService dk.fitfit.remotetexting.util.GoogleAuth.configurationService; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'configurationService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private java.lang.String dk.fitfit.remotetexting.business.service.ConfigurationService.clientId; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'security.oauth2.client.clientId' in string value "${security.oauth2.client.clientId}"
Basically it says it can't create my ConfigurationService because it can't resolve my placeholder 'security.oauth2.client.clientId'.
#Service
public class ConfigurationService {
#Value("${security.oauth2.client.clientId}")
private String clientId;
#Value("${fcm.auth_key}")
private String AUTH_KEY_FCM;
#Value("${fcm.api_url}")
private String API_URL_FCM;
...
}
Any clues about how to make heroku use my application.yml file?
I forgot to include application.yml file in my repository... doh!

Can not find processes folder when using spring boot and activiti

I have already put processes folder under resources as spring boot activiti user guide said. Here is my structure.
When I use :
1. mvn clean package
2. java -jar target/xxx.jar
It will raise following exception:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire method: public void org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration.setFilterChainProxySecurityConfigurer(org.springframework.security.config.annotation.ObjectPostProcessor,java.util.List) throws java.lang.Exception; nested exception is org.springframework.beans.factory.BeanExpressionException: Expression parsing failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.activiti.spring.boot.SecurityAutoConfiguration$SecurityConfiguration': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire method: public void org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter.setAuthenticationConfiguration(org.springframework.security.config.annotation.authentication.configuration.AuthenticationConfiguration); nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.config.annotation.authentication.configuration.AuthenticationConfiguration': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire method: public void org.springframework.security.config.annotation.authentication.configuration.AuthenticationConfiguration.setGlobalAuthenticationConfigurers(java.util.List) throws java.lang.Exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.activiti.spring.boot.SecurityAutoConfiguration$UserDetailsServiceConfiguration': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.activiti.engine.IdentityService org.activiti.spring.boot.SecurityAutoConfiguration$UserDetailsServiceConfiguration.identityService; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'identityServiceBean' defined in class path resource [org/activiti/spring/boot/JpaProcessEngineAutoConfiguration$JpaConfiguration.class]: Unsatisfied dependency expressed through constructor argument with index 0 of type [org.activiti.engine.ProcessEngine]: : Error creating bean with name 'processEngine' defined in class path resource [org/activiti/spring/boot/JpaProcessEngineAutoConfiguration$JpaConfiguration.class]: Unsatisfied dependency expressed through constructor argument with index 0 of type [org.activiti.spring.SpringProcessEngineConfiguration]: : Error creating bean with name 'springProcessEngineConfiguration' defined in class path resource [org/activiti/spring/boot/JpaProcessEngineAutoConfiguration$JpaConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.activiti.spring.SpringProcessEngineConfiguration]: Factory method 'springProcessEngineConfiguration' threw exception; nested exception is java.io.FileNotFoundException: class path resource [processes/] cannot be resolved to URL because it does not exist; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'springProcessEngineConfiguration' defined in class path resource [org/activiti/spring/boot/JpaProcessEngineAutoConfiguration$JpaConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.activiti.spring.SpringProcessEngineConfiguration]: Factory method 'springProcessEngineConfiguration' threw exception; nested exception is java.io.FileNotFoundException: class path resource [processes/] cannot be resolved to URL because it does not exist; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'processEngine' defined in class path resource [org/activiti/spring/boot/JpaProcessEngineAutoConfiguration$JpaConfiguration.class]: Unsatisfied dependency expressed through constructor argument with index 0 of type [org.activiti.spring.SpringProcessEngineConfiguration]: : Error creating bean with name 'springProcessEngineConfiguration' defined in class path resource [org/activiti/spring/boot/JpaProcessEngineAutoConfiguration$JpaConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.activiti.spring.SpringProcessEngineConfiguration]: Factory method 'springProcessEngineConfiguration' threw exception; nested exception is java.io.FileNotFoundException: class path resource [processes/] cannot be resolved to URL because it does not exist; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'springProcessEngineConfiguration' defined in class path resource [org/activiti/spring/boot/JpaProcessEngineAutoConfiguration$JpaConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.activiti.spring.SpringProcessEngineConfiguration]: Factory method 'springProcessEngineConfiguration' threw exception; nested exception is java.io.FileNotFoundException: class path resource [processes/] cannot be resolved to URL because it does not exist
Then when I execute:
mvn clean
and use idea to run unit test again. It works.
So, why processes folder can not be found when using mvn instead of idea? What is the problem here?
With #stalet help, I update part of pom.xml like this:
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.properties</include>
<include>**/*.xml</include>
</includes>
<filtering>false</filtering>
</resource>
<resource>
<directory>src/main/resources</directory>
</resource>
</resources>
Then it worked! Thanks!
I had the same error similar to this issue but not exactly same setup though. The cause was due to not having any process xml files under src/main/resources/processes/ directory. Once I created a process xml file under the src/main/resources/processes/ directory, the error is gone.

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.

Spring #Autowired not working - BeanCreationException

When I try to deploy file on server error occurs. I'm confused, because this code was working.
Exception
Failed to enable lec2ear-1.0.ear.
Unexpected HTTP response: 500
Request
{
"address" => [("deployment" => "lecture_7")],
"operation" => "deploy"
}
Response
Internal Server Error
{
"outcome" => "failed",
"failure-description" => {"JBAS014671: Failed services" => {"jboss.undertow.deployment.default-server.default-host./mart-parent" => "org.jboss.msc.service.StartException in service jboss.undertow.deployment.default-server.default-host./mart-parent: Failed to start service
Caused by: java.lang.RuntimeException: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'storageController': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private ru.menkin.ea.lec4.model.services.ICategoryService ru.menkin.ea.lec5.controllers.StorageController._categoryService; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'categoryService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private ru.menkin.ea.lec4.model.repositories.CategoryRepository ru.menkin.ea.lec4.model.services.CategoryService.categoryRepository; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'categoryRepository': Cannot resolve reference to bean 'jpaMappingContext' while setting bean property 'mappingContext'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jpaMappingContext': Invocation of init method failed; nested exception is javax.persistence.PersistenceException: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.5.1.v20130918-f2b9fc5): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLException: javax.resource.ResourceException: IJ000453: Unable to get managed connection for java:jboss/recipeDs
Error Code: 0
ICategoryService
public interface ICategoryService
{
public Category create(Category category);
public Category delete(int id) throws Exception;
public List<Category> findAll();
public Category update(Category category) throws Exception;
public Category findById(int id);
}
his implementation
public class CategoryService implements ICategoryService
{
#Autowired
private CategoryRepository categoryRepository;
...
Controller
#Controller
#RequestMapping(value = "/rest")
public class StorageController extends BaseController {
#Autowired
#Qualifier("categoryService")
private ICategoryService _categoryService;
...
database.xml
<djpa:repositories base-package="ru.menkin.ea.lec4.model" />
<bean id="categoryService" class="ru.menkin.ea.lec4.model.services.CategoryService" />
beans.xml
<context:annotation-config />
<context:component-scan base-package="ru.menkin.ea" />
Where my mistake?
Here last cause in your exception message:
Error creating bean with name 'jpaMappingContext': Invocation of init method failed; nested exception is javax.persistence.PersistenceException
Spring could not invoke the init method of your jpaMappingContext because a persistence exception occured - Something went wrong in the database.
So, Spring autowiring is actually working, but it cannot autowire your dependency because of a database problem that occurs when initializing one of the spring beans.
So something in the database or database settings changed since this code last worked. Analyze the full stack trace to find out the root cause of this issue - Which is a database problem.

Spring framework - Context initialization failed - Out of memory space

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)

Categories

Resources