Eclipse错误:目前仅在Tomcat中支持Websockets

时间:2014-06-23 16:40:08

标签: eclipse spring maven tomcat

我试图在webapp中使用tomcat,并希望使用Spring的支持将Tomcat servlet容器作为HTTP运行时嵌入,而不是像在教程中那样部署到外部实例我基于我的应用程序离开:http://spring.io/guides/gs/messaging-stomp-websocket/

但是,我收到了这个堆栈错误:

Caused by: java.lang.IllegalStateException: Websockets are currently only supported in Tomcat (found class org.springframework.boot.context.embedded.jetty.JettyEmbeddedServletContainerFactory). 
at org.springframework.boot.autoconfigure.websocket.WebSocketAutoConfiguration$1.customize(WebSocketAutoConfiguration.java:74)
at org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizerBeanPostProcessor.postProcessBeforeInitialization(EmbeddedServletContainerCustomizerBeanPostProcessor.java:67)
at org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizerBeanPostProcessor.postProcessBeforeInitialization(EmbeddedServletContainerCustomizerBeanPostProcessor.java:54)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:407)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1545)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)
... 16 more

我不确定它现在是怎么发生的,而不是Spring的例子。这是我的POM:

    <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0                      http://maven.apache.org/maven-v4_0_0.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>org.springframework</groupId>
<artifactId>gs-messaging-stomp-websocket</artifactId>
<version>0.1.0</version>
<url>http://www.springframework.org</url>

<properties>
    <maven.test.failure.ignore>true</maven.test.failure.ignore>
    <spring.framework.version>3.0.6.RELEASE</spring.framework.version>
</properties>   

<parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.1.1.RELEASE</version>
    </parent>


<repositories>
    <repository>
        <id>spring-snapshots</id>
        <url>http://repo.spring.io/libs-snapshot</url>
        <snapshots><enabled>true</enabled></snapshots>
    </repository>
</repositories>
<pluginRepositories>
    <pluginRepository>
        <id>spring-snapshots</id>
        <url>http://repo.spring.io/libs-snapshot</url>
        <snapshots><enabled>true</enabled></snapshots>
    </pluginRepository>
</pluginRepositories>
<dependencies>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-websocket</artifactId>
        <version>1.1.1.RELEASE</version>
        <exclusions>
            <exclusion>
                <artifactId>log4j-over-slf4j</artifactId>
                <groupId>org.slf4j</groupId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-messaging</artifactId>
        <version>4.0.5.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.apache.activemq</groupId>
        <artifactId>activemq-all</artifactId>
        <version>5.10.0</version>
    </dependency>
    <dependency>
        <groupId>org.apache.camel</groupId>
        <artifactId>camel-core</artifactId>
        <version>2.13.1</version>
    </dependency>
    <dependency>
        <groupId>org.apache.directory.studio</groupId>
        <artifactId>org.apache.commons.pool</artifactId>
        <version>1.6</version>
    </dependency>
    <dependency>
        <groupId>org.apache.camel</groupId>
        <artifactId>apache-camel</artifactId>
        <version>2.13.1</version>
        <type>pom</type>
    </dependency>
    <dependency>
        <groupId>jdk.tools</groupId>
        <artifactId>jdk.tools</artifactId>
        <scope>system</scope>
        <version>1.6</version>
        <systemPath>C:\Program Files\Java\jdk1.8.0_05\lib\tools.jar</systemPath>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-security</artifactId>
        <version>1.1.1.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.eclipse.jetty</groupId>
        <artifactId>jetty-webapp</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-websocket</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-autoconfigure</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-test</artifactId>
    </dependency>
</dependencies>
    <build>
    <plugins>
        <plugin> 
            <artifactId>maven-compiler-plugin</artifactId> 
            <version>2.3.2</version> 
        </plugin>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
    </plugins>
</build>

我拥有Spring示例使用的所有依赖项。哪些因素可能会影响应用程序使用Tomcat的能力?

提前感谢您的帮助!

编辑:

这是Application.class:

package hello;

import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.SpringApplication;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.stereotype.Component;

@Component
@EnableAutoConfiguration
public class Application {


    public static void main(String[] args) {  
        SpringApplication.run(Application.class, args);
    }
}

这是我的主要内容:

package com.example.integration;

import hello.*;

import org.apache.camel.ProducerTemplate;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;


public class TestCamelSpring {

public static void main(String[] args) {
    ApplicationContext context = new ClassPathXmlApplicationContext("camelspring.xml");
    ProducerTemplate camelTemplate = context.getBean("camelTemplate", ProducerTemplate.class);

    Application.main(args);
    System.out.println("Message Sending started");
    camelTemplate.sendBody("jms:queue:testQSource","Sample Message");
    System.out.println("Message sent");

}

}

0 个答案:

没有答案
相关问题