Search code examples
javamavenazureamqp

Trying to use Java Message Service (JMS) API with Service Bus and AMQP


I'm trying to execute this example program, but I am getting the following class not found exception:

javax.naming.NoInitialContextException: Cannot instantiate class: org.apache.qpid.amqp_1_0.jms.jndi.PropertiesFileInitialContextFactory [Root exception is java.lang.ClassNotFoundException: org.apache.qpid.amqp_1_0.jms.jndi.PropertiesFileInitialContextFactory]
    at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
    at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
    at javax.naming.InitialContext.init(Unknown Source)
    at javax.naming.InitialContext.<init>(Unknown Source)
    at filternet.SimpleSenderReceiver.<init>(SimpleSenderReceiver.java:30)
    at filternet.SimpleSenderReceiver.main(SimpleSenderReceiver.java:60)
Caused by: java.lang.ClassNotFoundException: org.apache.qpid.amqp_1_0.jms.jndi.PropertiesFileInitialContextFactory*

I have included the following dependency in my pom file:

 <dependency> <groupId>org.apache.qpid</groupId>
 <artifactId>qpid-jms-client</artifactId> </dependency>

But I can't find PropertiesFileInitialContextFactory class file nor any jndi directories in the local maven repository.


Solution

  • Solved by downloading the jars separately and installing them into the Maven repository according to this document:

    How to add local jar files in maven project?

    Then adding the pom definitions from the jar installs into the project's pom.xml file.