glassfish
  1. glassfish
  2. GLASSFISH-17002

Embedded GlassFish fails to retrieve client stub JAR file

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Critical Critical
    • Resolution: Fixed
    • Affects Version/s: 3.1.1, 4.0
    • Fix Version/s: 3.1.1_b11, 3.1.1, 4.0
    • Component/s: embedded
    • Labels:
      None
    • Environment:

      ANY

      Description

      If an EAR containing EJB and AppClient is deployed with '--retrieve' option in Embedded GlassFish, the client stub JAR file is not retrieved. The deployment causes

      java.lang.NullPointerException
              at org.glassfish.deployment.admin.DeployCommand.retrieveArtifacts(DeployCommand.java:718)
              at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:434)
      
      

      Reproducible with a simple test:

      import java.io.*;
      import org.glassfish.embeddable.*;
      
      public class Test {
      
        public static void main(String... args) throws Exception {
      
          BootstrapProperties bp = new BootstrapProperties();
          bp.setInstallRoot(System.getenv("S1AS_HOME"));
          GlassFishRuntime gfr = GlassFishRuntime.bootstrap(bp);
         
          GlassFishProperties gp = new GlassFishProperties();
          gp.setInstanceRoot(System.getenv("S1AS_HOME") + "/domains/domain1");
          GlassFish gf = gfr.newGlassFish(gp);
          gf.start();
      
          Deployer deployer = gf.getDeployer();
          String appName = deployer.deploy(new File("simple-ejb-cdiApp.ear"), "--retrieve=/tmp");
          System.out.println("Deployed [ " + appName + " ]");
      
          gf.dispose();
          gfr.shutdown();
      
        }
      }
      
      

      Run with $S1AS_HOME/lib/embedded/glassfish-embedded-static-shell.jar.

      simple-ejb-cdiApp.ear is attached.

        Activity

        Hide
        Bhavanishankar added a comment -

        Why fix this issue in 3.1.1?
        important use case to be able to run appclients in embedded glassfish.

        Which is the targeted build of 3.1.1 for this fix?
        b11

        Do regression tests exist for this issue?
        yes.

        Which tests should QA (re)run to verify the fix did not destabilize GlassFish?
        none. all tests are run in developer's hudson.

        Show
        Bhavanishankar added a comment - Why fix this issue in 3.1.1? important use case to be able to run appclients in embedded glassfish. Which is the targeted build of 3.1.1 for this fix? b11 Do regression tests exist for this issue? yes. Which tests should QA (re)run to verify the fix did not destabilize GlassFish? none. all tests are run in developer's hudson.
        Hide
        Tim Quinn added a comment -

        A note to Bhavani...

        The problem seems to be that the invocation's outbound payload is never created. CommandRunnerImpl creates the AdminCommandContext and uses the invocation's outbound and inbound payloads to assign those fields in the context. That outbound payload is used for delivering generated artifacts back to the admin client.

        Show
        Tim Quinn added a comment - A note to Bhavani... The problem seems to be that the invocation's outbound payload is never created. CommandRunnerImpl creates the AdminCommandContext and uses the invocation's outbound and inbound payloads to assign those fields in the context. That outbound payload is used for delivering generated artifacts back to the admin client.
        Hide
        Bhavanishankar added a comment -

        Thanks Tim. Yes, you are spot on.

        I kind of have the tentative fix as below in the embedded' deployerimpl to retrieve the payload:

        
                Payload.Outbound outboundPayload = null;
                String retrieve = commandParams.getOne("retrieve");
                if(retrive != null && new File(retrieve).exists()) {
                    outboundPayload = PayloadImpl.Outbound.newInstance();
                }
        
                inv.outbound(outboundPayload);
                inv.parameters(commandParams).execute();
        
                if (outboundPayload != null) {
                    try {
                        File payLoadZIp = File.createTempFile("gfembed", ".zip");
                        payLoadZIp.deleteOnExit();
                        FileOutputStream fout = new FileOutputStream(payLoadZIp);
                        outboundPayload.writeTo(fout);
                        fout.flush();
                        fout.close();
                        new com.sun.enterprise.util.zip.ZipFile(payLoadZIp, new File(retrive)).explode();
                    } catch (Exception ex) {
                        logger.warning(ex.getMessage());
                    }
                }
        
        
        
        Show
        Bhavanishankar added a comment - Thanks Tim. Yes, you are spot on. I kind of have the tentative fix as below in the embedded' deployerimpl to retrieve the payload: Payload.Outbound outboundPayload = null ; String retrieve = commandParams.getOne( "retrieve" ); if (retrive != null && new File(retrieve).exists()) { outboundPayload = PayloadImpl.Outbound.newInstance(); } inv.outbound(outboundPayload); inv.parameters(commandParams).execute(); if (outboundPayload != null ) { try { File payLoadZIp = File.createTempFile( "gfembed" , ".zip" ); payLoadZIp.deleteOnExit(); FileOutputStream fout = new FileOutputStream(payLoadZIp); outboundPayload.writeTo(fout); fout.flush(); fout.close(); new com.sun.enterprise.util.zip.ZipFile(payLoadZIp, new File(retrive)).explode(); } catch (Exception ex) { logger.warning(ex.getMessage()); } }
        Show
        Bhavanishankar added a comment - Fixed. http://java.net/projects/glassfish/lists/commits/archive/2011-07/message/154 http://java.net/projects/glassfish/lists/commits/archive/2011-07/message/155 http://java.net/projects/glassfish/lists/commits/archive/2011-07/message/156

          People

          • Assignee:
            Bhavanishankar
            Reporter:
            Bhavanishankar
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: