古典 java tomcat server 专案 dockerize 踩坑全记录

如标题所述,这里分享的 java tomcat server 专案具有以下特点:

  1. JDK 8 的开发环境
  2. 非 maven 专案
  3. 非 gradle 专案
  4. 绝对不是 spring boot 专案 /images/emoticon/emoticon16.gif

https://ithelp.ithome.com.tw/upload/images/20211103/20109107ZIZx3dNJdH.png

----- 以下开始采坑全记录!

MacBook-Pro ~ % docker run -d --name=tomcat-ithelp -p 8088:8080 tomcat:9.0-jdk8-openjdk 

https://ithelp.ithome.com.tw/upload/images/20211103/20109107LhVGPc7ZLM.png
container 长出来後,兴冲冲地在 safari 键入 localhost:8088
https://ithelp.ithome.com.tw/upload/images/20211103/20109107ibhNC7RwDp.png
/images/emoticon/emoticon20.gif

解决方法:

https://ithelp.ithome.com.tw/upload/images/20211103/201091077ttFZ4zhwZ.png
https://ithelp.ithome.com.tw/upload/images/20211103/201091077OUaDwqaNF.png
看起来正常了!/images/emoticon/emoticon12.gif
既然 docker image 是宣称 tomcat:9.0-jdk8-openjdk
https://ithelp.ithome.com.tw/upload/images/20211103/20109107hGIJVU3u1w.png
确实是 java 8。/images/emoticon/emoticon12.gif
接下来把专案档 managerWeb.war 复制一份到 container 的 webapps 目录下。

MacBook-Pro ~ % docker cp ~/managerWeb/managerWeb.war tomcat-ithelp:/usr/local/tomcat/webapps

container log 喷错了!
https://ithelp.ithome.com.tw/upload/images/20211103/20109107KmUqPlS1Ao.png
『 Failed to instantiate [com.mchange.v2.c3p0.ComboPooledDataSource]: Constructor threw exception; nested exception is java.lang.ExceptionInInitializerError』

解决方法:

https://ithelp.ithome.com.tw/upload/images/20211103/20109107e4oRHTl139.png

RESTART container 後,继续喷错!/images/emoticon/emoticon20.gif
https://ithelp.ithome.com.tw/upload/images/20211103/201091074dLrYCrHnM.png
『com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure』

解决方法:

https://ithelp.ithome.com.tw/upload/images/20211103/201091073kjx4uHuep.png

RESTART container 後,继续喷错!/images/emoticon/emoticon02.gif
https://ithelp.ithome.com.tw/upload/images/20211103/20109107hvq8NGHleW.png
『Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/applicationContext/applicationContext-sessionFactory.xml]: Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: javax.persistence.UniqueConstraint.name()Ljava/lang/String;』

经过google大神的指点後,
直接删除 WEB-INF/lib 下的 persistence.jar
https://ithelp.ithome.com.tw/upload/images/20211103/20109107LUj4ojGuaR.png
总算 ... /images/emoticon/emoticon01.gif
https://ithelp.ithome.com.tw/upload/images/20211104/201091074nUW7CPMS9.png

後记:
这篇主要是写给未来的自己看的。
未来再处理到这种 Jar 档没有控管的专案,只好耐心地把这堆有冲突的 Jar 档逐步移除了。
/images/emoticon/emoticon32.gif


<<:  MSP430 在 linux 上的环境设定

>>:  EP 32: TopStore App with .NET Multi-platform App UI (MAUI)

OpenStack Neutron 介绍 3

本系列文章同步发布於笔者网站 上一篇介绍了 Neutron 的网路的概念,接下来将会接续介绍 Neu...

Day7 甘特图的特性与关键路径

再来要讲到管理工具中耳熟能详的工具之一,甘特图。Gantt Chart在规划专案时,几乎就是所以人第...

Day 3 - Using the Gmail SMTP Server to Send Emails with ASP.NET Web Forms C# 使用 Gmail 做为邮件服务器来寄信

=x= 🌵 CONTACT Page 寄信页的後端寄信功能及其它注意事项。 Gmail SMTP S...

Day.5 深入理解连结之Object file

目标文件格式 (Object file) ​ 以文件的方式放在磁碟(Disk)中的 Object m...

【在 iOS 开发路上的大小事-Day26】透过 Firebase 来管理资料 (Realtime Database 篇) Part2

前情提要 昨天已经将环境设定好了,今天要来将新增、读取、更新、删除、排序功能实作出来 开始实作 设计...