Я пытаюсь интегрировать Apache Qpid в мое приложение Spring. Поскольку я новичок в обоих, я думал попробовать несколько примеров, прежде чем приступать к реализации моего проекта. Вот файл-интеграция apache qpid с весенней загрузкой
Config.java
import java.util.Properties;
import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.JMSException;
import javax.jms.Queue;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
@Configuration
@PropertySource("classpath:application.properties")
public class Config {
@Value("${connectionfactory.qpidConnectionFactory}")
String qpidConnectionFactory;
@Value("${queue.myqueue}")
String queueName;
@Bean
public Connection configProperties() throws NamingException, JMSException
{
Properties properties=new Properties();
Context context= new InitialContext(properties);
ConnectionFactory connectionFactory= (ConnectionFactory) context.createSubcontext(qpidConnectionFactory);
Connection connection= connectionFactory.createConnection();
return connection;
}
@Bean
public Queue configQueue() throws NamingException
{
Properties properties=new Properties();
Context context= new InitialContext(properties);
Queue queue= (Queue) context.lookup(queueName);
return queue;
}
}
application.properties
java.naming.factory.initial = org.apache.qpid.jndi.PropertiesFileInitialContextFactory
connectionfactory.qpidConnectionFactory = amqp://guest:[email protected]/?brokerlist='tcp://localhost:5672'
queue.myqueue = queue1
ApacheQpidApplication.java
import javax.jms.Connection;
import javax.jms.MessageConsumer;
import javax.jms.MessageProducer;
import javax.jms.Queue;
import javax.jms.Session;
import javax.jms.TextMessage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
@EnableAutoConfiguration
public class ApacheQpidApplication {
public final Connection connection;
public final Queue queue;
@Autowired
public ApacheQpidApplication(Connection connection, Queue queue)
{
this.connection=connection;
this.queue=queue;
}
public static void main(String[] args) {
SpringApplication.run(ApacheQpidApplication.class, args);
}
public void run(String... args) throws Exception{
connection.start();
Session session = connection.createSession(true, Session.SESSION_TRANSACTED);
MessageConsumer messageConsumer = session.createConsumer(queue);
MessageProducer messageProducer = session.createProducer(queue);
TextMessage message = session.createTextMessage("Hello world!");
messageProducer.send(message);
session.commit();
message = (TextMessage)messageConsumer.receive();
session.commit();
System.out.println(message.getText());
connection.close();
}
}
pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>ApacheQpid</name>
<description>Demo project for Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.3.2.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
Теперь, когда я пытаюсь запустить приложение, я получаю эту error->
2016-02-15 01:20:40.770 INFO 96065 --- [ main] com.example.ApacheQpidApplication : Starting ApacheQpidApplication on Rohans-MacBook-Pro.local with PID 96065 (/Users/rsingh/Documents/workspace-sts-3.7.2.RELEASE/ApacheQpid/target/classes started by rsingh in /Users/rsingh/Documents/workspace-sts-3.7.2.RELEASE/ApacheQpid)
2016-02-15 01:20:40.773 INFO 96065 --- [ main] com.example.ApacheQpidApplication : No active profile set, falling back to default profiles: default
2016-02-15 01:20:40.819 INFO 96065 --- [ main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.spring[email protected]3f200884: startup date [Mon Feb 15 01:20:40 IST 2016]; root of context hierarchy
2016-02-15 01:20:41.309 WARN 96065 --- [ main] s.c.a.AnnotationConfigApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'apacheQpidApplication': Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.example.ApacheQpidApplication$$EnhancerBySpringCGLIB$$a833764f]: No default constructor found; nested exception is java.lang.NoSuchMethodException: com.example.ApacheQpidApplication$$EnhancerBySpringCGLIB$$a833764f.<init>()
2016-02-15 01:20:41.315 ERROR 96065 --- [ main] o.s.boot.SpringApplication : Application startup failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'apacheQpidApplication': Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.example.ApacheQpidApplication$$EnhancerBySpringCGLIB$$a833764f]: No default constructor found; nested exception is java.lang.NoSuchMethodException: com.example.ApacheQpidApplication$$EnhancerBySpringCGLIB$$a833764f.<init>()
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1105) ~[spring-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1050) ~[spring-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:510) ~[spring-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) ~[spring-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:772) ~[spring-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:839) ~[spring-context-4.2.4.RELEASE.jar:4.2.4.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:538) ~[spring-context-4.2.4.RELEASE.jar:4.2.4.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:766) [spring-boot-1.3.2.RELEASE.jar:1.3.2.RELEASE]
at org.springframework.boot.SpringApplication.createAndRefreshContext(SpringApplication.java:361) [spring-boot-1.3.2.RELEASE.jar:1.3.2.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:307) [spring-boot-1.3.2.RELEASE.jar:1.3.2.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1191) [spring-boot-1.3.2.RELEASE.jar:1.3.2.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1180) [spring-boot-1.3.2.RELEASE.jar:1.3.2.RELEASE]
at com.example.ApacheQpidApplication.main(ApacheQpidApplication.java:30) [classes/:na]
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.example.ApacheQpidApplication$$EnhancerBySpringCGLIB$$a833764f]: No default constructor found; nested exception is java.lang.NoSuchMethodException: com.example.ApacheQpidApplication$$EnhancerBySpringCGLIB$$a833764f.<init>()
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:85) ~[spring-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1098) ~[spring-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE]
... 16 common frames omitted
Caused by: java.lang.NoSuchMethodException: com.example.ApacheQpidApplication$$EnhancerBySpringCGLIB$$a833764f.<init>()
at java.lang.Class.getConstructor0(Class.java:3082) ~[na:1.8.0_65]
at java.lang.Class.getDeclaredConstructor(Class.java:2178) ~[na:1.8.0_65]
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:80) ~[spring-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE]
... 17 common frames omitted
2016-02-15 01:20:41.318 INFO 96065 --- [ main] .b.l.ClasspathLoggingApplicationListener : Application failed to start with classpath: [file:/Users/rsingh/Documents/workspace-sts-3.7.2.RELEASE/ApacheQpid/target/classes/, file:/Users/rsingh/Downloads/javax.jms-3.1.2.2.jar, file:/Users/rsingh/Downloads/Qpid/qpid-broker/6.0.0/lib/bcel-5.2.jar, file:/Users/rsingh/Downloads/Qpid/qpid-broker/6.0.0/lib/bonecp-0.7.1.RELEASE.jar, file:/Users/rsingh/Downloads/Qpid/qpid-broker/6.0.0/lib/commons-cli-1.2.jar, file:/Users/rsingh/Downloads/Qpid/qpid-broker/6.0.0/lib/derby-10.11.1.1.jar, file:/Users/rsingh/Downloads/Qpid/qpid-broker/6.0.0/lib/dojo-1.10.3-distribution.zip, file:/Users/rsingh/Downloads/Qpid/qpid-broker/6.0.0/lib/geronimo-servlet_3.0_spec-1.0.jar, file:/Users/rsingh/Downloads/Qpid/qpid-broker/6.0.0/lib/guava-18.0.jar, file:/Users/rsingh/Downloads/Qpid/qpid-broker/6.0.0/lib/jackson-annotations-2.5.0.jar, file:/Users/rsingh/Downloads/Qpid/qpid-broker/6.0.0/lib/jackson-core-2.5.3.jar, file:/Users/rsingh/Downloads/Qpid/qpid-broker/6.0.0/lib/jackson-databind-2.5.3.jar, file:/Users/rsingh/Downloads/Qpid/qpid-broker/6.0.0/lib/jetty-continuation-8.1.17.v20150415.jar, file:/Users/rsingh/Downloads/Qpid/qpid-broker/6.0.0/lib/jetty-http-8.1.17.v20150415.jar, file:/Users/rsingh/Downloads/Qpid/qpid-broker/6.0.0/lib/jetty-io-8.1.17.v20150415.jar, file:/Users/rsingh/Downloads/Qpid/qpid-broker/6.0.0/lib/jetty-security-8.1.17.v20150415.jar, file:/Users/rsingh/Downloads/Qpid/qpid-broker/6.0.0/lib/jetty-server-8.1.17.v20150415.jar, file:/Users/rsingh/Downloads/Qpid/qpid-broker/6.0.0/lib/jetty-servlet-8.1.17.v20150415.jar, file:/Users/rsingh/Downloads/Qpid/qpid-broker/6.0.0/lib/jetty-util-8.1.17.v20150415.jar, file:/Users/rsingh/Downloads/Qpid/qpid-broker/6.0.0/lib/jetty-websocket-8.1.17.v20150415.jar, file:/Users/rsingh/Downloads/Qpid/qpid-broker/6.0.0/lib/logback-classic-1.1.3.jar, file:/Users/rsingh/Downloads/Qpid/qpid-broker/6.0.0/lib/logback-core-1.1.3.jar, file:/Users/rsingh/Downloads/Qpid/qpid-broker/6.0.0/lib/qpid-bdbstore-6.0.0.jar, file:/Users/rsingh/Downloads/Qpid/qpid-broker/6.0.0/lib/qpid-bdbstore-jmx-6.0.0.jar, file:/Users/rsingh/Downloads/Qpid/qpid-broker/6.0.0/lib/qpid-broker-6.0.0.jar, file:/Users/rsingh/Downloads/Qpid/qpid-broker/6.0.0/lib/qpid-broker-core-6.0.0.jar, file:/Users/rsingh/Downloads/Qpid/qpid-broker/6.0.0/lib/qpid-broker-plugins-access-control-6.0.0.jar, file:/Users/rsingh/Downloads/Qpid/qpid-broker/6.0.0/lib/qpid-broker-plugins-amqp-0-8-protocol-6.0.0.jar, file:/Users/rsingh/Downloads/Qpid/qpid-broker/6.0.0/lib/qpid-broker-plugins-amqp-0-10-protocol-6.0.0.jar, file:/Users/rsingh/Downloads/Qpid/qpid-broker/6.0.0/lib/qpid-broker-plugins-amqp-1-0-protocol-6.0.0.jar, file:/Users/rsingh/Downloads/Qpid/qpid-broker/6.0.0/lib/qpid-broker-plugins-amqp-msg-conv-0-8-to-0-10-6.0.0.jar, file:/Users/rsingh/Downloads/Qpid/qpid-broker/6.0.0/lib/qpid-broker-plugins-amqp-msg-conv-0-8-to-1-0-6.0.0.jar, file:/Users/rsingh/Downloads/Qpid/qpid-broker/6.0.0/lib/qpid-broker-plugins-amqp-msg-conv-0-10-to-1-0-6.0.0.jar, file:/Users/rsingh/Downloads/Qpid/qpid-broker/6.0.0/lib/qpid-broker-plugins-derby-store-6.0.0.jar, file:/Users/rsingh/Downloads/Qpid/qpid-broker/6.0.0/lib/qpid-broker-plugins-jdbc-provider-bone-6.0.0.jar, file:/Users/rsingh/Downloads/Qpid/qpid-broker/6.0.0/lib/qpid-broker-plugins-jdbc-store-6.0.0.jar, file:/Users/rsingh/Downloads/Qpid/qpid-broker/6.0.0/lib/qpid-broker-plugins-management-http-6.0.0.jar, file:/Users/rsingh/Downloads/Qpid/qpid-broker/6.0.0/lib/qpid-broker-plugins-management-jmx-6.0.0.jar, file:/Users/rsingh/Downloads/Qpid/qpid-broker/6.0.0/lib/qpid-broker-plugins-memory-store-6.0.0.jar, file:/Users/rsingh/Downloads/Qpid/qpid-broker/6.0.0/lib/qpid-broker-plugins-websocket-6.0.0.jar, file:/Users/rsingh/Downloads/Qpid/qpid-broker/6.0.0/lib/qpid-common-6.0.0.jar, file:/Users/rsingh/Downloads/Qpid/qpid-broker/6.0.0/lib/qpid-management-common-6.0.0.jar, file:/Users/rsingh/Downloads/Qpid/qpid-broker/6.0.0/lib/slf4j-api-1.7.12.jar, file:/Users/rsingh/.m2/repository/org/springframework/boot/spring-boot-starter/1.3.2.RELEASE/spring-boot-starter-1.3.2.RELEASE.jar, file:/Users/rsingh/.m2/repository/org/springframework/boot/spring-boot/1.3.2.RELEASE/spring-boot-1.3.2.RELEASE.jar, file:/Users/rsingh/.m2/repository/org/springframework/spring-context/4.2.4.RELEASE/spring-context-4.2.4.RELEASE.jar, file:/Users/rsingh/.m2/repository/org/springframework/spring-aop/4.2.4.RELEASE/spring-aop-4.2.4.RELEASE.jar, file:/Users/rsingh/.m2/repository/aopalliance/aopalliance/1.0/aopalliance-1.0.jar, file:/Users/rsingh/.m2/repository/org/springframework/spring-beans/4.2.4.RELEASE/spring-beans-4.2.4.RELEASE.jar, file:/Users/rsingh/.m2/repository/org/springframework/spring-expression/4.2.4.RELEASE/spring-expression-4.2.4.RELEASE.jar, file:/Users/rsingh/.m2/repository/org/springframework/boot/spring-boot-autoconfigure/1.3.2.RELEASE/spring-boot-autoconfigure-1.3.2.RELEASE.jar, file:/Users/rsingh/.m2/repository/org/springframework/boot/spring-boot-starter-logging/1.3.2.RELEASE/spring-boot-starter-logging-1.3.2.RELEASE.jar, file:/Users/rsingh/.m2/repository/ch/qos/logback/logback-classic/1.1.3/logback-classic-1.1.3.jar, file:/Users/rsingh/.m2/repository/ch/qos/logback/logback-core/1.1.3/logback-core-1.1.3.jar, file:/Users/rsingh/.m2/repository/org/slf4j/slf4j-api/1.7.13/slf4j-api-1.7.13.jar, file:/Users/rsingh/.m2/repository/org/slf4j/jcl-over-slf4j/1.7.13/jcl-over-slf4j-1.7.13.jar, file:/Users/rsingh/.m2/repository/org/slf4j/jul-to-slf4j/1.7.13/jul-to-slf4j-1.7.13.jar, file:/Users/rsingh/.m2/repository/org/slf4j/log4j-over-slf4j/1.7.13/log4j-over-slf4j-1.7.13.jar, file:/Users/rsingh/.m2/repository/org/springframework/spring-core/4.2.4.RELEASE/spring-core-4.2.4.RELEASE.jar, file:/Users/rsingh/.m2/repository/org/yaml/snakeyaml/1.16/snakeyaml-1.16.jar]
ли кто-нибудь знает причину этой ошибки?