1 Reply Latest reply: Jun 4, 2012 4:17 PM by Philippe Marschall RSS

metadata-complete="true" not respected

Philippe Marschall Novice

I have a servlet 3 application with metadata-complete="true" however JBoss AS 7 still tries to instantiate classes it should not (like AsyncListener subclasses). Consider the following simple application:

 

<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_3_0.xsd"
      version="3.0"
      metadata-complete="true">

 <servlet>
 <servlet-name>bug</servlet-name>
 <servlet-class>com.github.marschall.async_context_bug.BugServlet</servlet-class>
 <async-supported>true</async-supported>
 </servlet>

 <servlet-mapping>
 <servlet-name>bug</servlet-name>
 <url-pattern>/*</url-pattern>
 </servlet-mapping>

</web-app>

 

public class BugServlet extends HttpServlet {
  
    public void init() throws ServletException {
        new AsyncListener() {
  
            public void onTimeout(AsyncEvent event) {
            }
  
            public void onStartAsync(AsyncEvent event) {
            }
  
            public void onError(AsyncEvent event) {
  
            }
  
            public void onComplete(AsyncEvent event) {
            }
        };
    }
  
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
        resp.getWriter().write("OK");
    }

}

 

This results in the following deployment error

 

22:16:10,289 WARN  [org.jboss.as.ee] (MSC service thread 1-4) JBAS011006: Optionale Komponente com.github.marschall.async_context_bug.BugServlet$1 wird aufgrund von Ausnahme nicht installiert: org.jboss.as.server.deployment.DeploymentUnitProcessingException: JBAS011054: Konnte Standard-Konstruktor für class com.github.marschall.async_context_bug.BugServlet$1 nicht finden
 at org.jboss.as.ee.component.ComponentDescription$DefaultComponentConfigurator.configure(ComponentDescription.java:606) [jboss-as-ee-7.2.0.Alpha1-SNAPSHOT.jar:7.2.0.Alpha1-SNAPSHOT]
 at org.jboss.as.ee.component.deployers.EEModuleConfigurationProcessor.deploy(EEModuleConfigurationProcessor.java:83) [jboss-as-ee-7.2.0.Alpha1-SNAPSHOT.jar:7.2.0.Alpha1-SNAPSHOT]
 at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:116)
 at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811)
 at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746)
 at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) [rt.jar:1.7.0_04]
 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) [rt.jar:1.7.0_04]
 at java.lang.Thread.run(Thread.java:722) [rt.jar:1.7.0_04]

 

The applicatin deploys fine without error on Tomcat 7. You can find the source at https://github.com/marschall/async-context-bug