users@glassfish.java.net

DeploymentManager.getTargets method blocks Glassfish container

From: <glassfish_at_javadesktop.org>
Date: Thu, 22 Mar 2007 13:15:44 PST

Hi,

I've a problem fetching container targets when glassfish restarts. I've confined the code and the problem is that DeploymentManager.getTargets method of JSR88 blocks the ServletContextListener thread when the domain is started with a previously deployed war file.

The test is very simple:
1) Add to the contextInitialized method the following code:
        public void contextInitialized(ServletContextEvent arg0) {
                DeploymentManager manager = null;
                try {
                        DeploymentFactoryManager dfm = DeploymentFactoryManager.getInstance();
                        DeploymentFactory df = (DeploymentFactory)Class.forName("com.sun.enterprise.deployapi.SunDeploymentFactory").newInstance();
                        dfm.registerDeploymentFactory(df);
                        manager = dfm.getDeploymentManager("deployer:Sun:AppServer::127.0.0.1:4848", "admin", "adminadmin");
                        System.err.println("Getting targets");
                        Target[] targets = manager.getTargets(); // Blocks when glassfish starts
                        for (TargetModuleID m : manager.getRunningModules(ModuleType.WAR, targets))
                                System.err.println("Running Module: " + m);
                } catch (Exception e) {
                        e.printStackTrace();
                        throw new RuntimeException(e.toString());
                } finally {
                        if (manager != null)
                                manager.release();
                }
        }

2) Deploy the war file (everything goes fine)

3) Stop the domain

4) Start the domain
Now the container blocks when reaching the getTargets method.
If the jvm option com.sun.enterprise.server.ss.ASQuickStartup is set to false, instead of blocking it gives the following exception:
java.lang.RuntimeException: java.lang.IllegalStateException: java.io.IOException: Unable to connect to admin-server. Please check if the server is up and running and that the host and port provided are correct.
        at jsr88.ContainerTest.contextInitialized(ContainerTest.java:42)

Check with b25, b33 and b40 and the behaviour is the same across all builds.

Any idea how to solve the problem?
The sample eclipse project can be fetched from http://egroupware.ipleiria.pt/jsr88_bug.zip

Thanks,
Vitor
[Message sent by forum member 'bytec0de' (bytec0de)]

http://forums.java.net/jive/thread.jspa?messageID=209513