gpt4 book ai didi

java - 必须启动 Instrumentation LoadTimeWeaver/openjdk 11

转载 作者:行者123 更新时间:2023-11-28 23:12:59 34 4
gpt4 key购买 nike

我们有一个生产 Java 1.6/Tomcat 7/Spring 4 应用程序。

我们正在将它移动到 Openjdk 11。这意味着 Spring 5,我认为它也可能包括 Tomcat 9,因为我们正在更新其他所有内容。

问题是不言自明的发音:

ERROR org.springframework.web.context.ContextLoader - Context initialization failed org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'rootContextConfig': Unsatisfied dependency expressed through field 'entityManagerFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in com.xxxxx.config.RootContextConfig: Invocation of init method failed; nested exception is java.lang.IllegalStateException: Must start with Java agent to use InstrumentationLoadTimeWeaver. See Spring documentation.

一切都很好。唯一的问题是我们已经有了 Spring Insturment Java 代理

-javaagent:${CATALINA_HOME}/lib/spring-instrument-5.1.5.RELEASE.jar

就像我上面说的,这是所有工作代码,我们只是在更新版本。

我确信 LTW 正在加载,因为我们可以看到 InstrumentationLoadTimeWeaver 类产生的错误。

@Override
public void addTransformer(ClassFileTransformer transformer) {
Assert.notNull(transformer, "Transformer must not be null");
FilteringClassFileTransformer actualTransformer =
new FilteringClassFileTransformer(transformer, this.classLoader);
synchronized (this.transformers) {
Assert.state(this.instrumentation != null,
"Must start with Java agent to use InstrumentationLoadTimeWeaver. See Spring documentation.");
this.instrumentation.addTransformer(actualTransformer);
this.transformers.add(actualTransformer);
}
}

我只是想不通如何使用空检测对其进行实例化。显然我错过了一些东西。可能是一些小而愚蠢的东西。但现在我没主意了。

最佳答案

看来问题出在类加载上

  1. 添加 '-verbose:class' 选项以查看是否 InstrumentationLoadTimeWeaver已加载

  2. 尝试将此选项添加到您的 tomcat 上下文配置中
    <Context>
    ...
    <Loader delegate="true"/>
    ...
    </Context>

Tomcat 7.0.27 中的一些更改可能会触发此问题

Make the implementation of Catalina.getParentClassLoader consistent with similar methods across the code base and have it return the system class loader if no parent class loader is set. (markt)

关于java - 必须启动 Instrumentation LoadTimeWeaver/openjdk 11,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54811216/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com