-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Jib custom email service calls java.lang.NoClassDefFoundError #2060
Comments
This comment has been minimized.
This comment has been minimized.
Could you try with a different base image? Like one from https://hub.docker.com/_/jetty ? How do you run your application locally? Another option is using |
Seems like Jetty will fix this in Jetty 10, but it's unsure when Jetty 10 will be released. A few workarounds I can think of:
|
Hi everyone! @raizoor @loosebazooka @chanseokoh <packaging>jar</packaging> and performed a basic build using jdk 11 <properties>
<java.version>11</java.version>
</properties> and now the emails are sent successfully. @loosebazooka With these pom.xml dependencies<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jetty</artifactId>
</dependency>
I tried to build a jib project myself based on various basic images of the jetty and tomcat here is my jib plugin configuration jetty<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>jib-maven-plugin</artifactId>
<version>1.6.1</version>
<from>
<image>jetty:9.4.18-jre11</image>
</from>
<container>
<appRoot>/usr/local/jetty/webapps/ROOT</appRoot>
<entrypoint>
<args>rm -r /usr/local/jetty/lib/mail</args>
</entrypoint>
<entrypoint>
<args>
<arg>rm -r /usr/local/jetty/lib/mail</arg>
<arg>java -jar "$JETTY_HOME/start.jar" --add-to-startd=jmx,stats</arg>
</args>
</entrypoint>
</container>
<configuration>
<to>
<image>cr.yandex/id/${project.artifactId}</image>
<tags>${project.version}</tags>
</to>
<extraDirectories>
<paths>
<path>${project.basedir}/src/main/resources/path/to</path>
</paths>
</extraDirectories>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>build</goal>
</goals>
</execution>
</executions>
</plugin>
here is my jib plugin configuration tomcat<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>jib-maven-plugin</artifactId>
<version>1.6.1</version>
<from>
<image>tomcat:9.0.27-jdk11-openjdk</image>
</from>
<container>
<appRoot>/usr/local/tomcat/webapps/ROOT</appRoot>
<entrypoint>
<args>
<arg>/usr/local/tomcat/bin/catalina.sh run</arg>
<arg>tail -f /usr/local/tomcat/logs/catalina.out</arg>
</args>
</entrypoint>
</container>
<configuration>
<to>
<image>cr.yandex/id/${project.artifactId}</image>
<tags>${project.version}</tags>
</to>
<extraDirectories>
<paths>
<path>${project.basedir}/src/main/resources/path/to</path>
</paths>
</extraDirectories>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>build</goal>
</goals>
</execution>
</executions>
</plugin> @chanseokoh jib plugin config<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>jib-maven-plugin</artifactId>
<version>1.6.1</version>
<container>
<entrypoint>
<args>rm -r /usr/local/jetty/lib/mail</args>
</entrypoint>
<entrypoint>
<args>
<arg>rm -r /usr/local/jetty/lib/mail</arg>
<arg>java -jar "$JETTY_HOME/start.jar" --add-to-startd=jmx,stats</arg>
</args>
</entrypoint>
</container>
<configuration>
<to>
<image>cr.yandex/id/${project.artifactId}</image>
<tags>${project.version}</tags>
</to>
<extraDirectories>
<paths>
<path>${project.basedir}/src/main/resources/path/to</path>
<path>src/main/jib/jetty/lib/.wh.mail. </path>
</paths>
</extraDirectories>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>build</goal>
</goals>
</execution>
</executions>
</plugin> |
You said |
@chanseokoh Yeah |
@Daniil56 looking at your previous comment, there are a lot to say here, so please bear with me.
I think the Docker Hub Jetty images won't help, because Jetty 10 (which fixes this issue) is not yet releases. The Docker Hub Jetty images are Jetty 9 as of now. Using the Docker Hub Tomcat images could be an alternative. Your configuration just doesn't look right. Here is an example that more or less works with Tomcat 8.5, but as you can see in the example, the base Tomcat image contains sample apps (which I find weird), so you'll most likely want to delete the directory first. That is, you have a similar problem. They have an open issue to remove the bundled apps from the Tomcat images. And unrelated to all of these, your configurations just aren't correct syntactically: <artifactId>jib-maven-plugin</artifactId>
<version>1.6.1</version>
<from>...</from> <-- wrong
<container>...</container> <-- wrong
<configuration>...</configuration>
<!-- almost everything wrong below -->
<entrypoint>
<args>rm -r /usr/local/jetty/lib/mail</args>
</entrypoint>
<entrypoint>
<args>
<arg>rm -r /usr/local/jetty/lib/mail</arg>
<arg>java -jar "$JETTY_HOME/start.jar" --add-to-startd=jmx,stats</arg>
</args>
</entrypoint> You don't define multiple <configuration>
<entrypoint> <!-- there should be only one entrypoint -->
<arg>java</arg>
<arg>-jar</arg>
<arg>some.jar</arg>
</entrypoint>
</configuration> And although I cannot say it is completely wrong to attempt to delete some directory at the time of running the image, ideally you should create an image that doesn't have the directory in the first place. There are many ways to achieve this. Preparing a custom base image and have Jib use it could be one option. Another option would be use a file with the Also, you cannot expect <entrypoint>
<arg>sh</arg> <!-- note the `sh` program is not included in the default images that Jib uses -->
<arg>-c</arg>
<arg>echo $JETTY_HOME ; echo $PATH</arg>
</entrypoint> This is basically, like you write a script snippet (here,
About the
Then, because Hope this make a lot of things clear. |
It sounds like this will be fixed in Jetty 10, but it's unclear when it will be released. For those who hit this issue, take a look at some of the suggestions and workarounds in the comments above. I opened an issue against Distroless for tracking. I'll close the issue. |
Environment:
Description of the issue:
I have a spring boot 2 app with custom email services
When running on a local machine on localhost: 8080 the application works fine, the email service successfully fulfills the sending of emails. Locally the project runs on the jetty server
But after compiling the source code and building the jib plugin calling the email service causes an error :
As far as I know this error can occur when using jdk 11 and jetty server which has its own email service causing a conflict with the user email service.
This problem is partially described
here
This Dockerfile could solve the problem
My question is as follows:
Expected behavior:
Successful sending of emails using custom email service
Steps to reproduce:
POM.XML:
**Log output kubernetes pod**: :
**Log output local spring start**: :
Additional Information:
Until there is a solution I will try to rewrite the code in java 8
UPD: after refactoring and rebuilding the code in java 8, sending emails in the cluster earned.
The question is open, how to configure the jib plugin for java 11
The text was updated successfully, but these errors were encountered: