APPLICATION FAILED TO START Error starting ApplicationContext - spring

when I run this error comes pleas help me to solve this
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2019-02-11 10:53:55.839 ERROR 8804 --- [ restartedMain] o.s.b.d.LoggingFailureAnalysisReporter :
APPLICATION FAILED TO START
Description:
Field userDao in com.example.spring.security.api.service.UserServiceImpl required a bean named 'entityManagerFactory' that could not be found.
Action:
Consider defining a bean named 'entityManagerFactory' in your configuration.

What annotations are you using? Could be that you are using some annotation that tells Spring boot to not use some autoconfiguration.
You probably want HibernateJpaAutoConfiguration to run.

Related

Hibernate: Could not obtain connection to query metadata

I'm following Amigoscode tutorial Getting Started with Spring Boot and I'm currently trying to connect to my local database, but I get an error:
HHH000342: Could not obtain connection to query metadata
What I've learned is that Hibernate recent version works different, so the tutorial content it out of data. So I was wondering, can use a older version of Hibernate?
I can also be totally wrong about Hibernate. If this is a command error plz give me some information.
spring.datasource.url=jdbc:postgresql://localhost:5432/student
spring.datasource.username=postgres
spring.datasource.password=******
spring.jpa.hibernate.ddl-auto=create-drop
spring.java.show-sql=true
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PosterSQLDialect
spring.jpa.properties.hibernate.format_sql=true
NEW ERROR
49.203 ERROR 9572 --- [ main] j.LocalContainerEntityManagerFactoryBean : Failed to initialize JPA EntityManagerFactory: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]
2022-04-06 11:39:49.203 WARN 9572 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Invocation of init method failed; nested exception is org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]
There is no meaning of PosterSQLDialect in configuration of hibernate dialect. It should be PostgreSQLDialect.
Change
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PosterSQLDialect
To
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.PostgreSQLDialect

Error when trying to run test in springboot

I try to run some tests but somehow spring gets confused and I get the error below that appears to be some clash between some beans that Spring tries to instantiate. Anyone any ideas?
***************************
APPLICATION FAILED TO START
***************************
Description:
An attempt was made to call a method that does not exist. The attempt was made from the following location:
org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration$EnableWebMvcConfiguration.resourceHandlerMapping(WebMvcAutoConfiguration.java:408)
The following method did not exist:
org.springframework.web.servlet.config.annotation.DelegatingWebMvcConfiguration.resourceHandlerMapping(Lorg/springframework/web/util/UrlPathHelper;Lorg/springframework/util/PathMatcher;Lorg/springframework/web/accept/ContentNegotiationManager;Lorg/springframework/format/support/FormattingConversionService;Lorg/springframework/web/servlet/resource/ResourceUrlProvider;)Lorg/springframework/web/servlet/HandlerMapping;
The method's class, org.springframework.web.servlet.config.annotation.DelegatingWebMvcConfiguration, is available from the following locations:
jar:file:/home/test/stuff/.m2/repository/org/springframework/spring-webmvc/5.3.13/spring-webmvc-5.3.13.jar!/org/springframework/web/servlet/config/annotation/DelegatingWebMvcConfiguration.class
The class hierarchy was loaded from the following locations:
org.springframework.web.servlet.config.annotation.DelegatingWebMvcConfiguration: file:/home/test/stuff/.m2/repository/org/springframework/spring-webmvc/5.3.13/spring-webmvc-5.3.13.jar
org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport: file:/home/test/stuff/.m2/repository/org/springframework/spring-webmvc/5.3.13/spring-webmvc-5.3.13.jar
Action:
Correct the classpath of your application so that it contains a single, compatible version of org.springframework.web.servlet.config.annotation.DelegatingWebMvcConfiguration
2021-12-16 19:46:21.564 ERROR [cc-task-allocation-backend,,,] 5484 --- [ main] o.s.test.context.TestContextManager : Caught exception while allowing TestExecutionListener [org.springframework.test.context.web.ServletTestExecutionListener#5ef5c734] to prepare test instance [eu.europa.ec.cc.taskallocation.services.RuleServiceUniformDistTest#61d4171d]
java.lang.IllegalStateException: Failed to load ApplicationContext
at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:132)
Dependency management issue as the org.junit.jupiter dependencies were overwritten by a starter.

Error after dependency of Redis (spring-boot-starter-data-redis) added in spring-boot

