1 2 Previous Next 15 Replies Latest reply on Feb 14, 2017 5:17 AM by malys Go to original post
      • 15. Re: ear manifest file access
        malys

        Hello,

        Reading this post, for jboss-as 7,  I have developed a jboss extension to read the manifest file included in ear/war/jar to put the "implementation-version" attribute in jboss model.

         

        @Override
        public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
        try {
        ResourceRoot root = phaseContext.getDeploymentUnit().getAttachment(Attachments.DEPLOYMENT_ROOT);
        if (root.getRoot().exists()) {

         

        Manifest manifest = VFSUtils.getManifest(root.getRoot());
        if (manifest != null) {
        Attributes attributes = manifest.getMainAttributes();
        if (attributes != null) {
        Resource resource = phaseContext.getDeploymentUnit()
        .getAttachment(DeploymentModelUtils.DEPLOYMENT_RESOURCE);
        String value = getAttributeValueOrDefault(attributes, "Implementation-Version");
        resource.getModel().get("implementation-version").set(value);
        }
        }
        }
        } catch (final IOException e) {
        log.error("Fail to register app version in JBoss", e);
        }

         

        }

        I don't find any documentation to explain internal concepts of DeployementUnitProcessing and attachments and I'm not sure that was the best way to do it. But, It works fine on JBoss as 7.

         

        I wish port this extension on Wildlfy 10.

         

        11:10:04,055 ERROR [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 1) WFLYDS0012: Scan of .... threw Exception: java.lang.RuntimeException: WFLYDS0036: Deployment model operation failed. undefined

                at org.jboss.as.server.deployment.scanner.DefaultDeploymentOperations.getDeploymentsStatus(DefaultDeploymentOperations.java:83)

                at org.jboss.as.server.deployment.scanner.FileSystemDeploymentService$ScanContext.<init>(FileSystemDeploymentService.java:1614)

                at org.jboss.as.server.deployment.scanner.FileSystemDeploymentService$ScanContext.<init>(FileSystemDeploymentService.java:1563)

                at org.jboss.as.server.deployment.scanner.FileSystemDeploymentService.scan(FileSystemDeploymentService.java:568)

                at org.jboss.as.server.deployment.scanner.FileSystemDeploymentService.scan(FileSystemDeploymentService.java:489)

                at org.jboss.as.server.deployment.scanner.FileSystemDeploymentService$DeploymentScanRunnable.run(FileSystemDeploymentService.java:250)

                at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)

                at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308)

                at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180)

                at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294)

                at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)

                at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)

                at java.lang.Thread.run(Thread.java:745)

                at org.jboss.threads.JBossThread.run(JBossThread.java:320)

         

        On JBoss AS 7, the extension works like this:

        /deployment=*:read-resource

        {

            "outcome" => "success",

            "result" => [

                {

                    "address" => [("deployment" => "doe.ear")],

                    "outcome" => "success",

                    "result" => {

                        "content" => [{

                            "path" => "deployments/doe.ear",

                            "relative-to" => "jboss.server.base.dir",

                            "archive" => true

                        }],

                        "enabled" => true,

                        "implementation-version" => "2.0.2",

                        "name" => "doe.ear",

                        "persistent" => false,

                        "runtime-name" => "doe.ear"

                    }

                }

         

        Any ideas,

        Thank you.

        1 2 Previous Next