Skip to content
Open
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion NOTICE.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,16 @@ Javassist Version 3.30.2-GA
* Project: http://www.javassist.org/
* Copyright (C) 1999- Shigeru Chiba. All Rights Reserved.

Jackson JAX-RS Providers Version 2.19.1
Jackson JAX-RS Providers Version 2.20.1
* License: Apache License, 2.0
* Project: https://github.com/FasterXML/jackson-jaxrs-providers
* Copyright: (c) 2009-2024 FasterXML, LLC. All rights reserved unless otherwise indicated.

Jackson Jakarta RS Providers Version 3.0.3
* License: Apache License, 2.0
* Project: https://github.com/FasterXML/jackson-jakarta-rs-providers
* Copyright: (c) 2009-2025 FasterXML, LLC. All rights reserved unless otherwise indicated.

jQuery v3.7.1
* License: jquery.org/license
* Project: jquery.org
Expand Down
7 changes: 6 additions & 1 deletion bom/pom.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--

Copyright (c) 2013, 2025 Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2013, 2026 Oracle and/or its affiliates. All rights reserved.

This program and the accompanying materials are made available under the
terms of the Eclipse Public License v. 2.0, which is available at
Expand Down Expand Up @@ -286,6 +286,11 @@
<artifactId>jersey-media-json-jackson</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-json-jackson3</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-json-jettison</artifactId>
Expand Down
12 changes: 9 additions & 3 deletions bundles/apidocs/pom.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--

Copyright (c) 2012, 2025 Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2012, 2026 Oracle and/or its affiliates. All rights reserved.

This program and the accompanying materials are made available under the
terms of the Eclipse Public License v. 2.0, which is available at
Expand Down Expand Up @@ -66,8 +66,9 @@
<distribution>repo</distribution>
<comments>Google Guava @ org.glassfish.jersey.internal.guava,
Dropwizard Monitoring inspired classes @ org.glassfish.jersey.server.internal.monitoring.core,
Hibernate Validation classes @ org.glassfish.jersey.server.validation.internal.hibernate, and
Jackson JAX-RS Providers @ org.glassfish.jersey.jackson.internal.jackson.jaxrs</comments>
Hibernate Validation classes @ org.glassfish.jersey.server.validation.internal.hibernate,
Jackson JAX-RS Providers @ org.glassfish.jersey.jackson.internal.jackson.jaxrs, and
Jackson Jakarta RS Providers @ org.glassfish.jersey.jackson3.internal.jackson.jakarta.rs</comments>
</license>
<license>
<name>Public Domain</name>
Expand Down Expand Up @@ -297,6 +298,11 @@
<artifactId>jersey-media-json-jackson</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-json-jackson3</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.module</groupId>
<artifactId>jackson-module-jaxb-annotations</artifactId>
Expand Down
7 changes: 4 additions & 3 deletions bundles/examples/pom.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--

Copyright (c) 2013, 2025 Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2013, 2026 Oracle and/or its affiliates. All rights reserved.

This program and the accompanying materials are made available under the
terms of the Eclipse Public License v. 2.0, which is available at
Expand Down Expand Up @@ -68,8 +68,9 @@
<distribution>repo</distribution>
<comments>Google Guava @ org.glassfish.jersey.internal.guava,
Dropwizard Monitoring inspired classes @ org.glassfish.jersey.server.internal.monitoring.core,
Hibernate Validation classes @ org.glassfish.jersey.server.validation.internal.hibernate, and
Jackson JAX-RS Providers @ org.glassfish.jersey.jackson.internal.jackson.jaxrs</comments>
Hibernate Validation classes @ org.glassfish.jersey.server.validation.internal.hibernate,
Jackson JAX-RS Providers @ org.glassfish.jersey.jackson.internal.jackson.jaxrs, and
Jackson Jakarta RS Providers @ org.glassfish.jersey.jackson3.internal.jackson.jakarta.rs</comments>
</license>
<license>
<name>Public Domain</name>
Expand Down
7 changes: 4 additions & 3 deletions docs/pom.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--

Copyright (c) 2010, 2025 Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2010, 2026 Oracle and/or its affiliates. All rights reserved.

