0

I created small app what is using Hibernate and Spring boot. I have MySQL db on external server with some 123.123.12.123 IP address.

When I run this app locally (on Windows) via java -jar myapp.jar there is no problem, app is starting and everything is ok. The problem is appear when I am try run this app in Docker. App even not start. There is HibernateException:

Caused by: org.hibernate.HibernateException: Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set

I am sure it is because I cannot connect to db. (I have same issue when I was trying connect locally and db was not available). So what should I do to fix it? This is my application.properties:

spring.datasource.url=jdbc:mysql://123.123.12.123:3306/szoplist_db
spring.datasource.username=root
spring.datasource.password=my_passwd

EDIT:

I am running docker image via docker run -p 8080:8080 <IMAGE_ID>.

Dockerfile:

FROM openjdk:8-jdk-alpine
VOLUME /tmp
ARG JAR_FILE

ADD ${JAR_FILE} /app.jar

ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"]

Another apps (without db) with the same Dockerfile and run command works.

  • Please specify your `docker run` command. Docker file of your app might also help. Did you try to ping the ip from the container? You can also try one of the solutions from https://stackoverflow.com/q/20430371/2065796 – Sasha Shpota Mar 16 '18 at 08:14
  • Yes, sir! Done. –  Mar 16 '18 at 08:26
  • I have internet in my docker toolbox - I can ping to my `123.123.12.123` server(as `docker@192.168.99.100`). –  Mar 16 '18 at 08:34
  • What do you mean by `as docker@192.168.99.100`? Does `docker run -it openjdk:8-jdk-alpine ping 123.123.12.123` work? – Sasha Shpota Mar 16 '18 at 08:37
  • `ping 123.123.12.123` works. `123.123.12.123` it is only IP of my external MySQL server. Docker what I use is locally on my PC. –  Mar 16 '18 at 08:42
  • And yes, `docker run -it openjdk:8-jdk-alpine ping 123.123.12.123` works. –  Mar 16 '18 at 08:53
  • It might be that the problem is in hibernate setup. Make sure that the correct spring profile gets picked in docker (the correct `application.properties`). Does the exception have `caused by` sections? Posting full stack-trace might also help. – Sasha Shpota Mar 16 '18 at 09:02

0 Answers0