skywalking icon indicating copy to clipboard operation
skywalking copied to clipboard

[Bug] - “openjdk:8-jdk-alpine” base-image docker based application unable to start with Apache Skywalking

Open skundu1234 opened this issue 4 years ago • 10 comments

Search before asking

  • [X] I had searched in the issues and found no similar issues.

Apache SkyWalking Component

Java Agent (apache/skywalking-java)

What happened

we observed issues with the applications using “openjdk:8-jdk-alpine” base-image in docker file. Its working fine with adoptopenjdk:11-jre-hotspot image .We observed this below error while using this image and most applications are using this image for our organisation so what could be the solution can you please check.

Please update if Apache skywalking works only those images mentioned in document.

https://skywalking.apache.org/docs/skywalking-java/v8.10.0/en/setup/service-agent/java-agent/plugin-test/

Below error coming.

ERROR 2022-04-29 10:23:28:033 main AgentClassLoader : ._apm-mongodb-2.x-plugin-8.10.0.jar jar file can't be resolved
java.util.zip.ZipException: error in opening zip file
at java.util.zip.ZipFile.open(Native Method)
at java.util.zip.ZipFile.(ZipFile.java:225)
at java.util.zip.ZipFile.(ZipFile.java:155)
at java.util.jar.JarFile.(JarFile.java:166)
at java.util.jar.JarFile.(JarFile.java:130)
at org.apache.skywalking.apm.agent.core.plugin.loader.AgentClassLoader.doGetJars(AgentClassLoader.java:195)
at org.apache.skywalking.apm.agent.core.plugin.loader.AgentClassLoader.getAllJars(AgentClassLoader.java:177)
at org.apache.skywalking.apm.agent.core.plugin.loader.AgentClassLoader.findResources(AgentClassLoader.java:138)
at java.lang.ClassLoader.getResources(ClassLoader.java:1142)
at org.apache.skywalking.apm.agent.core.plugin.PluginResourcesResolver.getResources(PluginResourcesResolver.java:40)
at org.apache.skywalking.apm.agent.core.plugin.PluginBootstrap.loadPlugins(PluginBootstrap.java:45)
at org.apache.skywalking.apm.agent.SkyWalkingAgent.premain(SkyWalkingAgent.java:80)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:386)
at sun.instrument.InstrumentationImpl.loadClassAndCallPremain(InstrumentationImpl.java:401)

ERROR 2022-04-29 10:23:28:046 main AgentClassLoader : ._apm-elasticsearch-5.x-plugin-8.10.0.jar jar file can't be resolved
java.util.zip.ZipException: error in opening zip file
at java.util.zip.ZipFile.open(Native Method)
at java.util.zip.ZipFile.(ZipFile.java:225)
at java.util.zip.ZipFile.(ZipFile.java:155)
at java.util.jar.JarFile.(JarFile.java:166)
at java.util.jar.JarFile.(JarFile.java:130)
at org.apache.skywalking.apm.agent.core.plugin.loader.AgentClassLoader.doGetJars(AgentClassLoader.java:195)
at org.apache.skywalking.apm.agent.core.plugin.loader.AgentClassLoader.getAllJars(AgentClassLoader.java:177)
at org.apache.skywalking.apm.agent.core.plugin.loader.AgentClassLoader.findResources(AgentClassLoader.java:138)
at java.lang.ClassLoader.getResources(ClassLoader.java:1142)
at org.apache.skywalking.apm.agent.core.plugin.PluginResourcesResolver.getResources(PluginResourcesResolver.java:40)
at org.apache.skywalking.apm.agent.core.plugin.PluginBootstrap.loadPlugins(PluginBootstrap.java:45)
at org.apache.skywalking.apm.agent.SkyWalkingAgent.premain(SkyWalkingAgent.java:80)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:386)
at sun.instrument.InstrumentationImpl.loadClassAndCallPremain(InstrumentationImpl.java:401)

INFO 2022-04-29 10:23:28:047 main AgentClassLoader : /releaseapp/skywalking-stage-java-agent-8.10.0/plugins/apm-jetty-server-9.x-plugin-8.10.0.jar loaded.
INFO 2022-04-29 10:23:28:048 main AgentClassLoader : /releaseapp/skywalking-stage-java-agent-8.10.0/plugins/apm-httpasyncclient-4.x-plugin-8.10.0.jar loaded.
ERROR 2022-04-29 10:23:28:049 main AgentClassLoader : ._apm-spring-concurrent-util-4.x-plugin-8.10.0.jar jar file can't be resolved
java.util.zip.ZipException: error in opening zip file
at java.util.zip.ZipFile.open(Native Method)
at java.util.zip.ZipFile.(ZipFile.java:225)
at java.util.zip.ZipFile.(ZipFile.java:155)
at java.util.jar.JarFile.(JarFile.java:166)
at java.util.jar.JarFile.(JarFile.java:130)

