JDK:1.7
我正在努力在我的应用程序中实现一个 3rd 方库。我正在传递一个[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) {
}
}
可能的相关 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>