Stream: hapi
Topic: Fhir Sever Not Starting
Neil Lott (Dec 29 2020 at 01:18):
Has anyone seen this one?
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2020-12-28 18:11:24.763 ERROR 9967 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :
APPLICATION FAILED TO START
Description:
Field myEntityManagerFactory in ca.uhn.fhir.jpa.search.builder.SearchBuilder required a bean of type 'ca.uhn.fhir.jpa.config.HapiFhirLocalContainerEntityManagerFactoryBean' that could not be found.
The injection point has the following annotations:
- @org.springframework.beans.factory.annotation.Autowired(required=true)
Action:
Consider defining a bean of type 'ca.uhn.fhir.jpa.config.HapiFhirLocalContainerEntityManagerFactoryBean' in your configuration.
I'm attempting to wrap a fhir server in spring-boot and i'm seeing this now.
Jens Villadsen (Dec 29 2020 at 10:27):
Which version of HAPI are you using?
Neil Lott (Dec 29 2020 at 17:57):
5.2.0
Jens Villadsen (Dec 29 2020 at 20:12):
@Neil Lott look at the following it should get you around it:
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory(FhirContext fhirContext,
DataSource dataSource,
ConfigurableListableBeanFactory beanFactory,
JtaTransactionManager jtaTransactionManager,
JpaVendorAdapter jpaVendorAdapter) {
LocalContainerEntityManagerFactoryBean entityManagerFactoryBean = new HapiFhirLocalContainerEntityManagerFactoryBean();
try {
entityManagerFactoryBean.setJpaVendorAdapter(jpaVendorAdapter);
entityManagerFactoryBean.setJtaDataSource(dataSource);
entityManagerFactoryBean.getJpaPropertyMap().putAll(getHibernateProperties(beanFactory, jtaTransactionManager));
BaseConfig.configureEntityManagerFactory(entityManagerFactoryBean, fhirContext);
entityManagerFactoryBean.setPersistenceUnitName("HAPI_PU");
} catch (Exception e) {
throw new ConfigurationException("Could create LocalContainerEntityManagerFactoryBean due to a configuration issue", e);
}
return entityManagerFactoryBean;
}
@James Agnew you should be aware of this
Kishore Karanam (Jan 28 2021 at 20:43):
Me too facing the same issue. Any solution for the same?
Sergej Reiser (Mar 11 2021 at 12:34):
@Jens Villadsen Could you please ellaborate a little further on your solution?
I am trying to upgrade from HAPI 5.1.0 to 5.2.1 but the server fails to start and throws the same Excepation as descirbed in the first post.
Jens Villadsen (Mar 11 2021 at 12:46):
Have you tried on 5.3.0 now that it is released?
Sergej Reiser (Mar 11 2021 at 12:55):
Yes i also tried to use 5.3.0 which ends up in the same issue.
Im using hapi-fhir-spring-boot-starter to run a FHIR-Server in a spring-boot based project.
The reason why i tried to upgrade to 5.2.1 first is that there is a sample project which i always used as a reference (apparently this sample was removed in 5.3.0): hapi-fhir-spring-boot-sample-server-jpa.
But even this sample project fails with the same Exception.
I am aware, that there is another sample project (hapi-fhir-jpaserver-starter) but that one doesn't use the hapi-fhir-spring-boot-starter.
Jens Villadsen (Mar 11 2021 at 13:03):
https://github.com/hapifhir/hapi-fhir-jpaserver-starter is the only one that I co-maintain - the other ones are not really maintained anymore
Sergej Reiser (Mar 11 2021 at 15:59):
But HAPI's spring-boot-starter itself (hapi-fhir-spring-boot-starter) is still being maintained as it got a release for 5.3.0 and a pre-release for 5.4.0-PRE1-SNAPSHOT.
It just doesn't seem to work out-of-the-box as it used to do.
Maybe i am mistaken, but shouldn't a spring-boot-starter provide convenient functionality to automatically wire up your application by simply adding the starter to the classpath?
In other words: Shouldn't your code snipped be part of hapi-fhir-spring-boot-starter / hapi-fhir-spring-boot-autoconfigure?
Patrick Werner (Mar 11 2021 at 16:04):
The jpa-starter is the only maintained way of getting a ready to use hapi instance. hapi-fhir-spring-boot-starter might have got some (search replace version updates, but no maintainance. Look for yourself: https://github.com/hapifhir/hapi-fhir/commits/master/hapi-fhir-spring-boot)
Patrick Werner (Mar 11 2021 at 16:06):
the spring boot project was a community contribution quite some time ago. Afaik there is no maintainer for this part of hapi. So it can work, or it can't. I would take the safe route with the jpa starter project.
Sergej Reiser (Mar 12 2021 at 08:35):
@Patrick Werner thank you for clarifying! I falsely assumed, that every artifact located at https://github.com/hapifhir/hapi-fhir is being maintained. And since the artifacts are being released to Maven-Central i didn't even bother to check the commits. Maybe it should be mentioned in the artifact's readme file.
We have been using hapi-fhir-spring-boot-starter since 4.1.0 and it has served us very well thus far. We will look into hapi-fhir-jpaserver-starter though in order to upgrade to a newer version.
Patrick Werner (Mar 12 2021 at 08:47):
Yes adding a disclaimer to the Readme which points to the jpastarter project sounds like a good idea. @James Agnew ?
James Agnew (Mar 12 2021 at 13:55):
Definitely agreed
Matthew Dickie (Aug 26 2021 at 15:45):
Hi,
In Instant OpenHIE our scripts aren't working with an update from v5.2.1 to v5.4.1 - all in docker.
Previously, HAPI v5.2.1 connected to a MySQL DB (v5.7) when we configured Spring with the following:
- spring.datasource.url=jdbc:mysql://mysql:3306/hapi
- spring.datasource.username=admin
- spring.datasource.password=<password>
- spring.datasource.driverClassName=com.mysql.cj.jdbc.Driver
- spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect
With HAPI v5.3 onwards the service crashes with the following logs:
2021-08-26 15:19:21.889 [main] WARN o.h.e.jdbc.spi.SqlExceptionHelper [SqlExceptionHelper.java:137] SQL Error: 1146, SQLState: 42S02
2021-08-26 15:19:21.890 [main] ERROR o.h.e.jdbc.spi.SqlExceptionHelper [SqlExceptionHelper.java:142] Table 'hapi.HFJ_RESOURCE' doesn't exist
2021-08-26 15:19:21.892 [main] ERROR c.u.f.j.s.b.sql.SearchQueryExecutor [SearchQueryExecutor.java:136] Failed to create or execute SQL query
org.hibernate.exception.SQLGrammarException: could not extract ResultSet
When I searched through MySQL DB I see that the table name casing has changed from upper to lower case.
Hence HFJ_RESOURCE never resolved to hfj_resource.
I've tried using the following config to try prevent tables being created in lowercase but no luck:
- spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.SpringImplicitNamingStrategy
- spring.jpa.hibernate.naming.physical-strategy.case-insensitive=false
Not sure what other combinations are out there.
Does anyone have any suggestions for how to resolve the resource table names?
Richard Stanley (Aug 26 2021 at 22:36):
@Kevin Dougan can you have a peek at this one please?
Kevin Dougan (Aug 27 2021 at 12:30):
Hi @Matthew Dickie ,
What O/S are you using for your MySQL DB?
Also, if you can get access to the DB Server, what is the current value of the MySQL system variable called lower_case_table_names?
You might have to change that MySQL system variable, according to the following documentation:
https://dev.mysql.com/doc/refman/5.7/en/identifier-case-sensitivity.html
Matthew Dickie (Aug 27 2021 at 12:58):
Thanks @Kevin Dougan
MySQL DB is in a docker container from the official source - https://hub.docker.com/_/mysql tag 5.7 - not sure what OS that is - I assume a unix distribution?
The lower_case_table_names
variable is currently set to 0
I'll try to pass in an Environment variable set to 1
Last updated: Apr 12 2022 at 19:14 UTC