What you expected to happen

Application needs to start without calling with . _apm.*jar like ". _apm-elasticsearch-5.x-plugin-8.10.0.jar " . As Apache sky walking should start with openjdk images.

How to reproduce

We are facing same error for all docker applications "openjdk:8-jdk-alpine" using this image.

ERROR 2022-04-29 10:23:28:033 main AgentClassLoader : ._apm-mongodb-2.x-plugin-8.10.0.jar jar file can't be resolved
java.util.zip.ZipException: error in opening zip file
at java.util.zip.ZipFile.open(Native Method)
at java.util.zip.ZipFile.(ZipFile.java:225)
at java.util.zip.ZipFile.(ZipFile.java:155)
at java.util.jar.JarFile.(JarFile.java:166)
at java.util.jar.JarFile.(JarFile.java:130)
at org.apache.skywalking.apm.agent.core.plugin.loader.AgentClassLoader.doGetJars(AgentClassLoader.java:195)
at org.apache.skywalking.apm.agent.core.plugin.loader.AgentClassLoader.getAllJars(AgentClassLoader.java:177)
at org.apache.skywalking.apm.agent.core.plugin.loader.AgentClassLoader.findResources(AgentClassLoader.java:138)
at java.lang.ClassLoader.getResources(ClassLoader.java:1142)
at org.apache.skywalking.apm.agent.core.plugin.PluginResourcesResolver.getResources(PluginResourcesResolver.java:40)
at org.apache.skywalking.apm.agent.core.plugin.PluginBootstrap.loadPlugins(PluginBootstrap.java:45)
at org.apache.skywalking.apm.agent.SkyWalkingAgent.premain(SkyWalkingAgent.java:80)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:386)
at sun.instrument.InstrumentationImpl.loadClassAndCallPremain(InstrumentationImpl.java:401)

ERROR 2022-04-29 10:23:28:046 main AgentClassLoader : ._apm-elasticsearch-5.x-plugin-8.10.0.jar jar file can't be resolved
java.util.zip.ZipException: error in opening zip file
at java.util.zip.ZipFile.open(Native Method)
at java.util.zip.ZipFile.(ZipFile.java:225)
at java.util.zip.ZipFile.(ZipFile.java:155)
at java.util.jar.JarFile.(JarFile.java:166)
at java.util.jar.JarFile.(JarFile.java:130)
at org.apache.skywalking.apm.agent.core.plugin.loader.AgentClassLoader.doGetJars(AgentClassLoader.java:195)
at org.apache.skywalking.apm.agent.core.plugin.loader.AgentClassLoader.getAllJars(AgentClassLoader.java:177)
at org.apache.skywalking.apm.agent.core.plugin.loader.AgentClassLoader.findResources(AgentClassLoader.java:138)
at java.lang.ClassLoader.getResources(ClassLoader.java:1142)
at org.apache.skywalking.apm.agent.core.plugin.PluginResourcesResolver.getResources(PluginResourcesResolver.java:40)
at org.apache.skywalking.apm.agent.core.plugin.PluginBootstrap.loadPlugins(PluginBootstrap.java:45)
at org.apache.skywalking.apm.agent.SkyWalkingAgent.premain(SkyWalkingAgent.java:80)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:386)
at sun.instrument.InstrumentationImpl.loadClassAndCallPremain(InstrumentationImpl.java:401)

INFO 2022-04-29 10:23:28:047 main AgentClassLoader : /releaseapp/skywalking-stage-java-agent-8.10.0/plugins/apm-jetty-server-9.x-plugin-8.10.0.jar loaded.
INFO 2022-04-29 10:23:28:048 main AgentClassLoader : /releaseapp/skywalking-stage-java-agent-8.10.0/plugins/apm-httpasyncclient-4.x-plugin-8.10.0.jar loaded.
ERROR 2022-04-29 10:23:28:049 main AgentClassLoader : ._apm-spring-concurrent-util-4.x-plugin-8.10.0.jar jar file can't be resolved
java.util.zip.ZipException: error in opening zip file
at java.util.zip.ZipFile.open(Native Method)
at java.util.zip.ZipFile.(ZipFile.java:225)
at java.util.zip.ZipFile.(ZipFile.java:155)
at java.util.jar.JarFile.(JarFile.java:166)
at java.util.jar.JarFile.(JarFile.java:130)