When I add below dependency to pom.xml
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
Below error comes
2018-05-31 12:02:38.217 INFO 1416 --- [ost-startStop-1]
j.LocalContainerEntityManagerFactoryBean : Initialized JPA
EntityManagerFactory for persistence unit 'default' 2018-05-31
12:02:39.233 ERROR 1416 --- [ost-startStop-1]
o.s.b.c.embedded.tomcat.TomcatStarter : Error starting Tomcat
context. Exception:
org.springframework.beans.factory.UnsatisfiedDependencyException.
Message: Error creating bean with name
'registerCorePageControllerServlet' defined in
com.amd.apps.employee.cloud.AddonApplication:
Unsatisfied dependency expressed through method
'registerCorePageControllerServlet' parameter 1; nested exception is
org.springframework.beans.factory.UnsatisfiedDependencyException:
Error creating bean with name 'authenticationContextImpl' defined in
URL
[jar:file:/C:/Users/shiv/AppData/Local/Temp/employee.cloud-1.0.0.jar-spring-boot-libs-1766ddea-c2ae-424e-9565-d00395eb0d5c/core.cloud-1.0.0.jar!/com/amd/apps/cloud/service/common/AuthenticationContextImpl.class]:
Unsatisfied dependency expressed through constructor parameter 3;
nested exception is
org.springframework.beans.factory.UnsatisfiedDependencyException:
Error creating bean with name 'companyServiceImpl' defined in URL
[jar:file:/C:/Users/shiv/AppData/Local/Temp/employee.cloud-1.0.0.jar-spring-boot-libs-1766ddea-c2ae-424e-9565-d00395eb0d5c/core.cloud-1.0.0.jar!/com/amd/apps/cloud/service/directory/impl/CompanyServiceImpl.class]:
Unsatisfied dependency expressed through constructor parameter 1;
nested exception is
org.springframework.beans.factory.NoSuchBeanDefinitionException: No
qualifying bean of type
'com.atlassian.connect.spring.AtlassianHostRepository' available:
expected at least 1 bean which qualifies as autowire candidate.
Dependency annotations: {}
However if i remove this dependency, everything works perfectly. Redis service is configured, running and accessible. However i see below messages as well, which i do not see during normmal execution
2018-05-31 12:02:28.955 INFO 1416 --- [ main]
.s.d.r.c.RepositoryConfigurationDelegate : Multiple Spring Data
modules found, entering strict repository configuration mode!
2018-05-31 12:02:29.071 INFO 1416 --- [ main]
.RepositoryConfigurationExtensionSupport : Spring Data JPA - Could not
safely identify store assignment for repository candidate interface
com.atlassian.connect.spring.AtlassianHostRepository. 2018-05-31
12:02:29.171 INFO 1416 --- [ main]
.s.d.r.c.RepositoryConfigurationDelegate : Multiple Spring Data
modules found, entering strict repository configuration mode!
The problem is caused by RedisRepositoriesAutoConfiguration. It registers EnableRedisRepositories repeatedly only with default config, which with empty basePackages.
To solve the problem, you could exclude RedisRepositoriesAutoConfiguration by:
#SpringBootApplication(
exclude = { RedisRepositoriesAutoConfiguration.class })

Project runs in older version of IDEA, but not newer

I have a spring boot application that runs and functions just fine in IDEA 15.0.4.
Today I tried running it in the latest release of IDEA 2016.1
and I get the following error
2016-03-17 10:06:17.888 WARN 84730 --- [ main] s.c.a.AnnotationConfigApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'configClientBootstrapConfiguration': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException
and then execution stops.
Is there an additional step I have to do to get this to work in the newer version?
I solved this by simply re-cloning the repository and setting up a new project.

Can't start application in IDE with <jar-find> error, but 'gradle bootRun' - works fine

So, i have a problem that can't solve.
I have a multi module gradle project with spring boot runners. With Jpa, Elastic, OrientDb and another configurations provided by spring-data and spring-integration. And i try to start my web application! Write web starter, make annotation scan, so when I use task 'gradle bootRun' - everything start perfectly - app works, all contexts up and life is good.BUT, when i try use my favorite IDE like Intellij idea, or colleague use Eclipse - get an error :
org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with
name 'org.springframework.integration.config.IdGenerato rConfigurer#0':
BeanPostProcessor before instantiation of bean failed; nested exception is
org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with
name org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration':
Initialization of bean failed; nested exception is java.lang.NoSuchMethodError:
org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration.setBeanFactory(Lo rg/springframework/beans/factory/BeanFactoryV
That cause by (projectName - is fake):
java.lang.RuntimeException: error trying to scan <jar-file>:
file:/home/<user>/project/<projectName>/classes/production/<projectName>-system-webapp/
But i have NO /projectName/classes/production/ folder! Anyway - with gradle it's work fine.
And to be honestly, before this another error catched:
Error creating bean with name 'entityManagerFactory' defined in class com.project.system.jpa.PepperJpaConfiguration: Invocation of init method failed
caused by:
error trying to scan <jar-file>: file:/home/<user>/project/<projectName>/classes/production/<projectName>-system-webapp/
Thank you for advice! Can give additional info.
P.S : Edited
So, the problem was solved:
I do not provide important error stacktrace like:
at org.hibernate.ejb.packaging.NativeScanner.getFilesInJar(NativeScanner.java:195)
at org.hibernate.ejb.Ejb3Configuration.addScannedEntries(Ejb3Configuration.java:506)
at org.hibernate.ejb.Ejb3Configuration.scanForClasses(Ejb3Configuration.java:861)
... 21 more
Caused by: java.io.IOException: invalid constant type: 18 at 50
And this was and JDK8-Hibernate-javassist problem https://hibernate.atlassian.net/browse/HHH-8286
When upgrade javassist version to 3.18.1-GA - all problems was solved(but why run through gradle worked perfectly...)

Resources