突然无法通过VSCode启动配置运行Java

突然无法通过VSCode启动配置运行Java,java,visual-studio-code,Java,Visual Studio Code,我正在使用VSCode devcontainer编写Java应用程序。我把它放了大约一个月,回来工作,现在我得到了一些不熟悉的错误 配置 在这里,我将提供我的devcontainer环境的相关配置文件 我的Dockerfile如下所示: FROM openjdk:16-slim-buster # Install things RUN apt-get update \ && apt-get -y install --no-install-recommends apt-ut

我正在使用VSCode devcontainer编写Java应用程序。我把它放了大约一个月,回来工作,现在我得到了一些不熟悉的错误

配置 在这里,我将提供我的devcontainer环境的相关配置文件

我的Dockerfile如下所示:

FROM openjdk:16-slim-buster

# Install things
RUN apt-get update \
    && apt-get -y install --no-install-recommends apt-utils dialog 2>&1 \
    #
    # Verify git, process tools, lsb-release (common in install instructions for CLIs) installed
    && apt-get -y install curl git openssh-client vim less iproute2 procps lsb-release

# Install Maven CLI things
ARG MAVEN_VERSION=3.6.3
ARG MAVEN_SHA=c35a1803a6e70a126e80b2b3ae33eed961f83ed74d18fcd16909b2d44d7dada3203f1ffe726c17ef8dcca2dcaa9fca676987befeadc9b9f759967a8cb77181c0
RUN mkdir -p /usr/share/maven /usr/share/maven/ref \
  && curl -fsSL -o /tmp/apache-maven.tar.gz https://archive.apache.org/dist/maven/maven-3/${MAVEN_VERSION}/binaries/apache-maven-${MAVEN_VERSION}-bin.tar.gz \
  && echo "${MAVEN_SHA} /tmp/apache-maven.tar.gz" | sha512sum -c - \
  && tar -xzf /tmp/apache-maven.tar.gz -C /usr/share/maven --strip-components=1 \
  && rm -f /tmp/apache-maven.tar.gz \
  && ln -s /usr/share/maven/bin/mvn /usr/bin/mvn
ENV MAVEN_HOME /usr/share/maven
ENV MAVEN_CONFIG /root/.m2

# Allow for a consistant java home location for settings - image is changing over time
RUN if [ ! -d "/docker-java-home" ]; then ln -s "${JAVA_HOME}" /docker-java-home; fi
我的devontainer JSON在这里:

{
“名称”:“Java开发”,
“dockerFile”:“dockerFile”,
//在创建容器时设置*default*特定于容器的settings.json值。
“设置”:{
“terminal.integrated.shell.linux”:“/bin/bash”,
“java.home”:“/docker java home”
},
//添加创建容器时要安装的扩展的ID。
“扩展”:[
“vscjava.vscode java包”,
“redhat.vscode xml”
]
}
问题 当我之前停止使用这个应用程序时,一切都编译好并运行良好,我能够通过VSCode启动我的配置进行测试。现在,我遇到了两个问题,我认为它们是相关的。首先,当我尝试使用启动配置运行我的应用程序时,它不起作用,我遇到了一个奇怪的错误:

所以我不能通过VSCode启动任何东西。接下来,我尝试了一个
mvn包
,测试失败,出现如下错误:

FROM openjdk:16-slim-buster

# Install things
RUN apt-get update \
    && apt-get -y install --no-install-recommends apt-utils dialog 2>&1 \
    #
    # Verify git, process tools, lsb-release (common in install instructions for CLIs) installed
    && apt-get -y install curl git openssh-client vim less iproute2 procps lsb-release

# Install Maven CLI things
ARG MAVEN_VERSION=3.6.3
ARG MAVEN_SHA=c35a1803a6e70a126e80b2b3ae33eed961f83ed74d18fcd16909b2d44d7dada3203f1ffe726c17ef8dcca2dcaa9fca676987befeadc9b9f759967a8cb77181c0
RUN mkdir -p /usr/share/maven /usr/share/maven/ref \
  && curl -fsSL -o /tmp/apache-maven.tar.gz https://archive.apache.org/dist/maven/maven-3/${MAVEN_VERSION}/binaries/apache-maven-${MAVEN_VERSION}-bin.tar.gz \
  && echo "${MAVEN_SHA} /tmp/apache-maven.tar.gz" | sha512sum -c - \
  && tar -xzf /tmp/apache-maven.tar.gz -C /usr/share/maven --strip-components=1 \
  && rm -f /tmp/apache-maven.tar.gz \
  && ln -s /usr/share/maven/bin/mvn /usr/bin/mvn
