Docker Community Forums

Share and learn in the Docker community.

Table Doesn't Exist Error When Java MVC app in Docker Container Try to Connect To MySql in Another Container

docker

(Wexwuffley) #1

I have a Java-Hibernate MVC web application that uses a mySql database. It works fine on my computer but doesn’t work when I try to run it using docker containers. I am using Docker Toolbox on Windows Home because the latest version of Docker requires Windows Professional.

--------Please ignore any typos in the database, function and class names of my code snippets. I quickly changed them on this form to retain anonymity. In reality all names in my code are fine. I have verified a few times over that there are no typos. -------

I have an MVC web application running on Tomcat in one container and a mySql database running in the other. I think my application can connect to the database because I am able to load the home page in my web application in one of the Docker containers without error. But when I try to put something in one of the MySql tables I get the following error:


com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table ‘no_visits.visitors’ doesn’t exist
sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
java.lang.reflect.Constructor.newInstance(Constructor.java:423)
com.mysql.jdbc.Util.handleNewInstance(Util.java:425)
com.mysql.jdbc.Util.getInstance(Util.java:408)
com.mysql.jdbc.SQLError.createSQLException(SQLError.java:944)
com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3973)
com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3909)
com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2527)
com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2680)
com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2484)
com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1858)
com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1966)
com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeQuery(NewProxyPreparedStatement.java:353)
org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.extract(ResultSetReturnImpl.java:60)
org.hibernate.loader.Loader.getResultSet(Loader.java:2168)
org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1931)
org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1893)
org.hibernate.loader.Loader.doQuery(Loader.java:938)
org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:341)
org.hibernate.loader.Loader.doList(Loader.java:2692)
org.hibernate.loader.Loader.doList(Loader.java:2675)
org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2507)
org.hibernate.loader.Loader.list(Loader.java:2502)
org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:502)
org.hibernate.hql.internal.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:392)
org.hibernate.engine.query.spi.HQLQueryPlan.performList(HQLQueryPlan.java:216)
org.hibernate.internal.SessionImpl.list(SessionImpl.java:1489)
org.hibernate.query.internal.AbstractProducedQuery.doList(AbstractProducedQuery.java:1445)
org.hibernate.query.internal.AbstractProducedQuery.list(AbstractProducedQuery.java:1414)
org.hibernate.query.Query.getResultList(Query.java:146)
com.horse.novisit.dao.VisitDAOImpl.isVisit(isVisitImpl.java:79)
com.horse.novisit.service.VisitServiceImpl.isVisit(isVisitImpl.java:67)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke(Method.java:498)
org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:343)
org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:197)
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:294)
org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:98)
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185)
org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212)
com.sun.proxy.$Proxy52.isLongUrlInDB(Unknown Source)
com.horse.noToVisit.controller.visitController.postBigVisit(VisitController.java:47)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke(Method.java:498)
org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:209)
org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:136)
org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:102)
org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:877)
org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:783)
org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:991)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:925)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:974)
org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:877)
javax.servlet.http.HttpServlet.service(HttpServlet.java:661)
org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:851)
javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)


(Wexwuffley) #2

Please ignore typos in my code snippet. I quickly changed the database, function and class names on this forum to retain anonymity. I have carefully been through my code and in reality there are no typos.


(Jica) #3

How are you starting the containers?
You should start mysql container, check the database connection, and then start your app container.