在运行时不存在错误jar

时间:2019-04-29 07:26:27

标签: java docker

运行图像时出错:

  

C:\ Users \ 10649404 \ Desktop \ spring-boot-websocket-chat-demo> docker运行   -p 5000:8080 OK 2019-04-29 07:10:58.660 INFO org.glowroot-Glowroot版本:0.10.12,已构建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"]

请让我知道这个问题。 jar位于lib/glowroot-embedded-collector.jar

1 个答案:

答案 0 :(得分: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