【问题标题】:There is AnnotationException when try to deploy ear on websphere 8.5.5.13?尝试在 websphere 8.5.5.13 上部署 ear 时出现 AnnotationException?
【发布时间】:2019-05-18 23:13:30
【问题描述】:

spring 4.13 有应用 因此,当尝试在 websphere 8.5.5.13 上部署 ear-file 时 - 出现错误消息

[12/18/18 14:56:41:946 MSK] 00000086 AnnotationCon E CWMDF0002E: 注释处理失败,出现以下错误: com.ibm.ws.metadata.annotations.AnnotationException:注释 类处理失败: META-INF/versions/9/javax/xml/bind/ModuleUtil.class

这是什么问题? 这可能是应用程序和服务器库的安装错误或错误不兼容?

应用程序有入口点

@Configuration
@EnableWebMvc
@ComponentScan(basePackages = {"spring"})
public class WebAppInitalizer implements WebApplicationInitializer {
    private static final String CONFIG_LOCATION = "spring.config";
    private static final String MAPPING_URL = "/*";

    @Override
    public void onStartup(ServletContext servletContext) throws ServletException {
        System.out.println(">>>>>>>>>>>>>>>>>>>>>>> ONSTARTUP <<<<<<<<<<<<<<<<<<<<<<<<");
        WebApplicationContext context = getContext();
        servletContext.addListener(new ContextLoaderListener(context));
        ServletRegistration.Dynamic dispatcher = servletContext.addServlet("DispatcherServlet", new DispatcherServlet(context));
        dispatcher.setLoadOnStartup(1);
        dispatcher.addMapping(MAPPING_URL);
        System.out.println(">>>>>>>>>>>>>>>>>>>>>>> ONSTARTUP END <<<<<<<<<<<<<<<<<<<<<<<<");
    }

    private AnnotationConfigWebApplicationContext getContext() {
        AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
        context.setConfigLocation(CONFIG_LOCATION);
        return context;
    }
}

和配置是

package spring.config;

import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;

@Configuration
@ComponentScan(basePackages = "spring")
public class AppConfig {
}


   package spring.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

@Configuration
@EnableWebMvc
public class WebConfig extends WebMvcConfigurerAdapter {
}

测试控制器是:

package spring.controller;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class TestController {

    @RequestMapping(value = "/greeting")
    public String healthCheck() {
        return "greeting";
    }

}

【问题讨论】:

    标签: java spring websphere


    【解决方案1】:

    错误信息是抱怨 META-INF/versions/9 目录下的一个类。该位置表明您有一个包含 java V9 类的多版本 JAR。 WAS 不支持 Java V9 类,但已添加代码以在多版本 JAR 中容忍它们。

    直到发布 WAS 8.5.5 和 WAS 9.0 之后,才存在多版本 JAR。为 WAS 8.5.5 创建了五个 APAR,以解决在开始将多版本 JAR 添加到应用程序时发现的问题。 APAR 列表如下。请注意,3 个 APAR 包含在 8.5.5.14 中,另外 2 个包含在 8.5.5.15 中。您可能不需要所有这些。这取决于您的应用程序,在一种情况下,还取决于扫描应用程序类的顺序。

    WAS V9 有第 6 个 APAR,仅用于性能。它不适用于 WAS 8.5.5。

    底线:要完全容忍多版本 JAR,您需要升级到 8.5.5.15 或 9.0.0.10 或应用以下所有 APAR。

    1. PI89708 – 8.5.5.14、9.0.0.7
    2. PI93744 – 8.5.5.14、9.0.0.8
    3. PI96826 – 8.5.5.14、9.0.0.8
    4. PH02014 – 8.5.5.15、9.0.0.10
    5. PH03710 – 8.5.5.15, 9.0.0.10
    6. PI98450 - 不适用,9.0.0.9

    【讨论】:

      【解决方案2】:

      下一个补丁包中需要 PI96826

      https://www-01.ibm.com/support/docview.wss?uid=swg1PI96826

      Java V9 多版本 JAR 包含 META-INF 下的 Java V9 类 目录树。 Java V9 类的存在导致应用 开始失败,出现类似于以下的异常:

      【讨论】:

      • 但是从这个链接错误消息是处理类失败:META-INF/versions/9/org/apache/logging/log4j/util/ProcessIdUtil。但是错误是类的注释处理失败:META-INF/versions/9/javax/xml/bind/ModuleUtil.class 是否有相同的错误?
      • 鉴于补丁中对问题的解释,似乎很可能是相同的错误。问题是注解处理器无法处理为 Java 9 编译的类。对于它找到的 any 此类文件,它将失败 ...
      • @StephenC 修复是安装补丁 8.5.5.14,不是吗?
      【解决方案3】:

      还有一个(临时)解决方法是使用Reducing annotation searches during application deployment 中描述的存档或包过滤来排除某些库或类的扫描。

      产品提供可配置的过滤功能,以减少 搜索注释的类数。你可以识别 注释处理要忽略哪些模块或 Java 包 通过四个属性:(或清单属性):

      Ignore-Scanning-Archives
      Ignore-Scanning-Packages
      Include-Scanning-Archives
      Include-Scanning-Packages
      

      属性可以在 amm.filter.properties 中指定 app_server_root/properties,或者可以指定为清单 属性。您还可以识别哪些模块或 Java 包 使用这些系统属性忽略:

      com.ibm.ws.amm.scan.context.filter.archives
      com.ibm.ws.amm.scan.context.filter.packages
      com.ibm.ws.amm.scan.context.include.archives
      com.ibm.ws.amm.scan.context.include.packages
      

      使用这些选项来限制扫描哪些类以查找注释。

      我自己最近使用了 amm.filter.properties 版本,同时等待应用适当的 WebSphere 修复包,它使我们能够绕过我们眼前的问题。

      在我们的例子中,是 Jackson 2.10 库在抱怨,所以我将上述文件的 WebSphere 根属性版本复制到我的配置文件/属性目录,并将 Jackson jar 添加到 Ignore-Scanning-Archives 部分。

      看来我必须重新启动我们的 WebSphere ND 节点代理并重新部署应用程序 ear/war 才能解决最初的问题。

      【讨论】:

      • 请问你是怎么知道哪个图书馆在抱怨的
      • @Harsha 有问题的库在 WebSphere 日志中。例如[11/4/19 11:50:56:639 CST] 0000011c wtp W org.eclipse.jst.j2ee.commonarchivecore.internal.helpers.WARFileAnnotationsDetector locateAnnotations Failed to create class reader for [ module-info.class ] in [ WEB-INF/lib/jackson-databind-2.10.0.jar ]
      猜你喜欢
      • 2014-08-29
      • 1970-01-01
      • 2018-09-22
      • 2019-04-27
      • 2014-08-02
      • 1970-01-01
      • 1970-01-01
      • 2022-01-12
      • 1970-01-01
      相关资源
      最近更新 更多