2013-04-27 3 views
0

JDK: 1.7У ServletContext нет метода .createServlet?

Я работаю над реализацией сторонней библиотеки в своем приложении. Я прохожу мимо [WebappContext][1] до AtmosphereModule() ниже. После этого он заканчивается тем, что достигает метода ниже, и выбрасывает исключение NoSuchMethodError. Я немного в тупике. Я использую

private void installAtmosphere(ServletContext context, Options options) { 
    AtmosphereServlet servlet = null; 
    try { 
     servlet = context.createServlet(AtmosphereServlet.class); //ERROR 
    } catch (ServletException e) { 
     throw new IllegalStateException(e); 
    } 

Мой класс:

import com.production.ApplicationContextProvider; 
import com.production.workflow.process.approval.ApprovalSocketHandler; 
import com.github.flowersinthesand.portal.App; 
import com.github.flowersinthesand.portal.Bean; 
import com.github.flowersinthesand.portal.Options; 
import com.github.flowersinthesand.portal.atmosphere.AtmosphereModule; 
import com.github.flowersinthesand.portal.spring.SpringModule; 
import org.springframework.beans.factory.BeanFactory; 
import org.springframework.beans.factory.annotation.Autowired; 
import org.springframework.beans.factory.config.AutowireCapableBeanFactory; 

import javax.servlet.ServletContextEvent; 
import javax.servlet.ServletContextListener; 
import javax.servlet.annotation.WebListener; 

/** 
* Created with IntelliJ IDEA. 
*/ 
@WebListener 
public class SocketInitializer implements ServletContextListener { 

    public static App app; 

    @Override 
    public void contextInitialized(ServletContextEvent servletContextEvent) { 
     AutowireCapableBeanFactory beanFactory = ApplicationContextProvider.getApplicationContext().getAutowireCapableBeanFactory(); 
     app = new App(new Options().url("/socket/workstation/approval").packageOf(this), new AtmosphereModule(servletContextEvent.getServletContext()), new SpringModule(beanFactory)); 
     app.bean(ApprovalSocketHandler.class).init(); 
    } 

    @Override 
    public void contextDestroyed(ServletContextEvent servletContextEvent) { 

    } 
} 

Возможные relavant записи Maven:

<properties> 
    <grizzly-version>2.2.21</grizzly-version> 
    <jersey-version>1.17.1</jersey-version> 
    <slf4j-version>1.7.5</slf4j-version> 
    <javax-version>6.0</javax-version> 
    <java-version>1.6</java-version> 
    <org.springframework-version>3.1.2.RELEASE</org.springframework-version> 
    <atmosphere.version>1.0.0.beta5</atmosphere.version> 
</properties> 
<dependency> 
    <groupId>javax.servlet</groupId> 
    <artifactId>servlet-api</artifactId> 
    <version>2.5</version> 
</dependency> 
<dependency> 
    <groupId>javax</groupId> 
    <artifactId>javaee-web-api</artifactId> 
    <version>6.0</version> 
    <scope>provided</scope> 
</dependency> 
<dependency> 
    <groupId>javax</groupId> 
    <artifactId>javaee-api</artifactId> 
    <version>6.0</version> 
    <scope>provided</scope> 
</dependency> 

<!-- Grizzly --> 

<dependency> 
    <groupId>org.glassfish.grizzly</groupId> 
    <artifactId>grizzly-websockets-server</artifactId> 
    <version>${grizzly-version}</version> 
</dependency> 
<dependency> 
    <groupId>org.glassfish.grizzly</groupId> 
    <artifactId>grizzly-http-servlet</artifactId> 
    <version>${grizzly-version}</version> 
</dependency> 
<dependency> 
    <groupId>org.glassfish.grizzly</groupId> 
    <artifactId>grizzly-comet</artifactId> 
    <version>${grizzly-version}</version> 
</dependency> 

ответ

1

Вы пытаетесь установить версию сервлета до 3+?

<dependency> 
    <groupId>javax.servlet</groupId> 
    <artifactId>javax.servlet-api</artifactId> 
    <version>3.0.1</version> 
</dependency> 
Смежные вопросы