{"id":21006252,"url":"https://github.com/derlin/jersey-jetty-bean-validation-template","last_synced_at":"2026-07-02T07:33:10.152Z","repository":{"id":151664304,"uuid":"58376660","full_name":"derlin/jersey-jetty-bean-validation-template","owner":"derlin","description":"A webservice template using Maven, Jetty and Jersey and fully supporting the bean validation annotations.","archived":false,"fork":false,"pushed_at":"2016-05-09T17:40:09.000Z","size":44,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-04T21:32:50.740Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/derlin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-05-09T12:58:33.000Z","updated_at":"2024-06-22T02:46:17.000Z","dependencies_parsed_at":null,"dependency_job_id":"5cfb50b7-0e45-462e-bd20-bfd5f7e0622e","html_url":"https://github.com/derlin/jersey-jetty-bean-validation-template","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/derlin/jersey-jetty-bean-validation-template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/derlin%2Fjersey-jetty-bean-validation-template","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/derlin%2Fjersey-jetty-bean-validation-template/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/derlin%2Fjersey-jetty-bean-validation-template/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/derlin%2Fjersey-jetty-bean-validation-template/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/derlin","download_url":"https://codeload.github.com/derlin/jersey-jetty-bean-validation-template/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/derlin%2Fjersey-jetty-bean-validation-template/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35038239,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-07-02T02:00:06.368Z","response_time":173,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-19T08:50:22.711Z","updated_at":"2026-07-02T07:33:10.132Z","avatar_url":"https://github.com/derlin.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# jersey-jetty-bean-validation-template\n\nThis is a starter template for a __Java EE RESTful application__ using an embedded Jetty Server.\n\n## quick start\n\n__run__:\n\n - clone the project: `git clone git@github.com:derlin/jersey-jetty-bean-validation-template.git`\n - from the commandline go to the root of the project and run the following command: `mvn jetty:run`\n - if you use an IDE, you can also run the `WebAppLauncher` class\n - open `http://localhost:8680/api`, it should display _it works!_.\n\n__test__:\n\nThe simplest way is to use `curl`. The web service post method expect a json like this one:\n\n```\n{\n  \"timestamp\": \"2016-12-31T15:59:60+02:00\", // date using the RFC 3339 standard\n  \"captor-id\": \"3\", // a positive integer\n  \"address\": \"1.1.1.1\", // optional: only numbers and dots\n  \"value\": \"3.4\", // a string\n  \"token\": \"123456789-123456789-123456789-12\", // a string of length 32\n  \"comment\": \"lala\" // an optional comment, at most 1024 chars\n}\n```\nFor example, the following command should work:\n\n```\ncurl localhost:8680/api -X POST --header \"content-type:application/json\" -d '{ \"timestamp\": \"2016-12-31T15:59:60+02:00\", \"captor-id\": \"3\", \"value\": \"3.4\", \"token\": \"123456789-123456789-123456789-12\" }'\n```\n\nwhile the following command should display an error (negative captor-id):\n```\ncurl localhost:8680/api -X POST --header \"content-type:application/json\" -d '{ \"timestamp\": \"2016-12-31T15:59:60+02:00\", \"captor-id\": \"-3\", \"value\": \"3.4\", \"token\": \"123456789-123456789-123456789-12\" }' -v\n```\n\n--------------------------\n\n### Technologies\n\nThe project uses the following technologies:\n\n - [Maven](https://maven.apache.org/what-is-maven.html): a module for dependency management;\n - [Jetty](http://www.eclipse.org/jetty/): a simple web server and servlet container that can be embedded;\n - [Jersey](https://jersey.java.net/): a RESTful Web Services framework conforming to the JAX-RS reference implementation;\n - [Jackson](http://wiki.fasterxml.com/JacksonHome): a multi-purpose Java library for processing JSON data format;\n\n\n### Jetty Server\n\n This project contains everything needed to develop and run quickly a Java RESTful webserver. Moreover, it is configured\n to support the standard bean annotation validation.\n\n #### Embedded Jetty\n\n The jetty dependencies are listed in the `pom.xml`. The server can be started either from your IDE\n (by runnig the `WebAppLauncher` main method) or using the [mavenjetty plugin](http://www.eclipse.org/jetty/documentation/current/jetty-maven-plugin.html).\n\nTo configure jetty, have a look at the `ExampleApp` class, as well as the `webapp/WEB-INF/web.xml` file.\n`ExampleApp` lists the packages to parse in search for jersey webservices (in this project, the `ch.derlin.jaxrs.ws` package) and\nturn the bean validation features on.\nThe `web.xml` file registers the default servlet container, set the base path of the\nwebservices (the root `/` in this project) and pass the `ExampleApp` class as a parameter to the\nservlet container.\n\nThe only things you would like to change (except for the class names of course), are:\n\n - the server port: declared both in the `pom.xml` and the `WebAppLauncher` class;\n - the validation support: to turn it off, just remove all the calls to the `properties()` method inside the `ExampleApp` constructor;\n - the webservices packages: you need to list all the packages containing web services in the `ExampleApp` constructor. Note that the parsing is\n   recursive. By default, it will load the classes under `ch.derlin.jaxrs.ws`.\n\n\n### Web Service and Java bean\n\nThe sample provides one web service, `ExampleService`, which supports GET and POST methods under the path `/api`.\nThe POST method accepts both JSON and XML and expects a __valid__ `InputExample` object (due to the `@Valid` annotation).\n\n__standard validation annotations__\n\nThe `InputExample` class is a simple Java Bean, which shows different ways to use the standard validation annotations:\n\n - `@Null`, `@NotNull`: optional vs required parameters;\n - `@Size`, `@Min`, `@Max`: for the size of Strings/integers/floats;\n - `@Pattern`: specifying a special pattern (regex) which must be validated against the serialized field.\n\n\n__json support and custom serializers__\n\nThe `@XmlRootElement` and `@XmlElement` annotations mark the classes/fields to be included in the XML/JSON. The optional `name` argument\nallows you to specify another name for the field.\n\nThe `timestamp` field is interesting, since it shows you how to use a custom serializer. Have a look at the `@JsonSerialize` and `@JsonDeserialize` annotations\nand the  `ch.derlin.jaxrs.utils.RFC3339JsonUtils` class. Here, the date is serialized/deserialized using the RFC 3339 format).  \n\n\n### Static resources\n\nIn this example, any static resource under `src/main/webapp` is served (have a look at the `index.html` for more details.). To achieve this, two things:\n\n - for _mvn launch_: the `pom.xml` specifies a  resource directory,\n - for _IDE launch_: the `WebAppLauncher` get the path to the project sources and add it as the `resourceBase` (for it to work, `webapp` must be a resource directory in your project settings).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fderlin%2Fjersey-jetty-bean-validation-template","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fderlin%2Fjersey-jetty-bean-validation-template","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fderlin%2Fjersey-jetty-bean-validation-template/lists"}