'Tomcat 9 unable find org.apache.ibatis inside docker container with java 17
I am trying to rewrite the existing java application to upgrade it to java17 and tomcat 9 along with dockerization But while I am trying to run it in the docker container I am seeing the error below
Caused by: java.lang.Error: Unresolved compilation problems:
The import org.apache.ibatis cannot be resolved
The import org.apache.ibatis cannot be resolved
BaseTypeHandler cannot be resolved to a type
The method getNullableResult(ResultSet, String) of type StringBoolHandler must override or implement a supertype method
The method getNullableResult(ResultSet, int) of type StringBoolHandler must override or implement a supertype method
The method getNullableResult(CallableStatement, int) of type StringBoolHandler must override or implement a supertype method
JdbcType cannot be resolved to a type
at com.XXX.XXX.mybatis.typehandlers.StringBoolHandler.<init>(StringBoolHandler.java:11)
But StringBoolHandler class has the above-mentioned methods overridden and no compiler errors in IDE either
I am able to successfully start and run the application in IDE
This is my docker file
FROM openjdk:17-jdk
FROM maven:3.8.4 as maven_builder
WORKDIR /app
ADD src /app/src
ADD war /app/war
#Prepare by downloading dependencies
ADD pom.xml /app/pom.xml
RUN ["mvn", "dependency:resolve"]
RUN ["mvn", "verify"]
#Adding source, compile and package into a fat jar
RUN ["mvn","clean", "install", "-Dmaven.test.skip=true"]
FROM tomcat:9.0-jdk17
# adding new relic config
RUN mkdir -p /usr/local/tomcat/newrelic
COPY war/WEB-INF/lib/newrelic.jar /usr/local/tomcat/newrelic/newrelic.jar
COPY war/WEB-INF/newrelic.yml /usr/local/tomcat/newrelic/newrelic.yml
ENV JAVA_OPTS="$JAVA_OPTS -javaagent:/usr/local/tomcat/newrelic/newrelic.jar"
COPY --from=maven_builder /app/target/xxx-0.0.1-SNAPSHOT.war /usr/local/tomcat/webapps/xxx.war
I am able to find mybatis-3.5.7.jar in lib of deployed application in docker container
please feel free to suggest me any type of modifications needed to make my Dockerfile better
Solution 1:[1]
OK I got it fixed by changing the maven version
issue is with maven some how while building the war file it ignores the mybatis imports Once I downgraded my maven version it started working
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | meghanath reddy |
