5 Replies Latest reply on Jun 3, 2011 5:48 AM by adinn

    Problem with web.xml referencing WEB-INF classes and lib in AS7

    adinn

      Hi guys,

       

      I found another problem deploying the XTS interop tests to AS7. I can work round it but I think there issomething wrong in the dpeloyment model.

       

      The deployment is a war which includes a junit jar in WEB-INF/lib and a mix of servlet classes and JaxWS endpoint implementation classes in WEB-INF/classes. When I deploy the web-app the JaxWS endpoint classes are not recognised as JaxWS endpoints even though they do have WebService annottaions (thsi is not a missing depenendencies problem -- the annotations do exist on the class).

       

      12:39:13,100 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/sc007]] (MSC service thread 1-3) Servlet /sc007 threw load() exception: java.lang.ClassCastException: com.jboss.transaction.wstf.webservices.sc007.sei.ParticipantPortTypeImpl cannot be cast to javax.servlet.Servlet
          at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1162) [jbossweb-7.0.0.CR1.jar:7.0.0.Beta4-SNAPSHOT]
          at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1108) [jbossweb-7.0.0.CR1.jar:7.0.0.Beta4-SNAPSHOT]
          at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3631) [jbossweb-7.0.0.CR1.jar:7.0.0.Beta4-SNAPSHOT]
          at org.apache.catalina.core.StandardContext.start(StandardContext.java:3840) [jbossweb-7.0.0.CR1.jar:7.0.0.Beta4-SNAPSHOT]
          at org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:70) [jboss-as-web-7.0.0.Beta4-SNAPSHOT.jar:7.0.0.Beta4-SNAPSHOT]
          at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1675)
          at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [:1.6.0_21]
          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [:1.6.0_21]
          at java.lang.Thread.run(Thread.java:619) [:1.6.0_21]
      

       

      It turns out that the problem is to do with the presence of both a WEB-INF classes directory and WEB-INF/lib jars. I stopped the debugger in WSDependenciesProcessor.isJaxwsJseDeployment() and identified the problem.

       

              private boolean isJaxwsJseDeployment(final DeploymentUnit unit) {
              final boolean isWarDeployment = DeploymentTypeMarker.isType(DeploymentType.WAR, unit);
              if (isWarDeployment) {
                  final Index index = ASHelper.getRootAnnotationIndex(unit);
                  final WarMetaData warMetaData = ASHelper.getOptionalAttachment(unit, WarMetaData.ATTACHMENT_KEY);
                  if (warMetaData != null && warMetaData.getWebMetaData() != null) {
                      return (ASHelper.selectWebServiceServlets(index, warMetaData.getWebMetaData().getServlets(), true).size() > 0);
                  }
              }
      
              return false;
          }
      

       

      The problem is that call to ASHelper.getRootAnnotationIndex. The deployment has two entries in its annotation map, one for the stuff in WEB-INF/lib and another for the stuff in WEB-INF/classes. getRootAnnotationIndex picks the first one it finds with the MODULE_ROOT_MARKER tag. Unfortunately both of them have this tag and it returns the one for WEB-INF/lib losing all info about the annotations on classes in WEB-INF/classes.

       

      I suppose this is an AS problem more than a WS one but its definitely going to cause some difficulties for WS users.