Enable or disable annotation scanning when an app is deployed in WebSphere (metadata complete)

Home > Search
  by

By default, when an app is deployed or restarted, 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
public class People {
    . . .
}

 

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

 


Disable annotation scanning

There are two ways that annotation scanning can be disabled. You can either add metadata-complete="true" to the apps web.xml file, or you can enable the metadata-complete attribute in the WebSphere admin console.

web.xml

<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 deploying the app using the WebSphere admin console, you can select the metadata-complete attribute to disable 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

 



Add a Comment




We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.




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




Comments