[jboss-dev-forums] [Deployers on JBoss (Deployers/JBoss)] - Re: HOWTO deploy webapp dynamically

richard.opalka@jboss.com do-not-reply at jboss.com
Wed Jun 25 11:43:13 EDT 2008


This is our usecase:

We have the jaxws-endpoint-servlet.war web archive with the following content:

jar -tvf  jaxws-endpoint-servlet.war
  META-INF/
  META-INF/MANIFEST.MF
  WEB-INF/
  WEB-INF/classes/
  WEB-INF/classes/org/
  WEB-INF/classes/org/jboss/
  WEB-INF/classes/org/jboss/test/
  WEB-INF/classes/org/jboss/test/ws/
  WEB-INF/classes/org/jboss/test/ws/jaxws/
  WEB-INF/classes/org/jboss/test/ws/jaxws/endpoint/
  WEB-INF/classes/org/jboss/test/ws/jaxws/endpoint/EndpointBean.class
  WEB-INF/classes/org/jboss/test/ws/jaxws/endpoint/EndpointInterface.class
  WEB-INF/classes/org/jboss/test/ws/jaxws/endpoint/EndpointServlet.class
  WEB-INF/wsdl/
  WEB-INF/wsdl/TestService.wsdl
  WEB-INF/web.xml

The most important class here is EndpointServlet, which contains the following lines of code:


  | public void init(ServletConfig config) throws ServletException
  | {
  |    super.init(config);
  | 
  |    // Create the endpoint
  |    EndpointBean epImpl = new EndpointBean();
  |    javax.xml.ws.Endpoint endpoint = Endpoint.create(SOAPBinding.SOAP11HTTP_BINDING, epImpl);
  | 
  |    // Create and start the HTTP server
  |    SPIProvider spiProvider = SPIProviderResolver.getInstance().getProvider();
  |    HttpServer httpServer =  spiProvider.getSPI(HttpServerFactory.class).getHttpServer();
  |    httpServer.start();
  |       
  |    // Create the context and publish the endpoint
  |    HttpContext context = httpServer.createContext("/jaxws-endpoint");
  |    endpoint.publish(context);
  | }
  | 

The purpose of this code is to create new web application deployment dynamically using this api only. The endpoint published this way must reside on address http://localhost:8080/jaxws-endpoint where HttpContext and Endpoint are our abstractions.

Our current approach:

To solve this use case we're creating new web deployment dynamically this way at the moment:


  | JBossWebMetaData jbwmd = dep.getAttachment(JBossWebMetaData.class);
  | 
  | AbstractDeployment deployment = createSimpleDeployment(dep.getSimpleName());
  | MutableAttachments ma = (MutableAttachments)deployment.getPredeterminedManagedObjects();
  | ma.addAttachment(HttpSpec.PROPERTY_GENERATED_WEBAPP, Boolean.TRUE);
  | ma.addAttachment(ClassLoaderFactory.class, new ContextClassLoaderFactory());
  | ma.addAttachment(JBossWebMetaData.class, jbwmd);
  | mainDeployer.deploy(deployment);
  | 
  | ...
  | 
  | private static class ContextClassLoaderFactory implements ClassLoaderFactory
  | {
  |    public ClassLoader createClassLoader(DeploymentUnit unit) throws Exception
  |    {
  |       return Thread.currentThread().getContextClassLoader();
  |    }
  | 
  |    public void removeClassLoader(DeploymentUnit unit) throws Exception
  |    {
  |    }
  | }
  | 

Problem we're dealing with:

We're not able to dynamically deploy this archive to http://localhost:8080/jaxws-endpoint context. The dynamically created application is deployed to http://localhost:8080/jaxws-endpoint-servlet context.

I guess this is because of our custom class loader we have. Is there a possibility to enforce deployment context?

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4160586#4160586

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4160586



More information about the jboss-dev-forums mailing list