dropwizard

How to show Dropwizard active requests in logs

偶尔善良 提交于 2020-01-16 13:19:01
问题 This question is related to the one I ask here. I'm trying to log the number of active requests being made to my Dropwizard application every 10 minutes. The idea is to track usage of the app so it can get the proper support. In doing this, I'm trying to expose the dropwizard metrics to the logs. For testing purposes, I've made the following code: @GET @Path("/metrics") public MetricRegistry provideMetrics() { MetricRegistry metrics = new MetricRegistry(); metrics.register("io.dropwizard

Dropwizard: How to fix 414 Request-URI Too Long

雨燕双飞 提交于 2020-01-15 06:44:28
问题 Request (GET) or (POST): http://localhost:8080/images?name=iVBORw0KGgoAAAANSUhEUgAAAAUA%20AAAFC...... Response: Status Code: 414 Request-URI Too Long Connection: close Content-Length: 0 How to increase the request size? 回答1: You have a Request URI that is over 8kb in size! Eeesh! Request-URI limits exist because of various vulnerabilities and bugs found in browsers, proxies, and networking hardware. While it is possible to increase the Request URI limit checks in Jetty, the values chosen for

How can I deserialize a JSON to a Java class which has known mandatory fields, but can have several unknown fields?

主宰稳场 提交于 2020-01-14 11:06:51
问题 I have an input JSON which has fields what I sure inside. But, I need a flexibility to add several extra fields. I don't know the name of the extra fields, but I have to handle it. I was thinking adding a MaP field which contains all of extra fields, but the inputs are not mapped into this field. I want to deserialize the JSON in a Dropwizard endpoint. Is there a way to do with Jackson? Example: JSON payload 1: { "first_name": "John", "last_name": "Doe", "date_of_birth": "01/01/1990",

How can I deserialize a JSON to a Java class which has known mandatory fields, but can have several unknown fields?

雨燕双飞 提交于 2020-01-14 11:06:38
问题 I have an input JSON which has fields what I sure inside. But, I need a flexibility to add several extra fields. I don't know the name of the extra fields, but I have to handle it. I was thinking adding a MaP field which contains all of extra fields, but the inputs are not mapped into this field. I want to deserialize the JSON in a Dropwizard endpoint. Is there a way to do with Jackson? Example: JSON payload 1: { "first_name": "John", "last_name": "Doe", "date_of_birth": "01/01/1990",

How to Optionally Protect a Resource with Custom Dropwizard Filter

旧巷老猫 提交于 2020-01-11 05:34:09
问题 I'm using Dropwizard 0.9.2 and I want to create a resource that requires no authentication for GET and requires basic authentication for POST. I have tried @Path("/protectedPing") @Produces(MediaType.TEXT_PLAIN) public class ProtectedPing { @GET public String everybody() { return "pingpong"; } @PermitAll @POST public String authenticated(){ return "secret pingpong"; } with CachingAuthenticator<BasicCredentials, User> ca = new CachingAuthenticator<>(environment.metrics(), ldapAuthenticator,

Dropwizard Admin: Change loglevel for all

孤者浪人 提交于 2020-01-11 03:33:13
问题 My config is the standard logging: # The default level of all loggers. Can be OFF, ERROR, WARN, INFO, DEBUG, TRACE, or ALL. level: INFO # Logger-specific levels. loggers: # Sets the level for 'com.example.app' to DEBUG. com.example.app: DEBUG # Redirects SQL logs to a separate file org.hibernate.SQL: level: DEBUG I want to change the default log level for all loggers to DEBUG . I've tried the following and nothing works (say admin port is 1234): curl -X POST -d "logger=all&level=DEBUG"

Dropwizard Admin: Change loglevel for all

让人想犯罪 __ 提交于 2020-01-11 03:33:06
问题 My config is the standard logging: # The default level of all loggers. Can be OFF, ERROR, WARN, INFO, DEBUG, TRACE, or ALL. level: INFO # Logger-specific levels. loggers: # Sets the level for 'com.example.app' to DEBUG. com.example.app: DEBUG # Redirects SQL logs to a separate file org.hibernate.SQL: level: DEBUG I want to change the default log level for all loggers to DEBUG . I've tried the following and nothing works (say admin port is 1234): curl -X POST -d "logger=all&level=DEBUG"

DropWizard Auth Realms

时间秒杀一切 提交于 2020-01-10 02:55:18
问题 In DropWizard, I can set up basic auth like so (in the Application#run impl): BasicAuthProvider<SimplePrincipal> authProvider = new BasicAuthProvider(authenticator, "SECRET_REALM"); environment.jersey().register(authProvider); I am wondering what the significance of the String realm (" SECRET_REALM ") is? From general security concepts, I understand a "realm" to be a place (database, directory, file, keystore, etc.) where users and roles/permissions are stored. What does a realm mean in

How to register/add a command in dropwizard

a 夏天 提交于 2020-01-05 02:51:06
问题 I am trying to use the functionality of dropwizard http://dropwizard.codahale.com/manual/core/#commands I have written a class which extends from ConfiguredCommand and i want to add/register this to the dropwizard service/environment. I can't find out how to add/run the new command from dropwizard. 回答1: com.yammer.dropwizard.config.Bootstrap contains an addCommand method for adding ConfiguredCommand . You will get access to this object when you override initialize method in your service class

Dropwizard/Jersey is giving “Unable to process JSON” message on GET request

一曲冷凌霜 提交于 2020-01-04 05:14:15
问题 I'm trying to make my first simple project with Dropwizard. I have a MySQL-database, and the idea is to get the data (companies) from there and represent it as JSON. I have followed the Getting started page by Dropwizard and this tutorial to get connected to database with Hibernate. The idea is that URL "/companies" serves all the companies as JSON, and it is working fine. URL "/companies/{id}" is supposed to give a single company with given id, but every request gives code 400 and message