Question

JDK: 1.7

I'm working on implementing a 3rd party library into my application. I'm passing a [WebappContext][1] to the AtmosphereModule() below. Once in there, it ends up reaching the below method and throws a NoSuchMethodError exception. I'm a bit stumped. I'm using

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

My class:

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) {

    }
}

Possible relavant maven entries:

<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>
Was it helpful?

Solution

Did you try to set the servlet version to 3+?

<dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>javax.servlet-api</artifactId>
    <version>3.0.1</version>
 </dependency>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top