I get this exception (only when running the packaged, executable war file -running the @SpringBootApplication in the Eclipse IDE works fine-):
org.atmosphere.cpr.AtmosphereMappingException: No AtmosphereHandler found. Make sure you define it inside WEB-INF/atmosphere.xml or annotate using @___Service
But this is not true. I have annotated the relevant class. This is my @ManagedService class:
package de.my.app.atmosphere;
import javax.inject.Inject;
import org.atmosphere.config.service.Disconnect;
import org.atmosphere.config.service.ManagedService;
import org.atmosphere.config.service.Ready;
import org.atmosphere.cpr.AtmosphereResource;
import org.atmosphere.cpr.AtmosphereResourceFactory;
import org.json.JSONException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ManagedService(path = "/updateStuff")
public class PushStuff {
private final Logger log = LoggerFactory.getLogger(PushStuff.class);
@Inject
public static AtmosphereResourceFactory factory;
@Inject
public AtmosphereResource resource;
@Ready
public void onReady() throws JSONException {
log.info("onReady called!");
}
@Disconnect
public void onDisconnect() {
log.info("onDisconnect called!");
}
}
This is my Configuration:
package de.my.app.atmosphere;
import java.util.Collections;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import org.atmosphere.cpr.AtmosphereServlet;
import org.atmosphere.cpr.ContainerInitializer;
import org.springframework.boot.web.servlet.ServletContextInitializer;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.Ordered;
@Configuration
public class PushConfig {
@Bean
public EmbeddedAtmosphereInitializer atmosphereInitializer() {
return new EmbeddedAtmosphereInitializer();
}
@Bean
public ServletRegistrationBean atmosphereServlet() {
ServletRegistrationBean registration = new ServletRegistrationBean(new AtmosphereServlet(), "/updateStuff");
registration.addInitParameter("org.atmosphere.cpr.packages", "de.my.app.atmosphere");
registration.setLoadOnStartup(1);
registration.setOrder(Ordered.HIGHEST_PRECEDENCE);
return registration;
}
private static class EmbeddedAtmosphereInitializer extends ContainerInitializer
implements ServletContextInitializer {
@Override
public void onStartup(ServletContext servletContext) throws ServletException {
onStartup(Collections.<Class<?>>emptySet(), servletContext);
}
}
}
I get this exception (only when running the packaged, executable war file -running the
@SpringBootApplication
in the Eclipse IDE works fine-):But this is not true. I have annotated the relevant class. This is my
@ManagedService
class:This is my Configuration:
This is my pom.xml (some parts truncated):
The log when running from the war file states that:
There are some differences in the logs of the war file and the Java Application startup.
This is the Startup log of the war-file:
This is the Java Application run inside Eclipse (which works as mentioned above):
Why does it work when running from the IDE and why not from the packaged war?
I have a more detailed description of this issue on stackoverflow: https://stackoverflow.com/questions/46767772/org-atmosphere-cpr-atmospheremappingexception-in-spring-boot-executable-war-file Since i do not know wether or not its a bug or an error in my configuration.