Hi,
I have been trying to programmatically register an object in the
registry and I got the following exception:
org.apache.camel.RuntimeCamelException:
javax.naming.NoInitialContextException: Need to specify class name in
environment or system property, or as an applet parameter, or in an
application resource file: java.naming.factory.initial
at org.apache.camel.impl.JndiRegistry.bind(JndiRegistry.java:126)
at org.ow2.petals.camel.se.CamelSU.<init>(CamelSU.java:90)
The line in my code called is:
this.context.getRegistry(JndiRegistry.class).bind(PetalsCamelContext.class.getName(),
this);
The problem is that according to the code of getRegistry, if an initial
context can be created, then camel would fallback to the SimpleFactory
implementation.
Apparently, this code fails to do so because the JNDI registry fails not
when the context is created but when bind is called!
I guess this is not the desired behaviour of getRegistry, is it?
On a side note: am I wrong to try to register something in the registry
like that programmatically? Is there a different way of registering
things in the registry?
My initial objective was to able to inject an object to a camel
component without passing it as a constructor argument.
Thank you
Victor