I posted an example (attached here) some time ago of a "hello world"-level
session bean that doesn't redeploy correctly.  Whenever I redeploy session
beans using drag-and-drop into the deploy directory, I never get the new
code's behavior.  I have to restart JBoss for it to pick up the changed
version of the bean.

Since the capability for hot deployment is one of JBoss' major benefits
(among many), I hate having it not work.  If someone will give me a clue
about where the problem might be, I would take a crack at fixing it.  I'm
guessing that it has something to do with the classloader tree.

I tried this running a stock release JBoss 2.1 without Tomcat.  My classpath
was empty (no interference with system classloader happening, I think).  I
am calling the bean from an external JVM client, running on Solaris 8, and
using JDK 1.3. Any help would be appreciated.  We are trying to reduce the
build/test cycle time, and JBoss would have the answer if not for this bug!

Thanks,

Tim Taylor

Here is the code:


::::: Remote Interface

package strata.ejb.foo;

import java.rmi.*;

import javax.ejb.EJBObject;

public interface ISSB extends EJBObject {
    public void hello() throws RemoteException;
}

::::: Home
package strata.ejb.foo;

import java.rmi.*;

import javax.ejb.*;

public interface SSBHome extends EJBHome {
    ISSB create() throws CreateException, RemoteException;
}

::::: Bean
package strata.ejb.foo;

import javax.ejb.*;
import javax.naming.*;

public class SSB implements SessionBean {
    public void ejbActivate() {}
    public void ejbRemove() {}
    public void ejbPassivate() {}
    public void setSessionContext(SessionContext ctx) {}
    public void ejbCreate() throws CreateException {}

    public void hello() {
        // Change this line before redeployment to see that the
        // redeployment does not take effect.  If you change Foo
        // to Bar, redeploy, and then call the bean, it will
        // still print Foo.  If the server is bounced, then
        // Bar will be printed.
        System.out.println("Foo");
    }
}

::::: ejb-jar.xml
<?xml version="1.0"?>

<!DOCTYPE ejb-jar PUBLIC '-//Sun Microsystems, Inc.//DTD Enterprise
JavaBeans 1.1//EN' 'http://java.sun.com/j2ee/dtds/ejb-jar_1_1.dtd'>

<ejb-jar>
    <small-icon>images/green-cube.gif</small-icon>
    <enterprise-beans>
      <session>
        <small-icon>images/orange-cube.gif</small-icon>
        <ejb-name>ssb</ejb-name>
        <home>strata.ejb.foo.SSBHome</home>
        <remote>strata.ejb.foo.ISSB</remote>
        <ejb-class>strata.ejb.foo.SSB</ejb-class>
        <session-type>Stateless</session-type>
        <transaction-type>Container</transaction-type>
      </session>
    </enterprise-beans>
</ejb-jar>

::::: TestClient.java
package strata.ejb.foo;

import java.rmi.RemoteException;
import java.util.Hashtable;

import javax.naming.*;
import javax.ejb.*;

public class TestClient {
    private ISSB ssb;

    //    private String url = "t3://localhost:9734";
    private String url = "localhost:1099";
    private String user = "user1";
    private String password = "password1";
    private String jndiName = "ssb";


    private TestClient() throws Exception {
        setUpService();
    }

    private void setUpService() throws Exception {
        Hashtable env = new Hashtable();
        //        env.put(Context.INITIAL_CONTEXT_FACTORY,
        //      "weblogic.jndi.WLInitialContextFactory");
        env.put(Context.INITIAL_CONTEXT_FACTORY,
                "org.jnp.interfaces.NamingContextFactory");
        env.put(Context.PROVIDER_URL, url);
        env.put(Context.SECURITY_PRINCIPAL, user);
        env.put(Context.SECURITY_CREDENTIALS, password);

        Context ctx = new InitialContext(env);

        SSBHome home = (SSBHome) ctx.lookup(jndiName);

        ssb = (ISSB) home.create();
    }

    public static void main(String[] args) throws Exception {
        //        RunTest.runTest(new TestClient(), args);

        TestClient tc = new TestClient();

        tc.ssb.hello();

        System.exit(0);
    }
}


_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to