[jboss-user] [JNDI/Naming/Network] - Getting a javax.naming.Reference instance instead of actual
kjc5664
do-not-reply at jboss.com
Sun Jul 23 12:43:34 EDT 2006
JBoss Version: 4-0.3SP1
OS: Mandrake Linux 2006
JDK: 1.5
On the server I have deployed an MBean which binds an object into the JNDI name space
as follows:
| StdSchedulerFactory schedulerFactory = new StdSchedulerFactory();
| Scheduler scheduler = schedulerFactory.getScheduler();
|
| InitialContext ctx = new InitialContext();
| ctx.rebind(SchedulerConstants.DEFAULT_SCHEDULER_NAME,scheduler);
|
On the client side. I attempt to retreive the object from JNDI name space with the
the following code:
| Properties properties = new Properties();
| properties.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
| properties.put(Context.PROVIDER_URL, "localhost:1099");
| properties.put(Context.URL_PKG_PREFIXES,"org.jboss.naming");
|
| InitialContext iniCtx = new InitialContext(properties);
|
| Scheduler schedObj =
| (Scheduler) iniCtx.lookup(SchedulerConstants.DEFAULT_SCHEDULER_NAME);
|
|
|
This gives me ClassCastException: javax.naming.Reference.
I have implemented the javax.naming. Referenceable interface.
With getReference() returning a reference that has been instantiated
with the name of the class, as well as the factory which creates the class.
| public Reference getReference(){
|
| Reference retVal = new Reference(
| "StdScheduler",
| "StdSchedulerFactory",
| null);
|
| log.info("Returning reference");
| return retVal;
| }
|
The Jar file containing the classes StdScheduler and StdScheduler factory are in the ClassPath for both JBoss (in server/all/lib). And the client.
What am I doing wrong.
Thanks.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3960182#3960182
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3960182
More information about the jboss-user
mailing list