1 2 3 4 Previous Next 48 Replies Latest reply on Jun 26, 2008 1:33 AM by ropalka Go to original post
      • 15. Re: HOWTO deploy webapp dynamically

         

        "thomas.diesler@jboss.com" wrote:
        I read http://labs.jboss.com/file-access/default/members/jbossmc/freezone/docs/2.0.x/userGuide/pt04.html
        Is there anywhere else this is documented?

        How do I set the deployments class path?
        I cant do

         // There is one top level deployment
         ContextInfo context = factory.addContext(unit, "");
         context.addClassPathEntry(entry);
        



        I don't know if the non-VFS stuff is documentated?
        There's certainly lots of examples in the testsuite.
        The user guide just tells people how to do normal things. ;-)

        You certainly can't add a classpath entry if you don't a virtual file system
        to back your deployment. It doesn't mean anything.


        In my case, the deployment should use the context class loader of the calling component.


        You can override how the classloader gets "constructed" with an attachment
        (the ClassLoaderFactory)
        http://viewvc.jboss.org/cgi-bin/viewvc.cgi/jbossas/projects/microcontainer/trunk/deployers-spi/src/main/org/jboss/deployers/spi/deployer/helpers/AbstractClassLoaderDeployer.java?revision=69940&view=markup
        which tells the classloader deployer to not use it's own mechanism
        but to use the attached factory.

        Although I don't like this mechanism and I'm currently reworking it
        with proper classloader metadata including dependencies.

        e.g. So for now, you could write a ClassLoaderFactory
        that just returns a preset classloader.

        It should be obvious why this is bad, since you're going to leak that classloader
        unless you have tight control on when the thing gets undeployed
        (either the original deployment or the deployment you are constructing).

        Using the ClassLoaderFactory side steps the dependency checks/rules.

        • 16. Re: HOWTO deploy webapp dynamically

           

          "adrian@jboss.org" wrote:

          I don't know if the non-VFS stuff is documentated?
          There's certainly lots of examples in the testsuite.
          The user guide just tells people how to do normal things. ;-)


          Also, I don't know if it will work in JBossAS anyway at the moment.

          There's a todo item to test a programmatic deployment (like what you are
          trying perform), e.g. deploy a datasource from just metadata
          and then fix all the deployers that currently assume there is a virtual file

          I've already fixed a lot them, but people keep putting the same mistakes back in the code :-(

          • 17. Re: HOWTO deploy webapp dynamically
            thomas.diesler

            I am getting further. The endpoint deploys

            14:32:59,417 INFO [TomcatDeployment] deploy, ctxPath=/jaxws-endpoint-servlet, vfsUrl=
            14:33:00,357 INFO [DefaultEndpointRegistry] register: jboss.ws:context=jaxws-endpoint,endpoint=EndpointBean
            


            However, there seems to be a problem with the JACC service not finding jboss:service=defaultClassLoader

            14:33:00,690 ERROR [AbstractKernelController] Error installing to Instantiated: name=jboss.jacc:id=endpoint-deployment,service=jacc state=Described mode=Manual requiredState=Configured
            org.jboss.deployment.DeploymentException: Unable to createMBean for jboss.jacc:service=jacc,id=endpoint-deployment
             at org.jboss.deployment.DeploymentException.rethrowAsDeploymentException(DeploymentException.java:52)
            
            ...
            
            Caused by: javax.management.InstanceNotFoundException: jboss:service=defaultClassLoader is not registered.
             at org.jboss.mx.server.registry.BasicMBeanRegistry.get(BasicMBeanRegistry.java:529)
             at org.jboss.mx.server.MBeanServerImpl.getClassLoader(MBeanServerImpl.java:1094)
             at org.jboss.system.ServiceCreator.installPlainMBean(ServiceCreator.java:191)
             at org.jboss.system.ServiceCreator.install(ServiceCreator.java:115)
            


            • 18. Re: HOWTO deploy webapp dynamically
              anil.saldhana

              Thomas, can you enable some trace on "org.jboss.system" and paste it here?

              The Security Deployer just deals with the MetaData and creates a top level service bean. It does not do any Classloader circus.

              There is something that is happening with your web service deployments.

              • 19. Re: HOWTO deploy webapp dynamically

                The relevant code is in the ServiceDeployer:

                 public void deploy(DeploymentUnit unit, ServiceMetaData deployment) throws DeploymentException
                 {
                 ObjectName name = deployment.getObjectName();
                 try
                 {
                 ObjectName loaderName = deployment.getClassLoaderName();
                 if (loaderName == null)
                 {
                 ClassLoader cl = unit.getClassLoader();
                 if (cl != null && cl instanceof RepositoryClassLoader)
                 loaderName = ((RepositoryClassLoader) cl).getObjectName();
                 // TODO add to RealClassLoader
                 else if (cl != null && cl instanceof RealClassLoader)
                 loaderName = ((RealClassLoader) cl).getObjectName();
                 else
                 loaderName = defaultClassLoader;
                 }
                


                I'd guess the actual classloader Thomas is passing in, is not a RealClassLoader
                (but it probably has one as a parent) so this code should loop through
                ClassLoader::getParent() until it finds one that is, before trying to use
                "defaultClassLoader" which doesn't look like it is even configured.

                • 20. Re: HOWTO deploy webapp dynamically
                  starksm64

                  What is the codebase for the org.jboss.test.ws.jaxws.endpoint.EndpointTestCase in the JBAS-5257 issue? The last time I looked at the ws tests the codebase was https://svn.jboss.org/repos/jbossws/stack/native/branches/jbossws-native-2.0.2. This no longer exists?

                  • 22. Re: HOWTO deploy webapp dynamically
                    thomas.diesler

                     


                    You create Deployment on the fly


                    Yes, please show me the code that creates the deployment on the fly - attaches the WMD and deployes it afterwards.

                    • 23. Re: HOWTO deploy webapp dynamically
                      alesj

                       

                      "thomas.diesler@jboss.com" wrote:

                      You create Deployment on the fly


                      Yes, please show me the code that creates the deployment on the fly - attaches the WMD and deployes it afterwards.

                      Looking at the previous posts in this thread, I see a dozen such examples.
                      Why are they not good?
                      Or where exactly are you stuck now?

                      • 24. Re: HOWTO deploy webapp dynamically
                        ropalka

                         

                        "alesj" wrote:
                        Or where exactly are you stuck now?


                        Download svn module https://svn.jboss.org/repos/jbossws/stack/native/branches/jbossws-native-3.0.2
                        remove JBAS-5257 test exclusion from modules/testsuite/test-excludes-jboss501.txt
                        start JBossAS trunk server
                        copy jbossws-native-3.0.2/profiles.xml.example to jbossws-native-3.0.2/profiles.xml and update accordingly
                        issue command mvn -Ptestsuite,hudson,jboss501 -Djava.jdk15.home=$JAVA_HOME -Dtest=**/jaxws/endpoint/*TestCase test from directory jbossws-native-3.0.2


                        • 25. Re: HOWTO deploy webapp dynamically
                          alesj

                          I meant programatically. :-)

                          What is the piece of code that tries to do something with deployments but fails?
                          What exactly is trying to do?
                          What is supposed to do?
                          Where do you see the possible problem?
                          ...

                          You need to give me exact details.
                          Or exact questions.

                          Sorry, but I'm not gonna dig into WS code.

                          • 26. Re: HOWTO deploy webapp dynamically
                            ropalka

                            Give me few minutes, I'll review the test and the failure.

                            • 27. Re: HOWTO deploy webapp dynamically

                              Ales, don't worry about it.
                              I gave up trying to help these guys a while ago.

                              If somebody doesn't have the analysis skills to make a question answerable
                              then I don't have the time to try to guess/work out what the question actually is.
                              http://wiki.jboss.org/wiki/HelpExpertSystem

                              Please help me, is not such a question.

                              • 28. Re: HOWTO deploy webapp dynamically
                                ropalka

                                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?

                                • 29. Re: HOWTO deploy webapp dynamically
                                  starksm64

                                  You need to make a copy of the JBossWebMetaData and use setContextRoot("jaxws-endpoint").

                                  The getPredeterminedManagedObjects attachments bucket is the wrong one to be using. This is for data that is set from previous admin edits through the profileservice. The client spi does not look correct for deployer implementations.

                                  We also need this usecase in the jbossas testsuite as an illustration of proper dynamic deployment creation.