during the home lookup and session creation.
*/
Properties homeProps = new Properties();
homeProps.setProperty("java.naming.factory.initial", "org.jboss.naming.NamingContextFactory");
InitialContext ic = new InitialContext(homeProps);
Handle beanHandle = sessionBean.getHandle();
ByteArrayOutputStream out = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(out);
oos.writeObject(beanHandle);
oos.flush();
byte[] bytes = out.toByteArray();
Properties sysProps = System.getProperties();
Properties newProps = new Properties(sysProps);
newProps.setProperty("java.naming.factory.initial", "badFactory");
newProps.setProperty("java.naming.provider.url", "jnp://badhost:12345");
System.setProperties(newProps);
try
{
getLog().debug("Unserialize bean handle...");
ByteArrayInputStream in = new ByteArrayInputStream(bytes);
ObjectInputStream ois = new ObjectInputStream(in);
beanHandle = (Handle) ois.readObject();
StatelessSession theSession = (StatelessSession) beanHandle.getEJBObject();
theSession.method1("Hello");
getLog().debug("Called method1 on handle session bean");
}
finally
{