grizzly

Grizzly Static Content path below the context webapp

泪湿孤枕 提交于 2019-12-13 03:58:16
问题 Just spent a day trying to get Grizzly Static Content working. The following URL from the Grizzly Blog explained alot: Grizzly STatic Content . I am trying to mimic Tomcat, in that I would the path to the static content to be below the webapp or the context handle. public class SampleAdminApplication extends ResourceConfig { public SampleAdminApplication() { packages("com.companyname.sample.sampleadmin.server.services"); } } public class SampleGrizzlyWebServer { public static void main(String

Grizzly Embedded Server + Jersey service + Servlet filter

╄→尐↘猪︶ㄣ 提交于 2019-12-13 02:30:48
问题 The following code runs my REST service but my servlet filter never gets called. Any ideas? WebappContext webappContext = new WebappContext("grizzly web context", ""); FilterRegistration testFilterReg = webappContext.addFilter("TestFilter", TestFilter.class); testFilterReg.addMappingForUrlPatterns(EnumSet.allOf(DispatcherType.class), "/*"); ResourceConfig rc = new ResourceConfig().register(MyResource.class); HttpServer httpServer = GrizzlyHttpServerFactory.createHttpServer(URI.create("http:/

Basic Authentication at Grizzly Server

烂漫一生 提交于 2019-12-13 00:20:51
问题 I am using Jersey Grizzly and want to implement Basic Authentication to Grizzly. I create my grizzly server as follows: ResourceConfig rc = new PackagesResourceConfig("com.abc.de"); GrizzlyServerFactory.createHttpServer(BASE_URI, rc); at another class I have something like: @GET @Produces("text/plain") @Path("/description") public String getDescription() { String description = "probeDescription"; return description; } I don't know the difference and main concepts of jersey and grizzly. What

Running Jersey on Grizzly on Linux and Windows

天大地大妈咪最大 提交于 2019-12-12 09:37:32
问题 I come from a Windows .NET background, but am trying to expand my expertise, and so have picked up a few Java projects. Currently, I'm trying to create a REST API, and so I decided to go through the walk through for Jersey here: http://jersey.java.net/nonav/documentation/latest/getting-started.html I've gotten the Hello World project to work fine in Windows (using NetBeans and Maven), however when I try to do the same exact thing in Ubuntu (again using NetBeans and Maven) I get the following

Checking a local TCP port is not open in Java

大憨熊 提交于 2019-12-12 01:34:37
问题 Is there a simple way to make sure that a local port is not already open. Some TCP socket servers (eg Grizzly) don't seem to do this check by default. When this check is missing, the server appears to start and respond, but the client code is just connecting to an old server that wasn't shutdown. This can be very bad! Is there a simple line of Java code that could check to be sure that port isn't already used by another process? 回答1: I see two obvious ways to do it: try to connect to that

Publishing Jersey service instance to Grizzly

元气小坏坏 提交于 2019-12-11 17:34:20
问题 I can publish a jersey service to grizzly by doing the following final String baseUri = "http://localhost:51000"; final Map<String, String> initParams = new HashMap<String, String>(); initParams.put("com.sun.jersey.config.property.packages", "my.rest.service"); SelectorThread threadSelector = GrizzlyWebContainerFactory.create(baseUri, initParams); So the specified package will be scanned for any service classes annotated with @Path , and they will be initialized. My question is, is there any

Maximum URI length in Grizzly (GlassFish) and Tomcat

青春壹個敷衍的年華 提交于 2019-12-11 15:46:10
问题 Is there a maximum length (not default value) for URIs in Tomcat and in Grizzly (GlassFish 3)? I want to create a RESTful API which should be able to receive big GET requests. 回答1: In Tomcat it's configureable as maxHttpHeaderSize attribute of the HTTP connector element in server.xml . Its default value is 8192 bytes (8KB). That's about the same amount of unencoded ASCII characters. As Glassfish v3 uses Tomcat under the hood, the configuration setting is the same. Grizzly is just a HTTP

Binding different Grizzly HttpHandlers to different NetworkListeners

蹲街弑〆低调 提交于 2019-12-11 14:24:54
问题 The Grizzly documentation states that all HttpHandlers added to the ServerConfiguration will be shared across all listeners Is there another way of binding different handlers to different ports? Or will I have to multiply instantiate HttpServer ? 回答1: You can bind it to a PortRange i.e multiple ports NetworkListener(String name, String host, PortRange portRange) documented or HttpServer httpServer = new HttpServer(); NetworkListener networkListener1 = new NetworkListener("sample-listener1",

How to fix xml-less autowiring of service

不想你离开。 提交于 2019-12-11 11:13:34
问题 When I call a service directly in my main() I can query the database and things work fine. When a jersey request comes in and maps the JSON to NewJobRequest I can't use my service because the @Autowire failed. My app: public class Main { public static final URI BASE_URI = getBaseURI(); private static URI getBaseURI() { return UriBuilder.fromUri("http://localhost/").port(9998).build(); } protected static HttpServer startServer() throws IOException { ResourceConfig rc = new

Using Jersey with Grizzly

≡放荡痞女 提交于 2019-12-11 05:31:47
问题 I want to create a simple REST service, and for that I am using Jersey and Grizzly. Here is my Service class: @Path("/service") class TestRESTService { @GET @Path("test") @Produces(Array(MediaType.APPLICATION_JSON)) public String test() { return "{ \"TestField\" : \"TestValue\" }"; } } And from what I understand here is how I supposed to start it: ResourceConfig config = new ResourceConfig(); config.registerClasses(TestRESTService.class); URI serverUri = UriBuilder.fromUri("http://localhost/"