Anything else

No response

Are you willing to submit PR?

  • [ ] Yes I am willing to submit a PR!

Code of Conduct

skundu1234 avatar May 09 '22 05:05 skundu1234

@kezhenxu94 Could you run a single verification? Never heard of this.

wu-sheng avatar May 09 '22 05:05 wu-sheng

@skundu1234 which SkyWalking Java agent image are you using? We don't have such image named openjdk:8-jdk-alpine or adoptopenjdk:11-jre-hotspot, please provide reproducible steps or related details.

kezhenxu94 avatar May 09 '22 05:05 kezhenxu94

We are using 8.9.0 Skywalking Java Agent.We are starting application along with sky-walking arguments in docker file. Agent is downloaded in entrypoint.sh. Agent is downloaded from here: https://skywalking.apache.org/downloads/

Docker file details: FROM openjdk:8-jdk-alpine

copy extracted agent folder from the downloaded archive

EXPOSE 8080 ADD entrypoint.sh /app/entrypoint.sh RUN chmod -R 777 /app/entrypoint.sh

copy the jar file

COPY /target/spring-petclinic-2.4.5.jar /app/application.jar WORKDIR /app ENTRYPOINT ["entrypoint.sh", "application.jar" ]

skundu1234 avatar May 09 '22 06:05 skundu1234

Your docker file, your responsibility.

We have provided official docker images in dockerhub.

wu-sheng avatar May 09 '22 06:05 wu-sheng

Docker file is fine but only base image is the problem and Skywalking agent does not work with openjdk thats also official from Docker Hub. https://hub.docker.com/_/openjdk

Is there anything that Skywalking agent only works only certain base images.

skundu1234 avatar May 09 '22 06:05 skundu1234

This is duplicate of https://github.com/apache/skywalking/discussions/8975

Docker file is fine but only base image is the problem and Skywalking agent does not work > with openjdk thats also official from Docker Hub. https://hub.docker.com/_/openjdk Is there anything that Skywalking agent only works only certain base images.

You have no idea whether base image is the only problem, for what it's worth here are my suggestions:

  • Use our prebuilt Docker image instead of downloading on the fly, e.g.

    COPY --from=apache/skywalking-java-agent:8.9.0-alpine /skywalking/agent /path/to/your/desired/agent/location
    # ...
    
  • ._ files are hidden so when you said We did not see with ._apm-spring-concurrent-util-4.x-plugin-8.10.0.jar file anywhere in plugin,option plugins,activations.Not sure how _ underscore is coming. make sure you use ls -alh to list all hidden files, also, these files are totally possible produced on your side please Google it first https://apple.stackexchange.com/questions/14980/why-are-dot-underscore-files-created-and-how-can-i-avoid-them

  • Agent is downloaded in entrypoint.sh, I don't think this is a good idea because you'll need to download the agent every time you start the app, which is unnecessary and sometimes it's inconsistent from time to time.

kezhenxu94 avatar May 09 '22 06:05 kezhenxu94

Thank you very much @kezhenxu94 for this details.We are not able to see this error now.We are getting GRPC collector fail and this collector backend service is able to connect with other application. Any thoughts about that. Note: Kept enable_TLS: True and ca/ca.crt is present.

GRPC collector fail error log in skywalking-api.log:

ERROR 2022-05-09 11:20:28:125 SkywalkingAgent-12-GRPCChannelManager-0 GRPCChannelManager : Create channel to fail. java.lang.NullPointerException at org.apache.skywalking.apm.agent.core.remote.GRPCChannelManager.run(GRPCChannelManager.java:152) at org.apache.skywalking.apm.util.RunnableWithExceptionProtection.run(RunnableWithExceptionProtection.java:33) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748)

skundu1234 avatar May 09 '22 11:05 skundu1234

@kezhenxu94 Can you please check and update on this.

skundu1234 avatar May 18 '22 15:05 skundu1234

@skundu1234 I have no idea simply from the logs you posted, please check yourself or provide necessary context and detail logs

kezhenxu94 avatar May 19 '22 04:05 kezhenxu94

Also please open new issue since this issue was for Docker image and it's resolved

kezhenxu94 avatar May 19 '22 04:05 kezhenxu94