grizzly

Grizzly and ServletContainerContext

大城市里の小女人 提交于 2019-12-22 04:38:42
问题 I'm trying to get hold of some injected context (for example Session or HttpServletRequest) in a Servlet I've written, running on Grizzly, but nothing I do seems to work. The whole process seems to stall rather prematurely with the following error: SEVERE: Missing dependency for field: javax.servlet.http.HttpServletRequest com.test.server.LolCat.hsr The server is dead simple, it consists of two files, the static entry point (Main.java): package com.test.server; import java.io.IOException;

Bean Validation 400 errors are returning default error page (html) instead of Response entity (json)

China☆狼群 提交于 2019-12-19 03:37:24
问题 I have a JUnit testsuite: GrizzlyHttpServerFactory + Jersey + Bean Validation (jersey-container-grizzly2-servlet/jersey-bean-validation ver 2.12, grizzly-http-server ver 2.3.16, hibernate-validator ver 5.0.0.Final) The 400 errors generated by a ValidationException are returning Grizzly's default error page (html) instead of the Bean Validation's Response entity (json). I've tried a ClientResponseFilter and its entityStream also contains the html error page. When I run the system under Tomcat,

Jersey + HK2 + Grizzly: Proper way to inject EntityManager?

爱⌒轻易说出口 提交于 2019-12-18 12:34:08
问题 I've managed to set up injection (into resource classes) of my own service classes in Jersey, HK2 and a plain GrizzlyServer. (Basically followed this example.) I'm now curious what the best is to inject JPA EntityManagers into my resource classes? (I'm currently considering one request as one unit of work). One option that I'm currently exploring is to use a Factory<EntityManager> in the following way: class MyEntityManagerFactory implements Factory<EntityManager> { EntityManagerFactory emf;

How to use jersey 2.0 guice on grizzly

你说的曾经没有我的故事 提交于 2019-12-18 05:59:14
问题 I want to use Guice + Jersey 2.0 on Grizzly. According to this How to use guice-servlet with Jersey 2.0? discussion there is no direct Guice integration for Jersey2 at present but it can be achieved using HK2 as a bridge. I also checked the sample project in Github https://github.com/piersy/jersey2-guice-example-with-test . This project is implemented using Jetty. But my problem is to implement it in Grizzly. On Jetty it is used like this @Inject public MyApplication(ServiceLocator

How to get instance of javax.ws.rs.core.UriInfo

强颜欢笑 提交于 2019-12-18 05:44:26
问题 Is there any implementation of javax.ws.rs.core.UriInfo which I can use to create an instance quickly for testing. This interface is long, I just need to test something. I don't want to waste time on whole implementation of this interface. UPDATE: I want to write a unit test for a function similar to this: @GET @Path("/my_path") @Produces(MediaType.TEXT_XML) public String webserviceRequest(@Context UriInfo uriInfo); 回答1: You simply inject it with the @Context annotation, as a field or method

Tyrus websocket: IllegalStateException cannot set WriteListener for non-async request

淺唱寂寞╮ 提交于 2019-12-17 17:15:31
问题 I have a standard websocket endpoint based on Tyrus implementation which times to times triggers the java.lang.IllegalStateException: Cannot set WriteListener for non-async or non-upgrade request . We are running on Payara 4.1. My standard implementation @ServerEndpoint(value = "...", decoders=MessageDecoder.class, encoders=MessageEncoder.class) public class EndpointImpl extends AbstractEndpoint{ // onOpen, onClose, onMessage, onError methods } Where the abstract class is public abstract

Enabling JSON using jersey and grizzly

允我心安 提交于 2019-12-14 03:46:49
问题 I am playing with Jersey hosted with Grizzly and want to be able to consume and produce JSON, however I am getting 500 from the server in get request and media type unsupported in POST my server code is org.glassfish.jersey.server.ResourceConfig rc = new ResourceConfig(); rc.packages("RestServer.controllers"); final Map<String, Object> initParams = new HashMap<String, Object>(); initParams.put("com.sun.jersey.config.property.packages", "rest"); initParams.put("com.sun.jersey.api.json

Grizzly / Glassfish - Cant establish websockets handshake

安稳与你 提交于 2019-12-14 02:09:18
问题 I'm trying to get WebSockets working on top of Grizzly / Glassfish. I've cloned the sample WebSockets chat application, built it and deployed it to Glassfish 3.1.2. However, I cannot get WebSockets to connect. The WebSockets handshake is failing because I'm getting a 405 (Method Not Allowed) response. This makes sense because of what is in the Servlet: public class WebSocketsServlet extends HttpServlet { private final ChatApplication app = new ChatApplication(); @Override public void init

Jersey/Grizzly POST fails for large URI

本小妞迷上赌 提交于 2019-12-13 18:50:24
问题 Relevant: this and that I'm developing a POST webservice (jersey/grizzly, for research purposes only) which should be able to handle large URIs. But if a URI exceeds above 8000 characters I get a 400 Bad Request Exception with no further explanation. I debugged/tracked it down to the grizzly maxHttpHeaderSize attribute. I tried to set this attribute but failed. Here is how I start the server and the request: GrizzlyServerFactory.createHttpServer(BASE_URI, new PackagesResourceConfig("org.test"

Glassfish 4 Grizzly Threads Heavy CPU usage

天大地大妈咪最大 提交于 2019-12-13 13:33:29
问题 I have a Jersey application running on Glassfish 4 (4.1 build 13), JDK 1.7 update 67 and AWS Linux AMI and I'm noticing that after some hours running it, CPU usage goes up and stays up even though clients are stopped. Running "top -H" identifies 2 http-listener-1-kernel threads with high CPU usage (from a total of 16). I then took a thread dump to check these two threads: "http-listener-1-kernel(3) SelectorRunner" daemon prio=10 tid=0x00007fbc68251000 nid=0xaee runnable [0x00007fbcb55ce000]