Java FileNotFoundException:无法打开类路径资源,因为它不存在

Java FileNotFoundException:无法打开类路径资源,因为它不存在,java,spring,openfire,spring-context,Java,Spring,Openfire,Spring Context,我正在尝试使用openfire运行Spring,但出现以下错误: FileNotFoundException:无法打开类路径资源[ForwarderApplicationConfiguration.class],因为它不存在 org.springframework.context.annotation.ConfigurationClassParser-无法通过ASM读取类文件以确定@Bean方法顺序 import com.rabbitmq.client.Channel; import com.r

我正在尝试使用openfire运行Spring,但出现以下错误: FileNotFoundException:无法打开类路径资源[ForwarderApplicationConfiguration.class],因为它不存在 org.springframework.context.annotation.ConfigurationClassParser-无法通过ASM读取类文件以确定@Bean方法顺序

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class ForwarderApplicationConfiguration {

private static final Logger LOGGER = LoggerFactory.getLogger(ForwarderApplicationConfiguration.class);
public final static String QUEUE_NAME = "shout_forwarder";


@Bean
public Channel channel() {
    LOGGER.info("Initializing Forwarding Plugin");
    ConnectionFactory factory = new ConnectionFactory();
    factory.setHost("192.168.100.122");
    factory.setPassword("password");
    factory.setUsername("publisher");
    try {
        Connection connection = factory.newConnection();
        Channel channel = connection.createChannel();
        channel.queueDeclare(QUEUE_NAME, false, false, false, null);
        return channel;
    } catch (Exception ex) {
        LOGGER.error("Initializing Forwarding Plugin \n" + ex.getMessage());
        throw new RuntimeException(ex);
    }
}

@Bean
public MessageInterceptor messageInterceptor(Channel channel) {
    return new MessageInterceptor(channel);
}

}
这是主要课程:

import org.jivesoftware.openfire.MessageRouter;
import org.jivesoftware.openfire.XMPPServer;
import org.jivesoftware.openfire.container.Plugin;
import org.jivesoftware.openfire.container.PluginManager;
import org.jivesoftware.openfire.interceptor.InterceptorManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.xmpp.packet.JID;

import java.io.File;

public class MessageForwarderPlugin implements Plugin {
    private static final Logger Log = LoggerFactory.getLogger(MessageForwarderPlugin.class);
    private final InterceptorManager interceptorManager;
    private final JID violationNotificationFrom;
    private final MessageRouter messageRouter;
    private ApplicationContext springContext;
    private MessageInterceptor messageInterceptor;


    public MessageForwarderPlugin() {
        interceptorManager = InterceptorManager.getInstance();
        violationNotificationFrom = new JID(XMPPServer.getInstance()
                .getServerInfo().getXMPPDomain());
        messageRouter = XMPPServer.getInstance().getMessageRouter();
        springContext = new AnnotationConfigApplicationContext(ForwarderApplicationConfiguration.class);
        }

    @Override
    public void initializePlugin(PluginManager manager, File pluginDirectory) {
        Log.info("Initializing Forwarding Plugin");
        messageInterceptor = (MessageInterceptor) springContext.getBean("messageInterceptor");
        interceptorManager.addInterceptor(messageInterceptor);

    }

    @Override
    public void destroyPlugin() {
        Log.info("Destroying Forwarding Plugin");
        interceptorManager.removeInterceptor(messageInterceptor);
    }


}
pom:

4.0.0
org.igniterealtime.openfire.plugins
促进者
${maven.build.timestamp}
com.rabbitmq
amqp客户端
5.7.3
com.cenqua.shaj
沙吉
0.5
org.springframework
spring上下文
${spring.version}
org.igniterealtime.openfire
插件
4.2.0
1.8
1.8
1.8
5.2.7.发布
dd.HH.mm
${maven.build.timestamp}
src/main/java
org.apache.maven.plugins
maven汇编插件
2.6
org.igniterealtime.openfire.plugins
openfire插件程序集描述符
${openfire.version}
组装
包裹
单一的
真的
${plugin.name}
真的
openfire插件程序集
消息转发器插件
创建新插件的起点
<modelVersion>4.0.0</modelVersion>

