获取错误jar在运行时不存在

问题描述 投票:1回答:1

运行映像时出错:

C:\ Users \ 10649404 \ Desktop \ spring-boot-websocket-chat-demo> docker run -p 5000:8080 ok 2019-04-29 07:10:58.660 INFO org.glowroot - Glowroot version:0.10.12,built 2018-06-22 00:08:17 +0000 2019-04-29 07:10:58.673 INFO org.glowroot - Java版本:1.8.0_201

这是我没有得到的jar文件。它说缺少lib/glowroot-embedded-collector.jar,即使它存在于该位置。

2019-04-29 07:10:58.682 ERROR org.glowroot - missing lib/glowroot-embedded-collector.jar
2019-04-29 07:10:58.688 ERROR org.glowroot - Glowroot not started: org.glowroot.agent.embedded.init.EmbeddedGlowrootAgentInitFactory
java.lang.ClassNotFoundException: org.glowroot.agent.embedded.init.EmbeddedGlowrootAgentInitFactory
        at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:348)
        at org.glowroot.agent.MainEntryPoint.createGlowrootAgentInit(MainEntryPoint.java:311)
        at org.glowroot.agent.MainEntryPoint.start(MainEntryPoint.java:273)
        at org.glowroot.agent.MainEntryPoint.premain(MainEntryPoint.java:173)
        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 org.glowroot.agent.AgentPremain.premain(AgentPremain.java:59)
        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)

这是我的docker文件内容:

# Start with a base image containing Java runtime
FROM openjdk:8-jdk-alpine

# Add a volume pointing to /tmp

VOLUME /tmp
# Make port 8080 available to the world outside this container
EXPOSE 8080
ADD /opt/glowroot/glowroot.jar glowroot.jar
ADD /opt/glowroot/lib/glowroot-embedded-collector.jar  glowroot-embedded-collector.jar

ADD /opt/glowroot/lib/glowroot-central-collector-https-linux.jar  glowroot-central-collector-https-linux.jar
ADD /opt/glowroot/lib/glowroot-central-collector-https-osx.jar  glowroot-central-collector-https-osx.jar
ADD /opt/glowroot/lib/glowroot-central-collector-https-windows.jar  
glowroot-central-collector-https-windows.jar
    COPY /opt/glowroot/ /opt/glowroot/ 
    # The application's jar file
    ARG JAR_FILE=target/websocket-demo-0.0.1-SNAPSHOT.jar
    ARG OK=/opt/glowroot/glowroot.jar
    # Add the application's jar to the container
    ADD ${JAR_FILE} websocket-demo.jar
    #ADD ${OK} glowroot.jar
    # Run the jar file 

CMD ["java", "-javaagent:/glowroot.jar","-Dglowroot.agent.id=Docker","-jar", "/websocket-demo.jar"]

请让我知道这个问题。罐子出现在lib/glowroot-embedded-collector.jar

java docker
1个回答
1
投票

在您的Dockerfile中,您有:

ADD /opt/glowroot/lib/glowroot-embedded-collector.jar  glowroot-embedded-collector.jar

这会在根目录中复制jar文件,因此可以在以下位置找到:/glowroot-embedded-collector.jar

当你说lib / glowroot-embedded-collector.jar可用时,你的意思是在主机上还是在容器内?因为基于你的Dockerfile我不认为它可以存在于容器内。

也许尝试以这种方式更改ADD语句:

ADD /opt/glowroot/lib/glowroot-embedded-collector.jar  lib/glowroot-embedded-collector.jar
© www.soinside.com 2019 - 2024. All rights reserved.