ClassNotFoundException:OrderlyShutdownCapable

时间:2017-12-12 14:19:35

标签: java spring spring-boot tcp spring-integration

我已经创建了一个SpringBoot应用程序。使用Spring Tool Suite版本创建Tcp连接以接受连接:3.9.1.RELEASE并使用Spring Integration,因为它提供了通过互联网协议接收和发送消息的通道适配器 这是主要的课程:

@SpringBootApplication
public class TelefonicaHandlerApplication {

    public static void main(String[] args) throws UnknownHostException, IOException, InterruptedException {

        ConfigurableApplicationContext context = SpringApplication.run(TelefonicaHandlerApplication.class, args);
        Socket socket = SocketFactory.getDefault().createSocket("localhost", 9999);
        socket.getOutputStream().write("foo\r\n".getBytes());
        socket.close();
        Thread.sleep(1000);
        context.close();
    }

    @Bean
    public TcpNetServerConnectionFactory cf() {
        return new TcpNetServerConnectionFactory(9999);
    }

    @Bean
    public TcpReceivingChannelAdapter inbound(AbstractServerConnectionFactory cf) {
        TcpReceivingChannelAdapter adapter = new TcpReceivingChannelAdapter();
        adapter.setConnectionFactory(cf);
        adapter.setOutputChannel(tcpIn());
        return adapter;
    }

    @Bean
    public MessageChannel tcpIn() {
        return new DirectChannel();
    }

    @Transformer(inputChannel = "tcpIn", outputChannel = "serviceChannel")
    @Bean
    public ObjectToStringTransformer transformer() {
        return new ObjectToStringTransformer();
    }

    @ServiceActivator(inputChannel = "serviceChannel")
    public void service(String in) {
        System.out.println(in);
    }
}

这些是pom.xml文件的依赖项

<dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-jdbc</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>

         <dependency>
            <groupId>org.springframework.integration</groupId>
             <artifactId>spring-integration-core</artifactId>
         </dependency>

         <dependency>
                <groupId>org.springframework.integration</groupId>
                <artifactId>spring-integration-ip</artifactId>
            </dependency>

            <dependency>
            <groupId>org.springframework.integration</groupId>
                <artifactId>spring-integration-ws</artifactId>
            </dependency>

            <dependency>
                <groupId>org.springframework.integration</groupId>
                <artifactId>spring-integration-xml</artifactId>
            </dependency>

    </dependencies>

但是当我启动应用程序时。我收到了这个错误:

Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.NoClassDefFoundError: org/springframework/integration/context/OrderlyShutdownCapable
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
    at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    at java.lang.Class.getDeclaredMethods0(Native Method)
    at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
    at java.lang.Class.privateGetMethodRecursive(Class.java:3048)
    at java.lang.Class.getMethod0(Class.java:3018)
    at java.lang.Class.getMethod(Class.java:1784)
    at sun.launcher.LauncherHelper.validateMainClass(LauncherHelper.java:544)
    at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:526)
Caused by: java.lang.ClassNotFoundException: org.springframework.integration.context.OrderlyShutdownCapable
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 19 more

1 个答案:

答案 0 :(得分:0)

org.springframework.integration.context.OrderlyShutdownCapable显示在spring-integration-core以及版本2.2。因为你使用Spring Boot我很确定它无论如何都为你提供了正确的spring-integration-core依赖。

这可能是STS出了问题 - 重新安装它。 或者确实spring-integration-core工件被破坏了 - 您需要清理本地Maven并重新下载所有依赖项。