Open-MBEE / exec-mmsri

Open Source Reference Implementation for MMS Execubots
Apache License 2.0
3 stars 7 forks source link

Application run failed #39

Closed m0squito closed 1 year ago

m0squito commented 2 years ago

Hi,

I'm trying to run OpenMBEE using the docker image (via Docker Hub), per Wiki instructions. When I run the container, I get connection refused errors when Spring is trying to connect to PostrgresSQL. I have no experience with Docker and am not quite sure where/how I should troubleshoot this problem. Any help would be greatly appreciated.

Here's what I get in the command line when I run the container:

2022-05-24 19:59:45.261  INFO 1 --- [           main] org.openmbee.mms.mmsri.MMSRIApplication  : Starting MMSRIApplication on 5fc275c40768 with PID 1 (/application/BOOT-INF/classes started by root in /application)
2022-05-24 19:59:45.278  INFO 1 --- [           main] org.openmbee.mms.mmsri.MMSRIApplication  : No active profile set, falling back to default profiles: default
2022-05-24 19:59:50.798  INFO 1 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2022-05-24 19:59:51.464  INFO 1 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 609ms. Found 15 JPA repository interfaces.
2022-05-24 19:59:56.720  INFO 1 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'persistenceJPAConfig' of type [org.openmbee.mms.rdb.config.PersistenceJPAConfig$$EnhancerBySpringCGLIB$$2ab5809f] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2022-05-24 19:59:57.371  INFO 1 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.security.access.expression.method.DefaultMethodSecurityExpressionHandler@1ab14636' of type [org.springframework.security.access.expression.method.DefaultMethodSecurityExpressionHandler] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2022-05-24 19:59:57.410  INFO 1 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'methodSecurityMetadataSource' of type [org.springframework.security.access.method.DelegatingMethodSecurityMetadataSource] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2022-05-24 19:59:58.959  INFO 1 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8080 (http)
2022-05-24 19:59:59.226  INFO 1 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2022-05-24 19:59:59.247  INFO 1 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.37]
2022-05-24 20:00:00.195  INFO 1 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2022-05-24 20:00:00.196  INFO 1 --- [           main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 14545 ms
2022-05-24 20:00:03.647  INFO 1 --- [           main] o.hibernate.jpa.internal.util.LogHelper  : HHH000204: Processing PersistenceUnitInfo [name: defaultEntityManager]
2022-05-24 20:00:04.060  INFO 1 --- [           main] org.hibernate.Version                    : HHH000412: Hibernate ORM core version 5.4.18.Final
2022-05-24 20:00:04.594  INFO 1 --- [           main] o.hibernate.annotations.common.Version   : HCANN000001: Hibernate Commons Annotations {5.1.0.Final}
2022-05-24 20:00:05.985  WARN 1 --- [           main] o.h.e.j.e.i.JdbcEnvironmentInitiator     : HHH000342: Could not obtain connection to query metadata : Connection to localhost:5432 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.
2022-05-24 20:00:06.064  INFO 1 --- [           main] org.hibernate.dialect.Dialect            : HHH000400: Using dialect: org.hibernate.dialect.PostgreSQL10Dialect
2022-05-24 20:00:10.148  WARN 1 --- [           main] o.h.engine.jdbc.spi.SqlExceptionHelper   : SQL Error: 0, SQLState: 08001
2022-05-24 20:00:10.149 ERROR 1 --- [           main] o.h.engine.jdbc.spi.SqlExceptionHelper   : Connection to localhost:5432 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.
2022-05-24 20:00:10.166  WARN 1 --- [           main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'defaultEntityManager' defined in class path resource [org/openmbee/mms/rdb/config/PersistenceJPAConfig.class]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: defaultEntityManager] Unable to build Hibernate SessionFactory; nested exception is org.hibernate.exception.JDBCConnectionException: Unable to open JDBC Connection for DDL execution
2022-05-24 20:00:10.192  INFO 1 --- [           main] o.apache.catalina.core.StandardService   : Stopping service [Tomcat]
2022-05-24 20:00:10.317  INFO 1 --- [           main] ConditionEvaluationReportLoggingListener :

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2022-05-24 20:00:10.355 ERROR 1 --- [           main] o.s.boot.SpringApplication               : Application run failed

My host machine is an M1-based MacBook Pro.

SteveHespelt commented 2 years ago

Hi Jakub, It's a Docker networking thing - if you're using Docker-compose to launch the services, you'll want to change the uses of localhost to the appropriate service name as the Docker networking will treat the service name as a hostname. If you create a service named 'postgres', then other containers (eg. mms) can reach the 5432 port via jdbc:postgres:5432. For the default network mode being 'bridge'. IHTH. You'll definitely want to read the Docker docs on container networking, both for docker-compose & for containers launch via 'docker run'. Good information. 1 such url is https://docs.docker.com/network/#network-drivers - brief introduction.