grizzly

Grizzly + Static Content + Servlet Filter

╄→尐↘猪︶ㄣ 提交于 2020-01-05 08:45:30
问题 I can get Grizzly to serve static content I can create the servlet filter to filter a named servlet But I can't get the servlet filter to filter the static content. How do I do that? Here is the code I have so far: WebappContext webappContext = new WebappContext("grizzly web context", ""); FilterRegistration authFilterReg = webappContext.addFilter("Authentication Filter", org.package.AuthenticationFilter.class); // If I create a ServletContainer, I can add the filter to it like this: //

jersey 2.2: ContainerResponseFilter and ContainerRequestFilter never get executed

最后都变了- 提交于 2020-01-03 13:02:40
问题 Following the getting started guide on the Jersey website: I executed the following build command: $ mvn archetype:generate -DarchetypeArtifactId=jersey-quickstart-grizzly2 \ -DarchetypeGroupId=org.glassfish.jersey.archetypes -DinteractiveMode=false \ -DgroupId=com.example -DartifactId=simple-service -Dpackage=com.example \ -DarchetypeVersion=2.2 I then followed the tutorial on https://jersey.java.net/documentation/latest/filters-and-interceptors.html#d0e6783 to add a custom

grizzly does not log Exceptions in requests

情到浓时终转凉″ 提交于 2020-01-01 15:08:31
问题 I've set up a simple jersey server like this: ResourceConfig rc = new ResourceConfig().packages("com.example.jersey_test/services"); HttpServer server = GrizzlyHttpServerFactory.createHttpServer(URI.create(API_URI), rc); And I have a bean that simply throws an exception: @Path("persons") public class PersonService { @GET @Produces(MediaType.APPLICATION_JSON) public String getPersons() { java.util.logging.Logger.getGlobal().log(Level.INFO, "test"); throw new RuntimeException("test"); } } The

grizzly http server should keep running

一曲冷凌霜 提交于 2019-12-30 01:16:08
问题 Below is the code to start Grizzly Http Server. If I press any key the server stops. Is there any way to keep it alive. Jetty has join() method, which will not exit the main program. Is there anything similar to that in Grizzly also. public static void main(String args){ ResourceConfig rc = new PackagesResourceConfig("com.test.resources"); HttpServer httpServer = GrizzlyServerFactory.createHttpServer(BASE_URI, rc); logger.info(String.format("Jersey app started with WADL available at " + "

Using JaaS with Jersey on Grizzly

可紊 提交于 2019-12-29 08:13:09
问题 I'm trying to find a simple, flexible way to add JaaS authentication to REST. I found a post that I think leads me in the right direction (See StevenC's answer). It sounds like the servlet container is responsible for security, not the Jersey code itself. I like this idea, but need a little guidance on implementation. Grizzly is my servlet container and I want to configure it to use JaaS for authentication. For now, a simple username/password combination would be fine, and hard-coding the

Wildcards in grizzly HttpHandler's mappings

末鹿安然 提交于 2019-12-25 07:04:52
问题 I'm trying to map MyHttpHandler to custom url using grizzly 2.3 web server like this (that should be RESTfull url, like /entity/42/attribute ): HttpServer httpServer = HttpServer.createSimpleServer(); ServerConfiguration config = httpServer.getServerConfiguration(); config.addHttpHandler(new MyHttpHandler(), "/entity/*/attribute"); It does not work. How can I do it in grizzly? 回答1: For version 2.3.17 of grizzly-http-server, I see that addHttpHandler(HttpHandler httpHandler, String... mappings

Getting swagger-core 1.5 to work with Jersey and Grizzly

十年热恋 提交于 2019-12-24 11:51:46
问题 I have a Jersey2 application that runs on an embedded Grizzly server - a setup identical to this example: https://github.com/jersey/jersey/tree/2.18/examples/https-clientserver-grizzly/src/main/java/org/glassfish/jersey/examples/httpsclientservergrizzly I have integrated it with swagger-jersey2-jaxrs_2.10 and it has been working OK. Now that swagger-core 1.5 came out and it produces Swagger 2.0 definitions, I would like to upgrade to that version. Having followed the Swagger setup

Tyrus client cannot reconnect on server restart when client shared container is enabled

喜夏-厌秋 提交于 2019-12-24 11:27:31
问题 Here is the scenario: Websocket server is up Tyrus client shared container is enabled Tyrus client connects to server (everything is good) Websocket server restarts Tyrus client cannot connect to the server and throws the following exception even after the server is up: javax.websocket.DeploymentException: Connection failed If the client application is restarted it can connect to server again Note: This issue will not happen if Tyrus client shared container is disabled. stacktrace: javax

@Post method with capturing parenthesis in @Path not matched in Jersey

拈花ヽ惹草 提交于 2019-12-24 01:39:25
问题 I am having trouble getting JAX-RS POST methods to match with Jersey. Verbatim paths work fine ("/prefix/ABC/DEF"), but parenthesised captures ("/prefix/{alpha}/{beta}") fail to trigger. Here are the methods in question, as defined in the server interface, using Jersey. public interface CollectorEndpoint { ... @POST @Path("/prefix/{alpha}/{beta}") //doesn't match @Consumes(MediaType.APPLICATION_JSON) Response method1(@PathParam("alpha") String alpha, @PathParam("beta") String beta, String

can not get grizzly logging to work, nothing written to my log4j log file

随声附和 提交于 2019-12-23 15:29:44
问题 I have a simple Java/Spring program using a standard log4j.properties file to control logging, which is working fine. When we added Grizzly via: GrizzlyHttpServerFactory.createHttpServer(uri, resourceConfig) things work (i.e. the server in fact serves...but I get no log output. I have an explicit entry in log4j.properties for "org.glassfish.grizzly". I've gone so far as to debug into Grizzly's ExtendedLogger class and can see that its getting close to logging but then doesn't. 回答1: Turns out