尝试在Websphere 8.5.5.13上部署Ear时存在AnnotationException?

时间:2018-12-18 13:59:00

标签: java spring websphere

在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";
    }

}

3 个答案:

答案 0 :(得分:3)

您需要在下一个修订包中使用PI96826

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

  

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

答案 1 :(得分:2)

错误消息抱怨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的列表如下。请注意,8.5.5.14中包含3个APAR,而其他8.2.5.15中则包含2个。您可能不需要全部。它取决于您的应用程序,在一种情况下,取决于应用程序类的扫描顺序。

WAS V9有一个第六个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 :(得分:0)

(临时)解决方法是使用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
     

使用这些选项可以限制扫描哪些类的注释。

我最近在等待应用适当的WebSphere Fixpack时就使用了amm.filter.properties版本,它使我们能够绕开我们眼前的问题。

在我们的案例中,有Jackson 2.10个库在抱怨,因此我将上述文件的WebSphere根属性版本复制到了我的profile / properties目录中,并将Jackson罐子添加到了Ignore-Scanning-Archives部分。

似乎还必须重新启动我们的WebSphere ND Node Agent并重新部署应用程序,以解决最初的问题。

相关问题