docker - 当我使用 Dockerfile 运行 UniTime 时,它会不断产生错误吗?
问题描述
我需要在 Docker 上使用 UniTime,但它不能正常工作,当我运行它时我不断收到错误消息。
我得到的错误:
ERROR TaskExecutorService -> Failed to check for tasks: The session factory has not been initialized (or an error occured during initialization)
java.lang.RuntimeException: The session factory has not been initialized (or an error occured during initialization)
at org.unitime.timetable.model.base._BaseRootDAO.getSessionFactory(_BaseRootDAO.java:111)
at org.unitime.timetable.model.base._BaseRootDAO.getSession(_BaseRootDAO.java:151)
at org.unitime.timetable.model.base._BaseRootDAO.createNewSession(_BaseRootDAO.java:141)
at org.unitime.timetable.server.script.TaskExecutorService.checkForQueuedTasks(TaskExecutorService.java:67)
at org.unitime.timetable.server.script.TaskExecutorService$TaskExecutor.run(TaskExecutorService.java:162)
Dockerfile:
FROM tomcat:8
EXPOSE 8080
RUN apt-get update && \
apt-get install -y apt-utils && \
apt-get install -y default-mysql-server
ENV JAVA_OPTS="-Djava.awt.headless=true -Xmx2g -XX:+UseConcMarkSweepGC"
ENV TOMCAT8_GROUP=tomcat8
ENV TOMCAT8_USER=tomcat8
RUN wget https://repo1.maven.org/maven2/mysql/mysql-connector-java/5.1.38/mysql-connector-java-5.1.38.jar && \
cp mysql-connector-java-5.1.38.jar /usr/local/tomcat/lib/ && \
wget https://github.com/UniTime/unitime/releases/download/v4.4.140/unitime-4.4_bld140.zip && \
unzip unitime-4.4_bld140.zip -d unitime && \
/etc/init.d/mysql start && \
mysql -uroot -f <unitime/doc/mysql/schema.sql && \
mysql -uroot -f <unitime/doc/mysql/schema.sql && \
mysql -utimetable -punitime <unitime/doc/mysql/blank-data.sql && \
mkdir /usr/local/tomcat/data && \
useradd tomcat && \
chown tomcat /usr/local/tomcat/data && \
cp unitime/web/UniTime.war /usr/local/tomcat/webapps
解决方案
如果您仍在为此寻求帮助。以下是我必须在 UniTime 文件中进行的一些更改才能使用 Docker Deploy。一些 lib 更新特定于 Java 8。
取消注释 UniTime pom.xml https://github.com/UniTime/unitime/blob/master/pom.xml#L275-L282中的 mysql 连接部分 将 pom 的 mysql.version 更新为您正在使用的版本。
在 UniTime .project 添加 com.gwtplugins.gwt.eclipse 引用
<buildCommand>
<name>com.gwtplugins.gdt.eclipse.core.webAppProjectValidator</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.gwtplugins.gwt.eclipse.core.gwtProjectValidator</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
...
<nature>com.gwtplugins.gwt.eclipse.core.gwtNature</nature>
</natures>
...
- 在 UniTime Documentation/Database/MySQL/schema.sql 中找到与 localhost (127..?) 等效的 docker 或扩展时间表用户范围(用于测试)。
...
drop user timetable@localhost;
drop user IF EXISTS timetable@localhost;
create user timetable@localhost identified by 'unitime';
/* for Docker */
create user timetable@'%' identified by 'unitime';
grant all on timetable.* to timetable@localhost;
/* for Docker */
grant all on timetable.* to timetable@'%';
...
- 在 UniTime JavaSource/hibernate.cfg.xml 添加额外的休眠参数
...
<property name="connection.url">jdbc:mysql://database:3306/timetable?allowPublicKeyRetrieval=TRUE</property>
...
<!-- for Java 8-11 TSLv1.2 SSL 3 -->
<property name="hibernate.connection.verifyServerCertificate">false</property>
<property name="hibernate.connection.requireSSL">false</property>
<property name="hibernate.connection.useSSL">false</property>
<!-- End of MySQL Configuration -->
...
- 我使用 docker-compose.yml 文件来设置 tomcat 和 docker 配置。
推荐阅读
- javascript - setState 的同步替代方案
- django - Django 视图不保存模型实例但正确运行数据处理功能?
- css - Ionic v3 在运行时在明暗主题之间切换(动态)
- auth0 - 使用 Auth0 的 Lock 进行身份验证后检索 id 令牌
- typescript - 如何在 Nuxt Typescript 中创建自己的类型?
- c# - 无法让 Accord-FFMPEG-Package 在我的 .NET-Core-Application 中工作
- python - 限制外键数量,每个外键指的是一周中的一天
- python - 为所有操作模拟类实例的一个属性
- python - 在没有安装 Python 的办公室计算机上运行脚本
- scrapy - 选择哪些正确的标签和属性?