Spring annotation example server loading time it showing error - spring

I am new in spring I am doing spring annotation example in eclipse luna same example working in myeclipse but not working in eclipse
getting this error can any one help me
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'studentController': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.vcs.service.StudentService com.vcs.controller.StudentController.studentService; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'studentServiceImpl': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.vcs.dao.StudentDao com.vcs.service.StudentServiceImpl.studentDao; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'studentdaoImpl': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.hibernate.SessionFactory com.vcs.dao.StudentdaoImpl.sessionFactory; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/DispatcherServlet-servlet.xml]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: org/hibernate/context/CurrentSessionContext
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:286)

Looking at the last error 'java.lang.NoClassDefFoundError' it looks as if you were missing a hibernate dependency (hibernate-core) that contains CurrentSessionContext.

You are getting a NoClassDefFoundError exception for org.hibernate.context.CurrentSessionContext.
My guess is that under your eclipse setup, the required dependencies are not inside your class path.
Check the lib folder inside you war archive for your eclipse build. I am assuming it's a WAR archive from the presence of WEB-INF.
Can I also suggest you format your code in a code block to make for easier reading

Related

Unable to use MicroMeter instead Of Prometheus

I upgraded my Spring Version from 1.5 to 2.0 and upgraded Prometheus version 0.3.0 to 0.6.0. But unfortunately, it was not working. I was told I have to use MicroMeter instead of SimpleClient and added io.micrometer to my pom.xml and #EnablePrometheusEndpointremoved for my MetricConfig class but I come across with following error. Do you know why I get such kind of error ?
Caused by: org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'servletEndpointRegistrar' defined in
class path resource
[org/springframework/boot/actuate/autoconfigure/endpoint/web/ServletEndpointManagementContextConfiguration$WebMvcServletEndpointManagementContextConfiguration.class]:
Bean instantiation via factory method failed; nested exception is
org.springframework.beans.BeanInstantiationException: Failed to
instantiate
[org.springframework.boot.actuate.endpoint.web.ServletEndpointRegistrar]:
Factory method 'servletEndpointRegistrar' threw exception; nested
exception is
org.springframework.beans.factory.UnsatisfiedDependencyException:
Error creating bean with name 'routeControllerEndpoint' defined in
class path resource
[org/apache/camel/spring/boot/actuate/endpoint/CamelRouteControllerEndpointAutoConfiguration.class]:
Unsatisfied dependency expressed through method
'routeControllerEndpoint' parameter 0; nested exception is
org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'camelContext' defined in class path resource
[org/apache/camel/spring/boot/CamelAutoConfiguration.class]:
Post-processing of merged bean definition failed; nested exception is
java.lang.IllegalStateException: Failed to introspect Class
[org.apache.camel.impl.DefaultCamelContext] from ClassLoader
[jdk.internal.loader.ClassLoaders$AppClassLoader#77556fd]

update of spring data elasticsearch to 3.0.7

I have update my spring data elasticsearch to version 3.0.7
I wanna know if i should also update spring core version because after runnig my project an exception thrown
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'restParametrageCompetenceController': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: ma.accolade.ged.ms.gestion.parametrage.service.CompetenceService ma.accolade.ged.ms.gestion.parametrage.controller.RestParametrageCompetenceController.competenceService; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'CompetenceService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: ma.accolade.ged.ms.gestion.parametrage.persistance.CompetencePersistance ma.accolade.ged.ms.gestion.parametrage.service.impl.CompetenceImpl.competenceRepository; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'competencePersistance': Initialization of bean failed; nested exception is java.lang.AbstractMethodError
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:334)
You should use the release-train dependency. This way everything is in sync.
http://projects.spring.io/spring-data/#quick-start

Spring Boot start fails for Autoconfigure on RabbitMQ

