Issue Details (XML | Word | Printable)

Key: CACTUS-85
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Vincent Massol
Reporter: James Carpenter
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Cactus

Bad JBoss shutdown when using non-standard JBoss ports

Created: 08/Jan/04 06:59 AM   Updated: 17/Apr/04 03:43 PM
Return to search
Component/s: Ant Integration
Affects Version/s: 1.5
Fix Version/s: 1.6

Time Tracking:
Not Specified

Environment:
Operating System: All
Platform: All

Bugzilla Id: 25968


 Description  « Hide
At the following URL there is a description of what ports must be changed to
run multiple instances of JBoss on the same machine.
http://www.yorku.ca/dkha/jboss/docs/MultipleInstances.htm
Included in the ports that must be changed is port 1099 which is used by JNDI.

The org.apache.cactus.integration.ant.container.jboss.JBoss3xContainer class
provides an option to set the port that cactus will use to make http requests
to the server instance that is started. As reflected in the documentation it
is my job to make sure JBoss is correctly set up on whatever non-standard ports
I have choosen. (I am making use of Ant's token replacement to achieve this on
a per machine/per user basis.)

The problem is that when the JNDI port is something other than 1099 the
JBoss3xContainer has problems shutting down the server instance it started.

I looked at the most current version of JBoss3xContainer in CVS and didn't see
any fix for the problem.

I noticed from inspection of the JBoss3xContainer code that it is simply
running java on the org.jboss.Shutdown class with the appropriate options to
affect the shutdown. As it turns out the org.jboss.Shutdown class supports a --
server=blah option that can be used to affect what JNDI port is used. So if I
copy and rename the JBoss3xContainer code to create a custom
org.apache.cactus.integration.ant.container.Container class I can cause my
adaptation to pass a --server=localhost:X argument when org.jboss.Shutdown is
run. As you would expect I created a getter and setter that allowed me to
specify the JNDI port that will be used for X.

To make my custom Container class work I created a copy of the
org/apache/cactus/integration/ant/container/default.properties, listed my
custom class within this file, and made sure my version of the
default.propertiesfile was before the cactus-ant-1.5.jar in the classpath
passed to the taskdef ant task that imports the cactus ant tasks.

This solved the problem on both Windows 2000 and a Sun Sparc machine. A
similar approach should be rolled into the JBoss3xContainer. My relevant code
snipts are:

/**
     * The server JNDI Port (used during shutdown)
     */
    private String JNDIPort;

 /**
     * Specify the JNDI Port.
     *
     * @param theJNDIPort The JNDI Port
     */
    public final void setJNDIPort(String theJNDIPort)
    {
        this.JNDIPort = theJNDIPort;
    }

   /**
     * Returns the server JNDI Port.
     *
     * @return The JNDI Port
     */
    public final String getJNDIPort()
    {
        return this.JNDIPort;
    }

    /**
     * @see org.apache.cactus.integration.ant.container.Container#shutDown
     */
    public final void shutDown()
    {
        File binDir = new File(this.dir, "bin");
            
        Java java = createJavaForShutDown();
        java.setFork(true);

        Path classPath = java.createClasspath();
        classPath.createPathElement().setLocation(
            new File(binDir, "shutdown.jar"));

        java.setClassname("org.jboss.Shutdown");

        //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
        //The next few lines specifying a --server option
        //is the primary difference between the
        //CustomJBoss3xContainer and the one that ships
        //with Cactus.
        //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
        if(this.getJNDIPort() != null){
            java.createArg().setValue("--server=localhost:" + this.getJNDIPort
());
        }

        if (this.version.startsWith("3.2"))
        {
            java.createArg().setValue("--shutdown");
        }
        else
        {
            java.createArg().setValue("localhost");
            java.createArg().setValue(String.valueOf(getPort()));
        }

        java.execute();
    }

 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Vincent Massol added a comment - 26/Jan/04 01:33 AM
Fixed in CVS HEAD. Thanks for the detailed information. I'm currently
performing a nightly build of Cactus. It should be available in the nightly
build area in a few hours from now (say 2 hours).

Do you think you could try it (the attribute to use in the <jboss3x> element
is "jndiport")?

Thanks
-Vincent