{"id":823,"date":"2018-10-31T03:30:17","date_gmt":"2018-10-31T03:30:17","guid":{"rendered":"https:\/\/alphastar.net.au\/weblog\/?p=823"},"modified":"2018-10-31T03:42:00","modified_gmt":"2018-10-31T03:42:00","slug":"docker-access-to-dialectresolutioninfo-cannot-be-null-when-hibernate-dialect-not-set","status":"publish","type":"post","link":"https:\/\/alphastar.net.au\/weblog\/2018\/10\/31\/docker-access-to-dialectresolutioninfo-cannot-be-null-when-hibernate-dialect-not-set\/","title":{"rendered":"Docker: Access to DialectResolutionInfo cannot be null when &#8216;hibernate.dialect&#8217; not set"},"content":{"rendered":"<p>I came across this problem when dockerizing a Springboot application. A number of people have also come across this issue and the answers given weren&#8217;t all that helpful.<\/p>\n<pre>\r\ncom.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure\r\nThe last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.\r\n[...]\r\norg.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]\r\n[...]\r\nCaused by: org.hibernate.HibernateException: Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set\r\nat org.hibernate.engine.jdbc.dialect.internal.DialectFactoryImpl.determineDialect(DialectFactoryImpl.java:100)\r\nat org.hibernate.engine.jdbc.dialect.internal.DialectFactoryImpl.buildDialect(DialectFactoryImpl.java:54)\r\n<\/pre>\n<p>The issue is that a SpringBoot application that interfaces to an external MySQL Database does not connect. The stacktrace given is a bit of a red herring, it has nothing to do with the dialect settings (adding those did not solive the problem).<\/p>\n<p>The problem stems from the networking stack from within Docker. Inside a docker container, loopback addresses such as 127.0.0.1 or localhost\u00a0 <em>will refer to the localhost inside of the container only<\/em>! It <strong>will not<\/strong> refer to any services that are running on the docker host &#8211; that would (in a non docker world) be ordinarily referenced by localhost.<\/p>\n<p>A quick fix is to change the application.properties file to use a qualified IP address and not a loopback address.<\/p>\n<p>For instance change 127.0.0.1 to the output of the command in ipconfig or ifconfig<\/p>\n<p>The result should hopefully look like this<\/p>\n<pre>03:18:30.416 [main] INFO o.a.coyote.http11.Http11NioProtocol - Starting ProtocolHandler [\"http-nio-8080\"]\r\n03:18:30.426 [main] INFO o.a.tomcat.util.net.NioSelectorPool - Using a shared selector for servlet write\/read\r\n03:18:30.469 [main] INFO o.s.b.w.e.tomcat.TomcatWebServer - Tomcat started on port(s): 8080 (http) with context path ''<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>I came across this problem when dockerizing a Springboot application. A number of people have also come across this issue and the answers given weren&#8217;t all that helpful. com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications&#8230; <\/p>\n","protected":false},"author":1,"featured_media":830,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-823","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-coding"],"_links":{"self":[{"href":"https:\/\/alphastar.net.au\/weblog\/wp-json\/wp\/v2\/posts\/823","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/alphastar.net.au\/weblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/alphastar.net.au\/weblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/alphastar.net.au\/weblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/alphastar.net.au\/weblog\/wp-json\/wp\/v2\/comments?post=823"}],"version-history":[{"count":5,"href":"https:\/\/alphastar.net.au\/weblog\/wp-json\/wp\/v2\/posts\/823\/revisions"}],"predecessor-version":[{"id":828,"href":"https:\/\/alphastar.net.au\/weblog\/wp-json\/wp\/v2\/posts\/823\/revisions\/828"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/alphastar.net.au\/weblog\/wp-json\/wp\/v2\/media\/830"}],"wp:attachment":[{"href":"https:\/\/alphastar.net.au\/weblog\/wp-json\/wp\/v2\/media?parent=823"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/alphastar.net.au\/weblog\/wp-json\/wp\/v2\/categories?post=823"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/alphastar.net.au\/weblog\/wp-json\/wp\/v2\/tags?post=823"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}