qpid-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Xavier Millieret <xavier.millieret.i...@gmail.com>
Subject Re: Qpid in OSGI
Date Tue, 14 May 2013 07:27:30 GMT
Hi,

Thanks a lot, I resolve my issue, with the following code:


PropertiesFileInitialContextFactory contextFactory = new
PropertiesFileInitialContextFactory();
Hashtable<String, String> env = new Hashtable<String, String>();
env.put(Context.PROVIDER_URL, "conf/qpidConnection.properties");
env.put(Context.INITIAL_CONTEXT_FACTORY,
"org.apache.qpid.jndi.PropertiesFileInitialContextFactory");
Context context = contextFactory.getInitialContext(env);
ConnectionFactory connectionFactory = (ConnectionFactory)
context.lookup("qpidConnectionfactory");


And now in the manifest, we do a link to this bundle.
Can I suggest you from the Qpid page (in the user guide or the wiki), with
information about the bundle to use for a client on a Qpid OSGI platform.

On my test, I use these bundles:

org.apache.servicemix.bundles.commons-collections-3.2.1_1.jar
org.apache.servicemix.bundles.mina-1.1.7_6.jar
org.apache.servicemix.bundles.qpid-0.12_2.jar
org.apache.servicemix.bundles.xstream-1.3_4.jar


Best regards


2013/5/12 Aleš Trček <Ales.Trcek@halcom.si>

> Hi,
>
> Try it like this:
> ClassLoader origCL = Thread.currentThread().getContextClassLoader();
> try
> { // OSGi classloader mess hack
>
> Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
>     ctxJNDI = new InitialContext(props);
> } finally
> {
>     Thread.currentThread().setContextClassLoader(origCL);
> }
>
> Regards,
> Ales
>
> -----Original Message-----
> From: Xavier Millieret [mailto:xavier.millieret.info@gmail.com]
> Sent: Friday, May 10, 2013 1:29 PM
> To: users@qpid.apache.org
> Subject: Qpid in OSGI
>
> Hi,
>
> I am starting with Qpid, in OSGI.
> when I try to have a connection through jndi like:
>
> Hashtable<String, String> env = new Hashtable<String, String>();
> env.put(Context.PROVIDER_URL, "qpidConnection.properties");
> env.put(Context.INITIAL_CONTEXT_FACTORY,"org.apache.qpid.jndi.PropertiesFileInitialContextFactory");
>
> Context context = new InitialContext(env); ConnectionFactory
> connectionFactory = (ConnectionFactory) context.lookup("localhost");
>
> I have the following error:
>
>  javax.naming.NoInitialContextException: Cannot instantiate class:
> org.apache.qpid.jndi.PropertiesFileInitialContextFactory [Root exception is
> java.lang.ClassNotFoundException:
> org.apache.qpid.jndi.PropertiesFileInitialContextFactory]
>
> I try to use following bundles:
> org.apache.servicemix.bundles.qpid-1.0-incubating-M2.1_1.jar
>
> depends on:
> org.apache.servicemix.bundles.commons-collections-3.2.1_1.jar
> org.apache.servicemix.bundles.mina-1.1.7_3.jar
>
> someone could help me please.
>
> Thank you
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
> For additional commands, e-mail: users-help@qpid.apache.org
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message