Maybe looking at an example that works might help. JBossMQ also has to
implement some Referenceable objects. All that code is in the
org.jbossmq.referenceable package.
Sory I can't be more help, as soon as it was implemented I forgot how it all
worked :-)
hope it helps..
Regards,
Hiram
----- Original Message -----
From: "Ole Husgaard" <[EMAIL PROTECTED]>
To: "jBoss Developer" <[EMAIL PROTECTED]>
Sent: Monday, February 26, 2001 11:26 AM
Subject: [jBoss-Dev] Problem looking up a Referenceable in JNDI.
> Hi,
>
> I am currently working on a UserTransaction
> for standalone clients.
> JTA says that such beast must be
> Referenceable and Serializable, so I do that.
>
> Relevant parts of code in package
> org.jboss.tm.usertx below:
>
> UserTransaction class used in server and client:
> public class ClientUserTransaction
> implements UserTransaction,
> TransactionPropagationContextFactory,
> Referenceable,
> java.io.Serializable
> {
> public Reference getReference()
> throws NamingException
> {
> Reference ref = new Reference(this.getClass().getName(),
>
"org.jboss.tm.usertx.ClientUserTransactionService",
> null);
> return ref;
> }
>
> ...
> }
>
> Service class used in server:
> public class ClientUserTransactionService
> extends ServiceMBeanSupport
> implements ClientUserTransactionServiceMBean, ObjectFactory
> {
> public static String JNDI_NAME = "UserTransaction";
>
> protected void startService()
> throws Exception
> {
> new InitialContext().bind(JNDI_NAME, new
ClientUserTransaction(null));
> }
>
> public Object getObjectInstance(Object obj, Name name,
> Context nameCtx, Hashtable environment)
> throws Exception
> {
> Reference ref = (Reference)obj;
> ClientUserTransaction ut = null;
>
> if (ref.getClassName().equals(this.getClass().getName())) {
> // create the UserTransaction object
> ut = new ClientUserTransaction(new RMIUserTransactionImpl());
> }
> return ut;
> }
>
> ...
> }
>
> What happens is:
>
> During startService, an instance is bound.
> This makes JNP call getReference() on it
> and binds this reference.
>
> When the client does ctx.lookup("UserTransaction"),
> the object factory is *not* called. (In fact, it
> is *never* called.)
>
> Instead of delivering a ClientUserTransaction
> instance to the client, JNDI returns a Reference
> with the same data as the Reference returned by
> the ClientUserTransaction.getReference() call.
>
> Changing the JNDI name to "jnp:/UserTransaction"
> does not help.
>
>
> I am pretty new to JNDI, so I may have
> misunderstood something.
> If anyone who knows about this can tell
> me what I am doing wrong...
>
>
> Best Regards,
>
> Ole Husgaard.
>
>