jee 6 jaxrs get file not found - rest

I have a utility project having the source and the application
package com.x.framework.api;
import java.security.Principal;
import javax.annotation.Resource;
import javax.ejb.SessionContext;
import javax.ejb.Stateless;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import com.csx.enterprise.webframework.security.LDAPUser;
import com.csx.enterprise.webframework.util.FrameworkThreadProperties;
import com.csx.enterprise.webframework.util.Log;
import com.csx.enterprise.webframework.util.WebFrameworkConstants;
#Stateless
#Path("/security")
#Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public class SecurityResource {
#Resource
SessionContext ctx;
#GET
#Path("me")
#Produces(MediaType.APPLICATION_JSON)
public Response getMe() {
...
}
package com.x.framework.api;
import javax.ws.rs.ApplicationPath;
import javax.ws.rs.core.Application;
#ApplicationPath("/api")
public class JaxrsApplication extends Application{
}
I have a web project with web.xml
<servlet>
<servlet-name>javax.ws.rs.core.Application</servlet-name>
<init-param>
<param-name>javax.ws.rs.Application</param-name>
<param-value>com.x.framework.api.JaxrsApplication</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>javax.ws.rs.core.Application</servlet-name>
<url-pattern>/api/*</url-pattern>
</servlet-mapping>
<filter-mapping>
<filter-name>CSXSecurityFilter</filter-name>
<url-pattern>/api/*</url-pattern>
</filter-mapping>
But when I hit the URL https://localhost:9443/webframework/api/security/me, I keeps getting Error 404: java.io.FileNotFoundException: SRVE0190E: File not found: /api/security/me. Any suggestions?

The coding is fine. I had to go to the installedApp directory and extracted the ear file and found the files were not updated accordingly by the Eclipse. So it's not a coding issue, but more of a publishing issue.

Related

Junit class failing after ACS Commons version upgrade to 5.3.4

I upgraded ACS Commons version from 5.0.6 to 5.3.4 in my project and now can see most of the test classes failing with below error
org.junit.jupiter.api.extension.ParameterResolutionException: Failed to resolve parameter [io.wcm.testing.mock.aem.junit5.AemContext arg0] in method [void com.test.test.core.filters.LoggingFilterTest.doFilter(io.wcm.testing.mock.aem.junit5.AemContext) throws java.io.IOException,javax.servlet.ServletException]: Could not create io.wcm.testing.mock.aem.junit5.ResourceResolverMockAemContext instance.
at org.junit.jupiter.engine.execution.ExecutableInvoker.resolveParameter(ExecutableInvoker.java:232)
at org.junit.jupiter.engine.execution.ExecutableInvoker.resolveParameters(ExecutableInvoker.java:176)
at org.junit.jupiter.engine.execution.ExecutableInvoker.resolveParameters(ExecutableInvoker.java:137)
at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:118)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeTestMethod$7(TestMethodTestDescriptor.java:184)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeTestMethod(TestMethodTestDescriptor.java:180)
a
Caused by: org.reflections.ReflectionsException: Scanner TypeAnnotationsScanner was not configured
at org.reflections.Store.get(Store.java:39)
at org.reflections.Store.get(Store.java:61)
at org.reflections.Store.get(Store.java:46)
Please find below my test class. I am using JUnit version as below
<dependency>
<groupId>io.wcm</groupId>
<artifactId>io.wcm.testing.aem-mock.junit5</artifactId>
<version>4.0.4</version>
<scope>test</scope>
</dependency>
Attaching the class below:
import java.io.IOException;
import java.util.List;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import org.apache.sling.testing.mock.sling.servlet.MockRequestPathInfo;
import org.apache.sling.testing.mock.sling.servlet.MockSlingHttpServletRequest;
import org.apache.sling.testing.mock.sling.servlet.MockSlingHttpServletResponse;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import io.wcm.testing.mock.aem.junit5.AemContext;
import io.wcm.testing.mock.aem.junit5.AemContextExtension;
import uk.org.lidalia.slf4jext.Level;
import uk.org.lidalia.slf4jtest.LoggingEvent;
import uk.org.lidalia.slf4jtest.TestLogger;
import uk.org.lidalia.slf4jtest.TestLoggerFactory;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.Mockito.mock;
#ExtendWith(AemContextExtension.class)
class LoggingFilterTest {
private LoggingFilter fixture = new LoggingFilter();
private TestLogger logger = TestLoggerFactory.getTestLogger(fixture.getClass());
#BeforeEach
void setup() {
TestLoggerFactory.clear();
}
#Test
void doFilter(AemContext context) throws IOException, ServletException {
MockSlingHttpServletRequest request = context.request();
MockSlingHttpServletResponse response = context.response();
MockRequestPathInfo requestPathInfo = (MockRequestPathInfo) request.getRequestPathInfo();
requestPathInfo.setResourcePath("/content/test");
requestPathInfo.setSelectorString("selectors");
fixture.init(mock(FilterConfig.class));
fixture.doFilter(request, response, mock(FilterChain.class));
fixture.destroy();
List<LoggingEvent> events = logger.getLoggingEvents();
assertEquals(0, events.size());
}
}
Does anyone know why it is failing with the ACS Commons version change?
This is like breaking lot many junit test classes

Issue when using Jersey 2.x with IBM WAS 8.x to scan and register JAX-RS resources

I am trying to integrate Jersey 2.22.1 with IBM WAS 8.5.4.I have a couple of JAX-RS resources under a certain package (com.innovation.postdata.integration.rest.test.jersey.resources).One of the JAX-RS resource is shown below:
import javax.ws.rs.Consumes;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Response;
#Path("/service")
public class FileSubmissionTestRestService
{
#PUT
#Consumes({ "text/csv" })
#Path("/file")
public Response submitBordereaux (#QueryParam("forceResponse") String forceResponse)
{
if (forceResponse != null && !"".equals (forceResponse))
{
switch (forceResponse)
{
case "404":
return Response.status (Response.Status.NOT_FOUND).entity ("Resource Not Found!").build ();
case "401":
return Response.status (Response.Status.UNAUTHORIZED).entity ("Unauthorized user!").build ();
case "403":
return Response.status (Response.Status.FORBIDDEN).entity ("User not allowed!").build ();
case "405":
return Response.status (Response.Status.METHOD_NOT_ALLOWED).entity ("Unsupported HTTP method!").build ();
case "415":
return Response.status (Response.Status.UNSUPPORTED_MEDIA_TYPE)
.entity ("Media type not supported.It should be TEXT/CSV or APPLICATION/JSON!").build ();
case "500":
return Response.status (Response.Status.INTERNAL_SERVER_ERROR).entity ("Error occured on server!").build ();
default:
return Response.status (Response.Status.NO_CONTENT).build ();
}
}
return Response.status (Response.Status.INTERNAL_SERVER_ERROR).entity ("Error occured on server!").build ();
}
}
and I added a entry in web.xml as shown below
<servlet>
<servlet-name>JAX-RS REST Servlet</servlet-name>
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>jersey.config.server.provider.packages</param-name>
<param-value>com.innovation.postdata.integration.rest.test.jersey.resources</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>JAX-RS REST Servlet</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping>
I also added a custom run time property(com.ibm.websphere.jaxrs.server.DisableIBMJAXRSEngine) and set it to true in WAS to disable default WAS JAX-RS implementation.The JAX-RS resources (under com.innovation.postdata.integration.rest.test.jersey.resources) are packaged in a separate jar that is added to the main EAR WEB-INF/lib when packaging the EAR. When I start WAS I get to see only this in the start up logs:
[1/5/16 0:27:24:106 GMT-05:00] 00000070 ServletWrappe I
com.ibm.ws.webcontainer.servlet.ServletWrapper init SRVE0242I:
[InnovationInsurer] [/Jasper] [JAX-RS REST Servlet]: Initialization
successful.
No where it says that it tried to scan the resource packages or anything like this.Just this.The jars I am using are:
hk2-api-2.4.0-b31.jar
hk2-locator-2.4.0-b31.jar
hk2-utils-2.4.0-b31.jar
javax.annotation-api-1.2.jar
javax.inject-2.4.0-b31.jar
javax.ws.rs-api-2.0.1.jar
jersey-client-2.22.1.jar
jersey-common-2.22.1.jar
jersey-container-servlet-core-2.22.1.jar
jersey-guava-2.22.1.jar
jersey-media-jaxb-2.22.1.jar
jersey-server-2.22.1.jar
osgi-resource-locator-1.0.1.jar
javassist-3.12.0.GA.jar
aopalliance-1.0.jar
I am using Postman Rest Client to access the JAX-RS at http://10.2.64.3:9080/Jasper/rest/service/file?forceResponse=403 but I am always getting 200 OK which is wrong.Can anybody please help me out as to what could be the reason for this? Why is not even trying to scan the package and only saying servlet successfully initialized.
As far as I know, there is a bug in Websphere that prevent package scanning to work correctly (it works only if the classes are under WEB-INF/classes, not from WEB-INF/lib).
Some informations here: https://developer.ibm.com/answers/questions/169221/packagesresourceconfig.html
I've workarounded that issue using:
public class MyRestApplication extends ResourceConfig {
public MyRestApplication() {
register(DefaultExceptionMapper.class);
register(ConstraintViolationExceptionExceptionMapper.class);
register(JacksonJsonProvider.class);
// does not work in IBM WAS 8.5.5 full profile: see it here
// https://developer.ibm.com/answers/questions/169221/packagesresourceconfig.html
// and
// http://www-01.ibm.com/support/docview.wss?rs=180&uid=swg1PM99378
// packages(getClass().getPackage().getName(), LookupEndpoint.class.getPackage().getName());
// Works under WAS 8.5
registerClasses(LookupEndpoint.class, XEndpoint.class, YEndpoint.class);
}
}
and
<servlet>
<servlet-name>jersey_v2-servlet</servlet-name>
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>javax.ws.rs.Application</param-name>
<param-value>x.y.z.MyRestApplication</param-value>
</init-param>
<init-param>
<param-name>jersey.config.beanValidation.enableOutputValidationErrorEntity.server</param-name>
<param-value>true</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
That is obviously not optimal (you must maintain yourself the list of endpoints to be used) but at least it works.

SERVICE_UNAVAILABLE Google Web Toolkit

I have a small GWT project ongoing and I keep getting this error everytime i run it in developement mode.
HTTP ERROR: 503
Problem accessing /Segnalazioni_Degrado.html. Reason:
SERVICE_UNAVAILABLE
--------------------------------------------------------------------------------
Powered by Jetty://
These are the service classes I've created: DataLayerService, DataLayerServiceAsync, DataLayerImpl
package com.tesi.client;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.List;
import com.google.gwt.user.client.rpc.RemoteService;
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
#RemoteServiceRelativePath("dataLayer")
public interface DataLayerService extends RemoteService {
List<Segnalazione> getListaSegnalazioniAttivePerMappa();
}
.
package com.tesi.client;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.List;
import com.google.gwt.user.client.rpc.AsyncCallback;
public interface DataLayerServiceAsync {
void getListaSegnalazioniAttivePerMappa(AsyncCallback<List<Segnalazione>> callback);
}
.
package com.tesi.server;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
import com.tesi.client.DataLayerService;
import com.tesi.client.Segnalazione;
public class DataLayerServiceImpl extends RemoteServiceServlet implements
DataLayerService {
#Override
public List<Segnalazione> getListaSegnalazioniAttivePerMappa() {
// TODO Auto-generated method stub
List<Segnalazione> listaSegnalazioniAttive= new ArrayList<Segnalazione>();
try {
Connection con = ConnectionPool.getInstance().getConnection();
Statement stmt = con.createStatement();
ResultSet segnalazioniAttive = stmt
.executeQuery("SELECT * FROM SEGNALAZIONI_ATTIVE");
while(segnalazioniAttive.next()) {
//popolo gli oggetti segnalazione
Segnalazione s = new Segnalazione();
s.setCategoria(segnalazioniAttive.getString("categoria"));
s.setData(segnalazioniAttive.getDate("data"));
s.setDescrizione(segnalazioniAttive.getString("descrizione"));
s.setIndirizzo(segnalazioniAttive.getString("indirizzo"));
s.setNum_civico(segnalazioniAttive.getInt("numero_civico"));
listaSegnalazioniAttive.add(s);
}
} catch (Exception ex) {
}
return listaSegnalazioniAttive;
}
}
.
And this is the way I've modified the web.xml file
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5"
xmlns="http://java.sun.com/xml/ns/javaee">
<!-- Servlets -->
<servlet>
<servlet-name>greetServlet</servlet-name>
<servlet-class>com.tesi.server.GreetingServiceImpl</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>greetServlet</servlet-name>
<url-pattern>/segnalazioni_degrado/greet</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>dataLayerServlet</servlet-name>
<servlet-class>com.tesi.server.DataLayerServiceImpl</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>dataLayerServlet</servlet-name>
<url-pattern>/segnalazioni_degrado/dataLayer</url-pattern>
</servlet-mapping>
<!-- Default page to serve -->
<welcome-file-list>
<welcome-file>Segnalazioni_Degrado.html</welcome-file>
</welcome-file-list>
</web-app>
Have you got any clue how to solve it?
Sorry everyone, it was a stupid mistake.
I simply had to remove the GreetServlet from web.xml as that is just an example servlet.
Thank you anyway.
Try changing this
#RemoteServiceRelativePath("dataLayer")
into this
#RemoteServiceRelativePath("/segnalazioni_degrado/dataLayer")
If this does not work, please post the server error log

Cannot make REST call with url-pattern other than /*

I'm trying to do a simple REST Web Application using Tomcat 7, Apache Wink, and the Jackson JSON Processor, but seem to be hitting a wall. If I look in my web.xml file, I see:
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd" >
<web-app>
<display-name>Example Web Application</display-name>
<servlet>
<servlet-name>ExampleServlet</servlet-name>
<servlet-class>org.apache.wink.server.internal.servlet.RestServlet</servlet-class>
<init-param>
<param-name>javax.ws.rs.Application</param-name>
<param-value>com.dummy.example.server.ExampleApplication</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>ExampleServlet</servlet-name>
<url-pattern>/services/*</url-pattern>
</servlet-mapping>
</web-app>
Now, if I substitute /* for the URL pattern instead, the REST call works, but when I use /services/*, it fails.
In my ExampleApplication I see:
package com.dummy.example.server;
import java.util.HashSet;
import java.util.Set;
import javax.ws.rs.core.Application;
import org.codehaus.jackson.jaxrs.JacksonJaxbJsonProvider;
import org.codehaus.jackson.map.AnnotationIntrospector;
import org.codehaus.jackson.map.ObjectMapper;
import org.codehaus.jackson.map.introspect.JacksonAnnotationIntrospector;
import org.codehaus.jackson.xc.JaxbAnnotationIntrospector;
public class ExampleApplication extends Application {
/**
* Get the list of service classes provided by this JAX-RS application
*/
#Override
public Set<Class<?>> getClasses() {
Set<Class<?>> serviceClasses = new HashSet<Class<?>>();
serviceClasses.add(com.dummy.example.server.services.Employee.class);
return serviceClasses;
}
#SuppressWarnings("deprecation")
#Override
public Set<Object> getSingletons() {
Set<Object> s = new HashSet<Object>();
// Register the Jackson provider for JSON
// Make (de)serializer use a subset of JAXB and (afterwards) Jackson annotations
// See http://wiki.fasterxml.com/JacksonJAXBAnnotations for more information
ObjectMapper mapper = new ObjectMapper();
AnnotationIntrospector primary = new JaxbAnnotationIntrospector();
AnnotationIntrospector secondary = new JacksonAnnotationIntrospector();
AnnotationIntrospector pair = new AnnotationIntrospector.Pair(primary, secondary);
mapper.getDeserializationConfig().setAnnotationIntrospector(pair);
mapper.getSerializationConfig().setAnnotationIntrospector(pair);
// Set up the provider
JacksonJaxbJsonProvider jaxbProvider = new JacksonJaxbJsonProvider();
jaxbProvider.setMapper(mapper);
s.add(jaxbProvider);
return s;
}
}
And in my Employee class, I have:
package com.dummy.example.server.services;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import org.json.simple.JSONObject;
#Path("/services/employee")
#Produces(MediaType.APPLICATION_JSON)
#SuppressWarnings("unchecked")
public class Employee {
#GET
public JSONObject get() {
JSONObject json = new JSONObject();
json.put("Name", "Example");
return json;
}
}
Any ideas? I've been banging my head against this for some time now
The url-pattern parameter for your servlet (in the web.xml) is independent from the path you specify in your Employee class.
<servlet-mapping>
<servlet-name>ExampleServlet</servlet-name>
<url-pattern>/services/*</url-pattern>
</servlet-mapping>
means your servlet listens on the /services/ sub-path.
#Path("/services/employee")
means that your REST application listens on the /services/employee "sub-sub-path".
So your webservice is exposed at localhost:8080/example/services/services/employee (the concatenation of the url-pattern and the #Path annotation).
If you want to expose it at localhost:8080/example/services/employee with the mentioned url-pattern, you need to change the Employee class needs to have:
#Path("employee")
Where would you expect /services/* to go? The web-app states what URL patterns the web application is willing to service. This makes the application server (e.g., JBoss, GlassFish) route /services/foo/bar/whatever to your web application. The Employee class will be invoked in response to a request to /services/employee so you can make that request. Nothing else is registered so /services/* should result in either a 404 or 400 response. Since /services/* is registered to your web application, I would expect a 400.

Getting error on pubsub example using Atmosphere + Jersey

I'm following the tutorial here
http://jfarcand.wordpress.com/2011/06/29/rest-websocket-applications-why-not-using-the-atmosphere-framework/
I already have a Jersey project up and running and working fine using JBoss 7. The one difference i have is that i am using Jersey with Spring. So my JQueryPubSub looks like this
#Service <-- For Spring component Scan
#Path("/pubsub/{topic}")
#Produces("text/html;charset=ISO-8859-1")
public class JQueryPubSub {
#PathParam("topic")
Broadcaster topic;
#GET
public SuspendResponse<String> subscribe() {
return new SuspendResponse.SuspendResponseBuilder<String>()
.broadcaster(topic)
.outputComments(true)
.addListener(new EventsLogger())
.build();
}
#POST
#Broadcast
public Broadcastable publish(#FormParam("message") String message) {
return new Broadcastable(message, "", topic);
}
}
So i wanted to add this example but i'm getting
22:55:27,381 SEVERE [com.sun.jersey.spi.inject.Errors] (MSC service thread 1-3) The following errors and warnings have been detected with resource
and/or provider classes:
SEVERE: Missing dependency for field: org.atmosphere.cpr.Broadcaster com.order.resources.JQueryPubSub.topic
Any ideas how i can fix this issue and why Jersey seems to be aggressively injecting the value into broadcaster??
I had the same problem and was able to fix it by updating jersey jars from 1.4 to 1.6
If you use maven, you can add the following dependencies.
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-server</artifactId>
<version>1.6</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-core</artifactId>
<version>1.6</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-json</artifactId>
<version>1.6</version>
</dependency>
Answering after long time..but people who are trying can still take some advantage out of this
You can try with the following .
I just tried and it worked for me
Step-1
If you are using weblogic 12 c make the following change
function subscribe() {
var request = {
url :document.location.origin+'/<your-context-path>/ws/pubsub/' + getElementByIdValue('topic'),
Step-2
In web.xml add the below configuration
<servlet>
<description>AtmosphereServlet</description>
<servlet-name>AtmosphereServlet</servlet-name>
<servlet-class>org.atmosphere.cpr.AtmosphereServlet</servlet-class>
<init-param>
<param-name>com.sun.jersey.config.property.packages</param-name>
<param-value>*******package name where your handler is**********</param-value>
</init-param>
<init-param>
<param-name>org.atmosphere.cpr.broadcasterCacheClass</param-name>
<param-value>org.atmosphere.cache.UUIDBroadcasterCache</param-value>
</init-param>
<init-param>
<param-name>org.atmosphere.cpr.broadcastFilterClasses</param-name>
<param-value>org.atmosphere.client.TrackMessageSizeFilter
</param-value>
</init-param>
<init-param>
<param-name>WEBSOCKET_PROTOCOL_EXECUTION</param-name>
<param-value>true</param-value>
</init-param>
<load-on-startup>0</load-on-startup>
<async-supported>true</async-supported>
</servlet>
<servlet-mapping>
<servlet-name>AtmosphereServlet</servlet-name>
<url-pattern>/pubsub/*</url-pattern>
</servlet-mapping>
step-3
paste the below code in a java file in the package you defined in the above step(also can be found in the git site of atmosphere)
import java.io.IOException;
import org.atmosphere.client.TrackMessageSizeInterceptor;
import org.atmosphere.config.service.AtmosphereHandlerService;
import org.atmosphere.config.service.Singleton;
import org.atmosphere.cpr.AtmosphereResourceEvent;
import org.atmosphere.handler.AtmosphereHandlerAdapter;
import org.atmosphere.interceptor.AtmosphereResourceLifecycleInterceptor;
import org.atmosphere.interceptor.BroadcastOnPostAtmosphereInterceptor;
import org.atmosphere.interceptor.SuspendTrackerInterceptor;
import org.atmosphere.util.SimpleBroadcaster;
#Singleton
#AtmosphereHandlerService(path = "/{chat}",
interceptors = {
AtmosphereResourceLifecycleInterceptor.class,
TrackMessageSizeInterceptor.class,
BroadcastOnPostAtmosphereInterceptor.class,
SuspendTrackerInterceptor.class},
broadcaster = SimpleBroadcaster.class)
public class AtmosphereHandler extends AtmosphereHandlerAdapter {
#Override
public void onStateChange(AtmosphereResourceEvent event) throws IOException {
if (event.isSuspended()) {
String message = event.getMessage() == null ? null : event.getMessage().toString();
if (message != null && message.indexOf("message") != -1) {
event.getResource().write(message.substring("message=".length()));
} else {
event.getResource().write("=error=");
}
}
}
}
Now deploy the ear it works..
Jar files
atmosphere-annotations-2.1.1.jar
atmosphere-jersey-2.1.1.jar
atmosphere-runtime-2.1.1.jar
atmosphere-weblogic-2.1.1.jar
commons-collections-3.2.1.jar
commons-dbutils-1.5.jar
commons-io-2.4.jar
jersey-core-1.17.1.jar
jersey-json-1.17.1.jar
jersey-server-1.17.1.jar
jersey-servlet-1.17.1.jar
log4j-1.2.15.jar