RMQObjectFactory cannot be cast to InitialContextFactory

1,393 views
Skip to first unread message

Pēteris Priedītis

unread,
Jan 8, 2016, 8:30:58 AM1/8/16
to rabbitmq-users
Hello,

We have NoInitialContextException. Rabbit JMS can't work with InitialContext? Maybe there is some way how to fix this?

I have attached log file.

Best regards,
Peteris
log_152.txt.log

Gary Russell

unread,
Jan 8, 2016, 10:30:38 AM1/8/16
to rabbitm...@googlegroups.com
The JMS client doesn't come with its own JNDI provider; just an ObjectFactory to plug into your existing JNDI provider.

You don't have to use JNDI; you can just instantiate and configure the RMQConnectionFactory yourself.

If you must use JNDI for some reason; consult the provider documentation for how to plugin in additional ObjectFactory instances.

If you don't have a provider and you must use JNDI, in my experience, it's pretty easy to write a lightweight JNDI provider.

--
You received this message because you are subscribed to the Google Groups "rabbitmq-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-user...@googlegroups.com.
To post to this group, send email to rabbitm...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Pēteris Priedītis

unread,
Jan 11, 2016, 11:19:38 AM1/11/16
to rabbitmq-users
Thanks for help!

Our out of the box functionality perform a jndi lookup. It is possible to create external java app which would be used by Siebel however now I'm trying to avoid unnecessary work.
I also asked one jave expert and he thinks that custom jndi provider won't be simple solution.

is used com.sun.jndi.fscontext.RefFSContextFactory as the intial context. Maybe you know could we also use RefFSContextFactory?

I tried to use RefFSContextFactory however I received error:
[SIEBEL ERROR] Thread[Thread-0,5,main] [6:01:28.403 PM Mon Jan 11: ] Error invoking Receive -- 

SiebelJMSException errorSubtype=LOOKING_UP_CONNECTION_FACTORY (wrapped exception = javax.naming.NameNotFoundException: RefFSContextFactory)
at com.siebel.eai.jms.SiebelJNDIContext.getObject(SiebelJNDIContext.java:183)
at com.siebel.eai.jms.SiebelJNDIContext.getFactory(SiebelJNDIContext.java:164)
at com.siebel.eai.jms.JMSBusinessService.createConnection(JMSBusinessService.java:1366)
at com.siebel.eai.jms.JMSBusinessService.doInvokeMethodWithExceptions(JMSBusinessService.java:429)
at com.siebel.eai.jms.JMSBusinessService.doInvokeMethod(JMSBusinessService.java:283)
at com.siebel.eai.SiebelBusinessService.invokeMethod(SiebelBusinessService.java:9)

[SIEBEL ERROR] Thread[Thread-0,5,main] [6:01:28.404 PM Mon Jan 11: ] Threw SiebelBusinessServiceException with 
ErrorCode = JNDI_ERROR
ErrorMessage = Exception: javax.naming.NameNotFoundException: RefFSContextFactory; Message: RefFSContextFactory
StackTrace = javax.naming.NameNotFoundException: RefFSContextFactory
at com.sun.jndi.fscontext.RefFSContext.getObjectFromBindings(RefFSContext.java:400)
at com.sun.jndi.fscontext.RefFSContext.lookupObject(RefFSContext.java:327)
at com.sun.jndi.fscontext.RefFSContext.lookup(RefFSContext.java:146)
at com.sun.jndi.fscontext.FSContext.lookup(FSContext.java:127)
at javax.naming.InitialContext.lookup(Unknown Source)
at com.siebel.eai.jms.SiebelJNDIContext.getObject(SiebelJNDIContext.java:226)
at com.siebel.eai.jms.SiebelJNDIContext.getObject(SiebelJNDIContext.java:181)
at com.siebel.eai.jms.SiebelJNDIContext.getFactory(SiebelJNDIContext.java:164)
at com.siebel.eai.jms.JMSBusinessService.createConnection(JMSBusinessService.java:1366)
at com.siebel.eai.jms.JMSBusinessService.doInvokeMethodWithExceptions(JMSBusinessService.java:429)
at com.siebel.eai.jms.JMSBusinessService.doInvokeMethod(JMSBusinessService.java:283)
at com.siebel.eai.SiebelBusinessService.invokeMethod(SiebelBusinessService.java:9)

[SIEBEL DETAIL] Thread[Thread-0,5,main] [6:01:28.405 PM Mon Jan 11: ] Cumulative time = 60626

Gary Russell

unread,
Jan 11, 2016, 5:17:29 PM1/11/16
to rabbitm...@googlegroups.com
I am not familiar with Siebel, but this worked fine for me with RefFSContextFactory:

System.setProperty(Context.INITIAL_CONTEXT_FACTORY,
    "com.sun.jndi.fscontext.RefFSContextFactory");
System.setProperty(Context.PROVIDER_URL, "file:src/main/resources/");

InitialContext ic = new InitialContext();

RMQConnectionFactory connectionFactory = (RMQConnectionFactory) ic.lookup("ConnectionFactory");

System.out.println(connectionFactory);

result:

RMQConnectionFactory{user='guest', password=xxxxxxxx, host='10.0.0.3', port=5672, virtualHost='/foo', queueBrowserReadMax=0}

with .bindings:

#This file is used by the JNDI FSContext.
#Mon Jan 11 16:43:59 EST 2016
ConnectionFactory/ClassName=javax.jms.ConnectionFactory
ConnectionFactory/FactoryName=com.rabbitmq.jms.admin.RMQObjectFactory

ConnectionFactory/RefAddr/0/Content=amqp\://guest\:gu...@10.0.0.3\:5672/%2Ffoo
ConnectionFactory/RefAddr/0/Type=uri
ConnectionFactory/RefAddr/0/Encoding=String


Reply all
Reply to author
Forward
0 new messages