I have a large Spring boot application with uses amongst other thing RabbitMQ. I created a #Configuration file for the Rabbit queues. This has been working fine on Spring boot 1.0.2. Today I upgraded version 1.1.0 and now I am getting an exception on startup.
The problem seems to be that the HealthIndicator picks up that RabbitMQ is available and tries to setup a health indicator for it. It then promptly fails because it cannot inject the rabbitTemplate. Part of the error message says, "Error creating bean with name 'rabbitTemplate': Requested bean is currently in creation: Is there an unresolvable circular reference?"
The actual exception trace is included below.
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'environmentMvcEndpoint' defined in class path resource [org/springframework/boot/actuate/autoconfigure/EndpointWebMvcAutoConfiguration.class]: Unsatisfied dependency expressed through constructor argument with index 0 of type [org.springframework.boot.actuate.endpoint.EnvironmentEndpoint]: : Error creating bean with name 'org.springframework.boot.actuate.autoconfigure.EndpointAutoConfiguration': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: java.util.Map org.springframework.boot.actuate.autoconfigure.EndpointAutoConfiguration.healthIndicators; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.actuate.autoconfigure.HealthIndicatorAutoConfiguration$RabbitHealthIndicatorConfiguration': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private java.util.Map org.springframework.boot.actuate.autoconfigure.HealthIndicatorAutoConfiguration$RabbitHealthIndicatorConfiguration.rabbitTemplates; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.cisco.config.queuing.QueuingConfiguration': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: org.springframework.amqp.rabbit.core.RabbitTemplate com.cisco.config.queuing.QueuingConfiguration.rabbitTemplate; nested exception is org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'rabbitTemplate': Requested bean is currently in creation: Is there an unresolvable circular reference?; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.actuate.autoconfigure.EndpointAutoConfiguration': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: java.util.Map org.springframework.boot.actuate.autoconfigure.EndpointAutoConfiguration.healthIndicators; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.actuate.autoconfigure.HealthIndicatorAutoConfiguration$RabbitHealthIndicatorConfiguration': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private java.util.Map org.springframework.boot.actuate.autoconfigure.HealthIndicatorAutoConfiguration$RabbitHealthIndicatorConfiguration.rabbitTemplates; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.cisco.config.queuing.QueuingConfiguration': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: org.springframework.amqp.rabbit.core.RabbitTemplate com.cisco.config.queuing.QueuingConfiguration.rabbitTemplate; nested exception is org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'rabbitTemplate': Requested bean is currently in creation: Is there an unresolvable circular reference?
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:747) ~[spring-beans-4.0.5.RELEASE.jar!/:4.0.5.RELEASE]
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:462) ~[spring-beans-4.0.5.RELEASE.jar!/:4.0.5.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1094) ~[spring-beans-4.0.5.RELEASE.jar!/:4.0.5.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:989) ~[spring-beans-4.0.5.RELEASE.jar!/:4.0.5.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:504) ~[spring-beans-4.0.5.RELEASE.jar!/:4.0.5.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475) ~[spring-beans-4.0.5.RELEASE.jar!/:4.0.5.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:304) ~[spring-beans-4.0.5.RELEASE.jar!/:4.0.5.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228) ~[spring-beans-4.0.5.RELEASE.jar!/:4.0.5.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:300) ~[spring-beans-4.0.5.RELEASE.jar!/:4.0.5.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200) ~[spring-beans-4.0.5.RELEASE.jar!/:4.0.5.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:470) ~[spring-beans-4.0.5.RELEASE.jar!/:4.0.5.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:459) ~[spring-beans-4.0.5.RELEASE.jar!/:4.0.5.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.getBeansOfType(AbstractApplicationContext.java:1063) ~[spring-context-4.0.5.RELEASE.jar!/:4.0.5.RELEASE]
at org.springframework.boot.actuate.endpoint.mvc.MvcEndpoints.afterPropertiesSet(MvcEndpoints.java:55) ~[spring-boot-actuator-1.1.0.RELEASE.jar!/:1.1.0.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1612) ~[spring-beans-4.0.5.RELEASE.jar!/:4.0.5.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1549) ~[spring-beans-4.0.5.RELEASE.jar!/:4.0.5.RELEASE]
... 92 common frames omitted
This looks like a bug with the new health indicators in Spring Boot. I've raised https://github.com/spring-projects/spring-boot/issues/1081.
Until it's fixed you can disable the HealthIndicatorAutoConfiguration for rabbit by setting health.rabbit.enabled=false in your application.properties.

I am working on a spring and hibernate web application MySQLDialect not found

When i deploy it shows following error
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.hibernate.SessionFactory com.quad.dao.RoleDAOImpl.sessionFactory; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/mvc-dispatcher-servlet.xml]: Invocation of init method failed; nested exception is org.hibernate.HibernateException: Dialect class not found: org.hibernate.dialect.MySQLDialect
but i have hibernate jar file in lib folder.I dont understand why it is giving error.
You do not have your hibernate jar file in your classpath. Add the jars to your classpath and do a clean build.

Weird ClassNotFoundException in WebLogic 10.3.6

We have an .ear file that is running normal in a WebLogic 10.3.6 application server.
The .ear uses Spring 3.0.5 and Hibernate 3.5.2.
If we deploy the same .ear file in another WebLogic 10.3.6 server, we get the next error.
org.springframework.web.context.ContextLoader initWebApplicationContext
SEVERE: Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'filterService': Autowiring of fields failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private nl.surf.adapter.generic.dao.MessageFilterDAO nl.surf.adapter.generic.service.FilterService.messageFilterDAO; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/domain-config.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private nl.surf.adapter.generic.dao.MessageFilterDAO nl.surf.adapter.generic.service.FilterService.messageFilterDAO; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/domain-config.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/domain-config.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError
Caused by: org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError
Caused by: java.lang.NoClassDefFoundError
Caused by: java.lang.ClassNotFoundException: org.hibernate.cfg.Configuration
I've tried several solutions:
Place hibernate3.jar in .war/WEB-INF/lib (all jars are now in .ear/lib)
Use <prefer-web-inf-classes>true</prefer-web-inf-classes> in .war/WEB-INF/weblogic.xml
Nothing seems to work.
I'm kind of lost here...
After some extensive searching on the web and trial and error changes on the .ear, i've found the solution for my problem.
I've changed file META-INF/weblogic-application.xml and added the tags beneath inside tag <weblogic-application>
<prefer-application-packages>
<package-name>org.apache.*</package-name>
<package-name>antlr.*</package-name>
</prefer-application-packages>

Resources