This program and the accompanying materials are made available under the
terms of the Eclipse Public License v. 2.0, which is available at
Expand Down Expand Up @@ -64,8 +64,9 @@
<distribution>repo</distribution>
<comments>Google Guava @ org.glassfish.jersey.internal.guava,
Dropwizard Monitoring inspired classes @ org.glassfish.jersey.server.internal.monitoring.core,
Hibernate Validation classes @ org.glassfish.jersey.server.validation.internal.hibernate, and
Jackson JAX-RS Providers @ org.glassfish.jersey.jackson.internal.jackson.jaxrs</comments>
Hibernate Validation classes @ org.glassfish.jersey.server.validation.internal.hibernate,
Jackson JAX-RS Providers @ org.glassfish.jersey.jackson.internal.jackson.jaxrs, and
Jackson Jakarta RS Providers @ org.glassfish.jersey.jackson3.internal.jackson.jakarta.rs</comments>
</license>
<license>
<name>Public Domain</name>
Expand Down
3 changes: 2 additions & 1 deletion etc/config/checkstyle-suppressions.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--

Copyright (c) 2014, 2018 Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2014, 2018, 2026 Oracle and/or its affiliates. All rights reserved.

This program and the accompanying materials are made available under the
terms of the Eclipse Public License v. 2.0, which is available at
Expand All @@ -26,6 +26,7 @@
<suppress files="org[\\/]openjdk[\\/]jmh" checks=".*"/>
<!-- Suppress all checks on repackaged Jackson JAX-RS providers. -->
<suppress files="org[\\/]glassfish[\\/]jersey[\\/]jackson[\\/]internal[\\/]jackson" checks=".*"/>
<suppress files="org[\\/]glassfish[\\/]jersey[\\/]jackson3[\\/]internal[\\/]jackson" checks=".*"/>
<suppress files="generated" checks=".*"/>

<!-- Suppress all checks for all Jersey repackaged libraries. -->
Expand Down
1 change: 1 addition & 0 deletions etc/config/copyright-exclude
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ build.readme
/core-server/src/main/java/org/glassfish/jersey/server/internal/monitoring/core/UniformTimeValuesSnapshot.java
/core-server/src/main/java/jersey/repackaged
/media/json-jackson/src/main/java/org/glassfish/jersey/jackson/internal/jackson
/media/json-jackson3/src/main/java/org/glassfish/jersey/jackson3/internal/jackson
/META-INF/NOTICE.md
NOTICE.md
/ext/cdi/jersey-cdi1x/src/main/java/org/glassfish/jersey/ext/cdi1x/internal/ProcessAllAnnotatedTypes.java
Expand Down
7 changes: 6 additions & 1 deletion examples/NOTICE.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,16 @@ Javassist Version 3.30.2-GA
* Project: http://www.javassist.org/
* Copyright (C) 1999- Shigeru Chiba. All Rights Reserved.

Jackson JAX-RS Providers Version 2.19.1
Jackson JAX-RS Providers Version 2.20.1
* License: Apache License, 2.0
* Project: https://github.com/FasterXML/jackson-jaxrs-providers
* Copyright: (c) 2009-2023 FasterXML, LLC. All rights reserved unless otherwise indicated.

Jackson Jakarta RS Providers Version 3.0.3
* License: Apache License, 2.0
* Project: https://github.com/FasterXML/jackson-jakarta-rs-providers
* Copyright: (c) 2009-2025 FasterXML, LLC. All rights reserved unless otherwise indicated.

