8 Replies Latest reply: Feb 24, 2011 7:50 AM by Ales Justin RSS

Custom Deployer - migrate from JBoss4.2

Mikhail Kolesnikov Newbie

In JBoss4 there is a class org.jboss.deployment.SubDeployerSupport

Using this class I'm develop custom deployer, that now used in development and production too.

 

In that deployer I'm override method

protected void processNestedDeployments(DeploymentInfo di)

and some other methods too.

 

Using internal config file deployment.xml I'm sort and filter subdeployments as needed by business requirements. Obtain information about deployed package and deployment status. I'm create MBean for obtain information about sub-deployments via JMX console. And more other things...

 

Now our team planned to migrate on JBoss5 (may be 6). And I see that SubDeployerSupport is comletely not usefull in JBoss 5 and later.

 

I'm trying to use classes:

  • org.jboss.deployers.spi.deployer.helpers.AbstractDeployer
  • org.jboss.deployers.vfs.plugins.structure.AbstractVFSStructureDeployer

With some settings such as:

  • setStage(DeploymentStages.INSTALLED);
  • setStage(DeploymentStages.PRE_REAL);
  • setRelativeOrder(...);

With a combination of such parameters I'm can obtain deployment status and list of deployments. But I'm still can't sort and filter subdeployments!

 

The question was: how I must use Deployer in JBoss5 (6) for sort and filter subdeployments?

  • 1. Custom Deployer - migrate from JBoss4.2
    Ales Justin Master
    The question was: how I must use Deployer in JBoss5 (6) for sort and filter subdeployments?

    In case you missed this article, a bit more info on how MC' VDF works:

    * http://java.dzone.com/articles/jboss-microcontainer-virtual-deployment-framework

     

    To answer the question, you can do this:

     

    (a) use jboss-structure.xml to define a deployment comparator per (sub)deployment

    * http://community.jboss.org/wiki/JBoss5custommetadatafiles

    A down side of this is that you then have to be explicit about all things; metadata locations, classpath, ...

     

    (b) you can add a deployer that dynamically/runtime sets relative order of subdeployments

    * see DeploymentUnitExt::changeRelativeOrder

     

    (c) set global comparator in deployers.xml for MainDeployerImpl

    * <property name="comparator"><inject bean="topContextComparator"/></property>

  • 2. Custom Deployer - migrate from JBoss4.2
    Ales Justin Master
    The question was: how I must use Deployer in JBoss5 (6) for sort and filter subdeployments?

    Previous post was about sorting.

    What exactly do you wanna filter?

     

    In VDF all deployers touch all (sub)deployments.

    It's just a matter of how soon you determine that the given (sub)deployment is not relevant for a deployer.

    Hence it's up to a deployer to filter/determine what it needs to process.

     

    e.g. some short circuit logic is prefered, so you don't endup processing all deployments only to realize at the end that there is nothing to process

  • 3. Custom Deployer - migrate from JBoss4.2
    Mikhail Kolesnikov Newbie

    Ales Justin wrote:

    (b) you can add a deployer that dynamically/runtime sets relative order of subdeployments

    * see DeploymentUnitExt::changeRelativeOrder


    Thanks for DeploymentUnitExt::changeRelativeOrder !!!

     

     

    Ales Justin wrote:

    determine that the given (sub)deployment is not relevant for a deployer

    I'm need to determine that given subdeployments is not needed for deployment at all. In JBoss4 I'm just remove such subdeployments from DeploymentInfo.subDeployments and all goes OK.

     

    Example deployment structure:

    • some-service.myDeployerExt
      • sub-last.jar
      • sub-only-need-in-special-case.jar
      • sub-second.jar
      • sub-first.jar

     

    And I'm need this subdeployments to start in the right order, but sub-only-need-in-special-case.jar is not need to be started at all:

    1. sub-first.jar
    2. sub-second.jar
    3. sub-last.jar

     

    Sorting problem I had already solved (thanks a lot!) but how can I exclude subdeployments from the deployment process at all? I see that task intended to the StructureDeployer, but can't get a right way...

  • 4. Custom Deployer - migrate from JBoss4.2
    Mikhail Kolesnikov Newbie

    And more... I see DeploymentUnitExt::changeRelativeOrder works only in JBoss6. Is there any "hack" to do such ordering in JBoss5???

  • 5. Custom Deployer - migrate from JBoss4.2
    Ales Justin Master
    And more... I see DeploymentUnitExt::changeRelativeOrder works only in JBoss6. Is there any "hack" to do such ordering in JBoss5???

    I think I ported this feature to MC Deployers 2.0.x as well.

    Check if this really exists in 2.0.10.GA version and then simply replace it.

  • 6. Custom Deployer - migrate from JBoss4.2
    Ales Justin Master
    I'm need to determine that given subdeployments is not needed for deployment at all. In JBoss4 I'm just remove such subdeployments from DeploymentInfo.subDeployments and all goes OK.

     

    Example deployment structure:

    • some-service.myDeployerExt
      • sub-last.jar
      • sub-only-need-in-special-case.jar
      • sub-second.jar
      • sub-first.jar

     

    And I'm need this subdeployments to start in the right order, but sub-only-need-in-special-case.jar is not need to be started at all:

    1. sub-first.jar
    2. sub-second.jar
    3. sub-last.jar

     

    Sorting problem I had already solved (thanks a lot!) but how can I exclude subdeployments from the deployment process at all? I see that task intended to the StructureDeployer, but can't get a right way...

    Simply use jboss-structure.xml, where you explicitly define (sub)deployments.

     

    Or you could add a new StructureDeployer, which would still recognize this sub-deployment,

    but would mostly make it a no-op; e.g. no classpath, meta locations, ...

  • 7. Custom Deployer - migrate from JBoss4.2
    Mikhail Kolesnikov Newbie

    I have setted up my Structure Deployer to recognize (return true) some deployments I'm not really need. But JBoss5 returned me a message like that:

    14:47:23,704 ERROR [AbstractKernelController] Error installing to PostClassLoader: name=vfsfile:/usr/local/jboss-5.1.0.GA/server/default/deploy/test.onyma/ state=ClassLoader mode=Manual requiredState=PostClassLoader

    org.jboss.deployers.spi.DeploymentException: Cannot process metadata

        at org.jboss.deployers.spi.DeploymentException.rethrowAsDeploymentException(DeploymentException.java:49)

    ...

    Caused by: java.lang.RuntimeException: java.lang.ClassNotFoundException: test.TestJob from BaseClassLoader@692a88{ ... }}

        at org.jboss.deployers.plugins.annotations.WeakClassLoaderHolder.loadClass(WeakClassLoaderHolder.java:76)

    Seems that annotations from this "not need" subdeployments are still recognized by EJBDeployer or some other deployers. How can I tell other deployers not to check "not need" package at all?

  • 8. Custom Deployer - migrate from JBoss4.2
    Ales Justin Master
    I have setted up my Structure Deployer to recognize (return true) some deployments I'm not really need. But JBoss5 returned me a message like that:

    Are you sure you don't have any classpath and metadata location entries setup?

     

    Seems that annotations from this "not need" subdeployments are still recognized by EJBDeployer or some other deployers. How can I tell other deployers not to check "not need" package at all?

    * http://java.dzone.com/articles/jboss-microcontainer-scanning