Java – The type org.springframework.context.ApplicationContextAware cannot be resolved. It is indirectly referenced from required .class files

javaspringspring-mvc

Compiling the following code yields this error:

The type org.springframework.context.ApplicationContextAware cannot be resolved. It is indirectly referenced from required .class files
(this error is for last line of code)

I think I should add a .jar file in build path, but I don't know what is it?

CamelContext context = new DefaultCamelContext(); 
ConnectionFactory connectionFactory = new ActiveMQConnectionFactory(ActiveMQConnection.DEFAULT_BROKER_URL);
context.addComponent("test-jms", JmsComponent.jmsComponentAutoAcknowledge(connectionFactory));

Best Answer

You need to add Spring Framework's

org.springframework.context-3.x.x.jar

to your project's build path. Depending on which third party library you're using it may have additional Spring dependencies and you would have to add those Spring jars too. You'd most likely need org.springframework.core-3.x.x.jar too.

Consult your direct dependencies' documentation to find out what its dependencies are.