ENV MAVEN_HOME /usr/share/maven
ENV MAVEN_CONFIG /root/.m2

# Allow for a consistant java home location for settings - image is changing over time
RUN if [ ! -d "/docker-java-home" ]; then ln -s "${JAVA_HOME}" /docker-java-home; fi
com.google.common.util.concurrent.UncheckedExecutionException:java.lang.IllegalStateException:无法加载缓存项
在com.insureexcel.poipoi.input.InputProcessorTest.setup(InputProcessorTest.java:34)上
原因:java.lang.IllegalStateException:无法加载缓存项
在com.insureexcel.poipoi.input.InputProcessorTest.setup(InputProcessorTest.java:34)上
原因:java.lang.ExceptionInInitializeError
在com.insureexcel.poipoi.input.InputProcessorTest.setup(InputProcessorTest.java:34)上
原因:com.google.inject.internal.cglib.core.$CodeGenerationException:java.lang.reflect.InaccessibleObjectException-->无法使受保护的最终java.lang.Class java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,int,java.security.ProtectionDomain)抛出java.lang.ClassFormatError可访问:模块java.base不可访问“打开java.lang”到未命名模块@523fa30b
在com.insureexcel.poipoi.input.InputProcessorTest.setup(InputProcessorTest.java:34)上
原因:java.lang.reflect.InAccessibleObject异常:无法使受保护的最终java.lang.Class java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,int,java.security.ProtectionDomain)抛出java.lang.ClassFormatError可访问性:模块java.base未将java.lang“打开”到未命名模块@523fa30b
在com.insureexcel.poipoi.input.InputProcessorTest.setup(InputProcessorTest.java:34)上
所以它看起来与一些反射有关。我使用的是GSON和Guice,这里是
pom.xml
的相关部分:


com.google.code.gson
格森
2.8.6
com.google.inject
圭斯
4.2.3
我尝试将Guice更新为
5.0.0-BETA-1
,这修复了测试中的错误,并成功编译了所有内容。但是,现在我在执行某些序列化时出现运行时错误。错误如下所示:

线程“main”java.lang.reflect.InAccessibleObject异常:无法使字段私有java.lang.String java.lang.Throwable.detailMessage可访问:模块java.base未“打开java.lang”到未命名模块@523fa30b 位于java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:357) 位于java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297) 位于java.base/java.lang.reflect.Field.checkCanSetAccessible(Field.java:177) 位于java.base/java.lang.reflect.Field.setAccessible(Field.java:171) 位于com.google.gson.internal.reflect.unsafferectionAccessor.makeAccessible(unsafferectionAccessor.java:44) 位于com.google.gson.internal.bind.ReflectTypeAdapterFactory.getBoundFields(ReflectTypeAdapterFactory.java:159) 位于com.google.gson.internal.bind.ReflectTypeAdapterFactory.create(ReflectTypeAdapterFactory.java:102) 位于com.google.gson.gson.getAdapter(gson.java:458) 位于com.google.gson.internal.bind.ReflectTypeAdapterFactory.CreateBundfield(ReflectTypeAdapterFactory.java:117) 位于com.google.gson.internal.bind.ReflectTypeAdapterFactory.getBoundFields(ReflectTypeAdapterFactory.java:166) 位于com.google.gson.internal.bind.ReflectTypeAdapterFactory.create(ReflectTypeAdapterFactory.java:102) 位于com.google.gson.gson.getAdapter(gson.java:458) 位于com.google.gson.gson.toJson(gson.java:696) 位于com.google.gson.gson.toJson(gson.java:683) 位于com.google.gson.gson.toJson(gson.java:638) 位于com.google.gson.gson.toJson(gson.java:618) ... 显然它与GSON有关。它似乎无法访问私有字段?我尝试序列化的对象如下所示:

公共类映射容器{
私有MyMapObject映射;
私有字符串状态;
私人例外信息;
公共映射容器(MyMapObject映射){
this.map=map;
this.status=“好”;
this.errorInformation=null;
}
公共映射容器(异常错误){
this.map=null;
this.status=“error”;
this.errorInformation=错误;
}
...
接球手和接球手
...
}
根据这个错误,我的对象中的异常字段似乎很难处理。我已经仔细查看了一遍,找不到发生这种情况的好理由。我检查了运行此操作的Docker映像,它似乎最近已经更新。容器中的my
java--version
返回了