jQuery v3.7.1
* License: jquery.org/license
* Project: jquery.org
Expand Down
91 changes: 91 additions & 0 deletions examples/json-jackson3/README.MD
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
[//]: # " Copyright (c) 2015, 2020, 2026 Oracle and/or its affiliates. All rights reserved. "
[//]: # " "
[//]: # " This program and the accompanying materials are made available under the "
[//]: # " terms of the Eclipse Distribution License v. 1.0, which is available at "
[//]: # " http://www.eclipse.org/org/documents/edl-v10.php. "
[//]: # " "
[//]: # " SPDX-License-Identifier: BSD-3-Clause "

Jackson JAX-RS JSON Provider Example
====================================

This example demonstrates how to produce/consume JSON representations
from Java objects. This applies not only to JAXB beans, as shown in the
`json-from-jaxb` example but also to ordinary, un-annotated, POJOs.

This example hosts three simple read-only resources: One provides an
example of using a Jackson JSON provider (registered by the feature
`JacksonFeature` in the `MyApplication` class) instead of using JAXB
(Object-&gt;JAXB-&gt;JSON) which has some limitations (e.g. empty arrays
in JAXB beans). For this resource the JSON representation is produced by
the Jackson JAX-RS provider, while the XML representation is generated
by JAXB as usual. The second web resource is based on a simple
un-annotated POJO and provides only JSON-based representations: JSON and
JSON with padding (JSONP). The third resource depicts how Jackson and
JAXB annotations could be mixed together within a single POJO.

Contents
--------

The "empty array" web resource is implemented by the `org.glassfish.jersey.examples.jackson3.EmptyArrayResource` class.

The "non JAXB" web resource is implemented by the `org.glassfish.jersey.examples.jackson3.NonJaxbBeanResource` class.

Both resources use the default Jackson mapper configuration to serialize JSON
data out and depicts the corner cases, where the Jersey internal, StAX
based, JSON processing can not be utilized.

The `org.glassfish.jersey.examples.jackson3.CombinedAnnotationResource`
class is used to show how JAXB and Jackson annotations could be combined
together in one Java bean for JSON serialization. See the

`org.glassfish.jersey.examples.jackson3.MyJsonMapperProvider` class
where Jackson specific options are used to set up the desired JSON
serialization configuration.

The mapping of the URI path space is presented in the following table:

URI path | Resource class | HTTP method
---------------------------- | ---------------------------- | -------------
**_/emptyArrayResource_** | EmptyArrayResource | GET
**_/nonJaxbResource_** | NonJaxbBeanResource | GET
**_/combinedAnnotations_** | CombinedAnnotationResource | GET

To use Jackson specific configuration options, one can implement a
`ContextResolver<JsonMapper>` provider. For an example of such an
implementation, see the `MyJsonMapperProvider` class.

Running the Example
-------------------

Run the example as follows:

> mvn clean compile exec:java

This deploys the example using[Grizzly](https://projects.eclipse.org/projects/ee4j.grizzly)

A [WADL description](http://wadl.java.net/#spec) may be accessed at the URL:

- <http://localhost:8080/jackson/application.wadl>

The three resources are available at

- <http://localhost:8080/jackson/emptyArrayResource>
- <http://localhost:8080/jackson/nonJaxbResource>
- <http://localhost:8080/jackson/combinedAnnotations>

To easily obtain the different output types available,
[cURL](http://curl.haxx.se/) can be used as follows:

Obtain the JSON output of EmptyArrayResource (use
`-HAccept:application/xml` for XML output):

> curl -HAccept:application/json http://localhost:8080/jackson/emptyArrayResource

Obtain the JSON output of NonJaxbBeanResource (use `-HAccept:application/javascript` for JSONP output):

> curl -HAccept:application/json http://localhost:8080/jackson/nonJaxbResource

Obtain the JSON output of CombinedAnnotationResource:

> curl -HAccept:application/json http://localhost:8080/jackson/combinedAnnotations
91 changes: 91 additions & 0 deletions examples/json-jackson3/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
<?xml version="1.0"?>
<!--

Copyright (c) 2010, 2026 Oracle and/or its affiliates. All rights reserved.

This program and the accompanying materials are made available under the
terms of the Eclipse Distribution License v. 1.0, which is available at
http://www.eclipse.org/org/documents/edl-v10.php.

SPDX-License-Identifier: BSD-3-Clause

-->

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.glassfish.jersey.examples</groupId>
<artifactId>project</artifactId>
<version>${revision}</version>
</parent>

<artifactId>json-jackson3</artifactId>
<packaging>jar</packaging>
<name>jersey-examples-json-jackson</name>

<description>Jersey JSON with Jackson example.</description>

<dependencies>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-grizzly2-http</artifactId>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.inject</groupId>
<artifactId>jersey-hk2</artifactId>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-json-jackson3</artifactId>
</dependency>

<dependency>
<groupId>org.glassfish.jersey.test-framework.providers</groupId>
<artifactId>jersey-test-framework-provider-bundle</artifactId>
<type>pom</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.test-framework</groupId>
<artifactId>jersey-test-framework-util</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>jakarta.xml.bind</groupId>
<artifactId>jakarta.xml.bind-api</artifactId>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-osgi</artifactId>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<configuration>
<mainClass>org.glassfish.jersey.examples.jackson3.App</mainClass>
</configuration>
</plugin>
</plugins>
</build>

<profiles>
<profile>
<id>pre-release</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
</plugin>
</plugins>
</build>
</profile>
</profiles>

</project>
28 changes: 28 additions & 0 deletions examples/json-jackson3/src/main/assembly/src.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<!--

Copyright (c) 2010, 2018, 2026 Oracle and/or its affiliates. All rights reserved.

This program and the accompanying materials are made available under the
terms of the Eclipse Distribution License v. 1.0, which is available at
http://www.eclipse.org/org/documents/edl-v10.php.

SPDX-License-Identifier: BSD-3-Clause

-->

<assembly>
<id>project</id>
<formats>
<format>zip</format>
</formats>
<fileSets>
<fileSet>
<directory>.</directory>
<outputDirectory></outputDirectory>
<useDefaultExcludes>true</useDefaultExcludes>
<excludes>
<exclude>**/target/**</exclude>
</excludes>
</fileSet>
</fileSets>
</assembly>
Loading
Loading