<groupId>org.igniterealtime.openfire.plugins</groupId>
<artifactId>forwarder</artifactId>
<version>${maven.build.timestamp}</version>
<dependencies>

    <dependency>
        <groupId>com.rabbitmq</groupId>
        <artifactId>amqp-client</artifactId>
        <version>5.7.3</version>
    </dependency>

    <dependency>
        <groupId>com.cenqua.shaj</groupId>
        <artifactId>shaj</artifactId>
        <version>0.5</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context</artifactId>
        <version>${spring.version}</version>
    </dependency>
     </dependencies>
<parent>
    <groupId>org.igniterealtime.openfire</groupId>
    <artifactId>plugins</artifactId>
    <version>4.2.0</version>
    <relativePath/>
</parent>
<properties>
    <java.version>1.8</java.version>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
    <spring.version>5.2.7.RELEASE</spring.version>
    <maven.build.timestamp.format>dd.HH.mm</maven.build.timestamp.format>
    <dev.build.timestamp>${maven.build.timestamp}</dev.build.timestamp>
</properties>

<build>
    <sourceDirectory>src/main/java</sourceDirectory>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-assembly-plugin</artifactId>
            <version>2.6</version>
            <dependencies>
                <dependency>
                    <groupId>org.igniterealtime.openfire.plugins</groupId>
                    <artifactId>openfire-plugin-assembly-descriptor</artifactId>
                    <version>${openfire.version}</version>
                </dependency>
            </dependencies>
            <executions>
                <execution>
                    <id>make-assembly</id>
                    <phase>package</phase>
                    <goals>
                        <goal>single</goal>
                    </goals>
                    <configuration>
                        <appendAssemblyId>true</appendAssemblyId>
                        <finalName>${plugin.name}</finalName>
                        <attach>true</attach>
                        <descriptorRefs>
                            <descriptorRef>openfire-plugin-assembly</descriptorRef>
                        </descriptorRefs>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

<name>Message Forwarder Plugin</name>
<description>A start point to create a new plugin</description>
import org.jivesoftware.openfire.MessageRouter;
import org.jivesoftware.openfire.XMPPServer;
import org.jivesoftware.openfire.container.Plugin;
import org.jivesoftware.openfire.container.PluginManager;
import org.jivesoftware.openfire.interceptor.InterceptorManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.xmpp.packet.JID;

import java.io.File;

public class MessageForwarderPlugin implements Plugin {
    private static final Logger Log = LoggerFactory.getLogger(MessageForwarderPlugin.class);
    private final InterceptorManager interceptorManager;
    private final JID violationNotificationFrom;
    private final MessageRouter messageRouter;
    private AnnotationConfigApplicationContext springContext;//this
    private MessageInterceptor messageInterceptor;


     public MessageForwarderPlugin() {
    interceptorManager = InterceptorManager.getInstance();
    violationNotificationFrom = new JID(XMPPServer.getInstance().getServerInfo().getXMPPDomain());
    messageRouter = XMPPServer.getInstance().getMessageRouter();
    springContext = new AnnotationConfigApplicationContext();//this
    springContext.setClassLoader(ForwarderApplicationConfiguration.class.getClassLoader());//this
    springContext.register(ForwarderApplicationConfiguration.class);//this
    springContext.refresh();//this
}

    @Override
    public void initializePlugin(PluginManager manager, File pluginDirectory) {
        Log.info("Initializing Forwarding Plugin");
        messageInterceptor = (MessageInterceptor) springContext.getBean("messageInterceptor");
        interceptorManager.addInterceptor(messageInterceptor);

    }

    @Override
    public void destroyPlugin() {
        Log.info("Destroying Forwarding Plugin");
        interceptorManager.removeInterceptor(messageInterceptor);
    }


}