Bootstrap FreeKB - IBM WebSphere - Annotation scanning (metadata complete attribute)
IBM WebSphere - Annotation scanning (metadata complete attribute)

Updated:   |  IBM WebSphere articles

By default, when an app is deployed or restarted on WebSphere, the annotations in the app will be scanned. For example, lets consider an app that has a few annotations. The scanning of each annotation in the app will increase the time it takes to deploy or restart the app. 

@Annotation1
@Annotation2
@Annotation3

 

There are advantages and disadvantages to having annotation scanning enabled or disabled.

  • Advantage - Disabiling annotation scanning should reduce the time it takes to deploy or restart the app.
  • Disadvantage - Disabiling annotation scanning will not record issues with annotation in the JVMs SystemOut.log

 


Enable or Disable annotation scanning

The preferred way to enable or disable annotation scanning is to add metadata-complete="true" or metadata-complete="false" to the apps web.xml file. The reason this is preferred is because then you will not be asked if you want to scan annotations when manually deploying the app to WebSphere, or to define if annotations should be scanned as part of an automated deploy, and to define if annotations should be scanned when the application is restarted.

<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
metadata-complete="true"
version="2.5">

 

If there is some reason why you cannot add metadata-complete="true" or metadata-complete="false" to the apps web.xml file, then you will get the metadata-complete prompt when manually deploying the app to WebSphere. Check marking the metadata-complete attribute disables annotation scanning when the app is deployed or restarted.

 


SRVE8000W in SystemOut.log

While disabiling annotation scanning as the advantage of reducing the time it will take to deploy the app, the disadvanage is that the JVM may not catch issues when the classes are scanned for annotations. When annotation scanning is enabled, the JVMs SystemOut.log should record a stack trace error when an issue is found with annotation scanning. In this example, the JVMs SystemOut.log records a problem with annotation scanning with the "People" class in the "com.example.main" package.

[11/5/18 22:40:26:690 CST] 000000aa annotation    W com.ibm.ws.webcontainer.annotation.WASAnnotationHelper collectClasses SRVE8000W: Skipped class that failed to initialize for annotation scanning.
                                 java.lang.ClassNotFoundException: com.example.main.People

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter e43339 in the box below so that we can be sure you are a human.