Source code file content

Revision: 5845

JERSEY-1726: updated signature of Jersey TestContainerFactory supports method + copyright update
» Project Revision History

» Checkout URL

svn / trunk / jersey / jersey-documentation / src / docbook / dependencies.xml

Size: 45440 bytes, 1 line
<?xml version="1.0" encoding="UTF-8"?>
<!--

    DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.

    Copyright (c) 2010-2013 Oracle and/or its affiliates. All rights reserved.

    The contents of this file are subject to the terms of either the GNU
    General Public License Version 2 only ("GPL") or the Common Development
    and Distribution License("CDDL") (collectively, the "License").  You
    may not use this file except in compliance with the License.  You can
    obtain a copy of the License at
    http://glassfish.java.net/public/CDDL+GPL_1_1.html
    or packager/legal/LICENSE.txt.  See the License for the specific
    language governing permissions and limitations under the License.

    When distributing the software, include this License Header Notice in each
    file and include the License file at packager/legal/LICENSE.txt.

    GPL Classpath Exception:
    Oracle designates this particular file as subject to the "Classpath"
    exception as provided by Oracle in the GPL Version 2 section of the License
    file that accompanied this code.

    Modifications:
    If applicable, add the following below the License Header, with the fields
    enclosed by brackets [] replaced by your own identifying information:
    "Portions Copyright [year] [name of copyright owner]"

    Contributor(s):
    If you wish your version of this file to be governed by only the CDDL or
    only the GPL Version 2, indicate your decision by adding "[Contributor]
    elects to include this software in this distribution under the [CDDL or GPL
    Version 2] license."  If you don't indicate a single choice of license, a
    recipient has the option to distribute your version of this file under
    either the CDDL, the GPL Version 2 or to extend the choice of license to
    its licensees as provided above.  However, if you add GPL Version 2 code
    and therefore, elected the GPL Version 2 license, then the option applies
    only if the new code is made subject to such option by the copyright
    holder.

-->

<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
"http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd"[
<!ENTITY % ents SYSTEM "jersey.ent" >
%ents;
]>
<chapter id="chapter_deps">
  <title>Dependencies</title>

  <para>Jersey is built, assembled and installed using Maven. Jersey is
  deployed to the Java.Net maven repository at the following location: <ulink
  url="https://maven.java.net/index.html">http://maven.java.net/</ulink>.
  The Jersey modules can be browsed at the following location: <ulink
  url="https://maven.java.net/content/repositories/&repository;/com/sun/jersey">https://maven.java.net/content/repositories/&repository;/com/sun/jersey</ulink>.
  Jars, Jar sources, Jar JavaDoc and samples are all available on the java.net
  maven repository.</para>

  <para>A zip file containing all maven-based samples can be obtained <ulink
  url="http://maven.java.net/service/local/artifact/maven/redirect?r=&repository;&amp;g=com.sun.jersey.samples&amp;a=jersey-samples&amp;v=&version;&amp;e=zip&amp;c=project">here</ulink>.
  Individual zip files for each sample may be found by browsing the <ulink
  url="https://maven.java.net/content/repositories/&repository;/com/sun/jersey/samples/">samples</ulink>
  directory.</para>

  <para>An application depending on Jersey requires that it in turn includes
  the set of jars that Jersey depends on. Jersey has a pluggable component
  architecture so the set of jars required to be include in the class path can
  be different for each application.</para>
  
  <para>
  All Jersey components are built using Java SE 6 compiler. It means, you will also need at least Java SE 6
  to be able to compile and run your application.
  </para>

  <para>Developers using maven are likely to find it easier to include and
  manage dependencies of their applications than developers using ant or other
  build technologies. This document will explain to both maven and non-maven
  developers how to depend on Jersey for their application. Ant developers are
  likely to find the <ulink url="http://maven.apache.org/ant-tasks/index.html">Ant
  Tasks for Maven</ulink> very useful. For the convenience of non-maven
  developers the following are provided: <itemizedlist>
      <listitem>
        <para>A <ulink
        url="http://maven.java.net/service/local/artifact/maven/redirect?r=&repository;&amp;g=com.sun.jersey&amp;a=jersey-archive&amp;v=&version;&amp;e=zip">zip
        of Jersey</ulink> containing the Jersey jars, core dependencies (it
        does not provide dependencies for third party jars beyond those
        for JSON support) and JavaDoc.</para>
      </listitem>

      <listitem>
        <para>A <ulink
        url="http://maven.java.net/service/local/artifact/maven/redirect?r=&repository;&amp;g=com.sun.jersey&amp;a=jersey-bundle&amp;v=&version;&amp;e=jar">jersey
        bundle jar</ulink> to avoid the dependency management of multiple
        jersey-based jars.</para>
      </listitem>
    </itemizedlist></para>

  <para>Jersey's runtime dependences are categorized into the following:
  <itemizedlist>
      <listitem>
        <para>Core server. The minimum set of dependences that Jersey requires
        for the server.</para>
      </listitem>

      <listitem>
        <para>Core client. The minimum set of dependences that Jersey requires
        for the client.</para>
      </listitem>

      <listitem>
        <para>Container. The set of container dependences. Each container
        provider has it's own set of dependences.</para>
      </listitem>

      <listitem>
        <para>Entity. The set of entity dependencies. Each entity provider has
        it's own set of dependences.</para>
      </listitem>

      <listitem>
        <para>Tools. The set of dependencies required for runtime
        tooling.</para>
      </listitem>

      <listitem>
        <para>Spring. The set of dependencies required for Spring.</para>
      </listitem>

      <listitem>
        <para>Guice. The set of dependencies required for Guice.</para>
      </listitem>
    </itemizedlist></para>

  <para>All dependences in this documented are referenced by
  hyper-links</para>

  <section id="core_server">
    <title>Core server</title>

    <para>Maven developers require a dependency on the <ulink
    url="http://maven.java.net/service/local/artifact/maven/redirect?r=&repository;&amp;g=com.sun.jersey&amp;a=jersey-server&amp;v=&version;&amp;e=pom">jersey-server</ulink>
    module. The following dependency needs to be added to the pom:
    <programlisting language="xml">&lt;dependency&gt;
    &lt;groupId&gt;com.sun.jersey&lt;/groupId&gt;
    &lt;artifactId&gt;jersey-server&lt;/artifactId&gt;
    &lt;version&gt;&version;&lt;/version&gt;
&lt;/dependency&gt;</programlisting></para>

    <para>If you want to depend on Jersey snapshot versions the following repository needs to be added to the pom:
    <programlisting language="xml">&lt;repository&gt;
    &lt;id&gt;snapshot-repository.java.net&lt;/id&gt;
    &lt;name&gt;Java.net Snapshot Repository for Maven&lt;/name&gt;
    &lt;url&gt;https://maven.java.net/content/repositories/snapshots/&lt;/url&gt;
    &lt;layout&gt;default&lt;/layout&gt;
&lt;/repository&gt;</programlisting></para> 

    <para>Non-maven developers require: <itemizedlist>
        <listitem>
          <ulink
          url="http://maven.java.net/service/local/artifact/maven/redirect?r=&repository;&amp;g=com.sun.jersey&amp;a=jersey-server&amp;v=&version;&amp;e=jar">jersey-server.jar</ulink>

          ,
        </listitem>

        <listitem>
          <ulink
          url="http://maven.java.net/service/local/artifact/maven/redirect?r=&repository;&amp;g=com.sun.jersey&amp;a=jersey-core&amp;v=&version;&amp;e=jar">jersey-core.jar</ulink>

          ,
        </listitem>

        <listitem>
          <ulink
          url="http://search.maven.org/remotecontent?filepath=asm/asm/&asm.version;/asm-&asm.version;.jar">asm.jar</ulink>
        </listitem>
      </itemizedlist> or, if using the jersey-bundle: <itemizedlist>
        <listitem>
          <ulink
          url="http://maven.java.net/service/local/artifact/maven/redirect?r=&repository;&amp;g=com.sun.jersey&amp;a=jersey-bundle&amp;v=&version;&amp;e=jar">jersey-bundle.jar</ulink>

          ,
        </listitem>

        <listitem>
          <ulink
          url="http://search.maven.org/remotecontent?filepath=asm/asm/&asm.version;/asm-&asm.version;.jar">asm.jar</ulink>
        </listitem>
      </itemizedlist> For Ant developers the <ulink
    url="http://maven.apache.org/ant-tasks/index.html">Ant Tasks for Maven</ulink>
    may be used to add the following to the ant document such that the
    dependencies do not need to be downloaded explicitly: <programlisting language="xml">&lt;artifact:dependencies pathId="dependency.classpath"&gt;
  &lt;dependency groupId="com.sun.jersey"
              artifactId="jersey-server"
              version="&version;"/&gt;
  &lt;artifact:remoteRepository id="maven-repository.java.net"
                             url="http://maven.java.net/" /&gt;
  &lt;artifact:remoteRepository id="maven1-repository.java.net"
                             url="http://download.java.net/maven/1"
                             layout="legacy" /&gt;
&lt;/artifact:dependencies&gt;</programlisting> The path id
    “dependency.classpath” may then be referenced as the classpath to be used
    for compiling or executing. Specifically the <ulink
    url="http://search.maven.org/remotecontent?filepath=asm/asm/&asm.version;/asm-&asm.version;.jar">asm.jar</ulink>
    dependency is required when either of the following <ulink
    url="http://jersey.java.net/nonav/apidocs/&version;/jersey/com/sun/jersey/api/core/ResourceConfig.html">com.sun.jersey.api.core.ResourceConfig</ulink>
    implementations are utilized: <itemizedlist>
        <listitem>
          <ulink
          url="http://jersey.java.net/nonav/apidocs/&version;/jersey/com/sun/jersey/api/core/ClasspathResourceConfig.html">com.sun.jersey.api.core.ClasspathResourceConfig</ulink>

          ; or
        </listitem>

        <listitem>
          <ulink
          url="http://jersey.java.net/nonav/apidocs/&version;/jersey/com/sun/jersey/api/core/PackagesResourceConfig.html">com.sun.jersey.api.core.PackagesResourceConfig</ulink>
        </listitem>
      </itemizedlist></para>

    <para>By default Jersey will utilize the <ulink
    url="http://jersey.java.net/nonav/apidocs/&version;/jersey/com/sun/jersey/api/core/ClasspathResourceConfig.html">ClasspathResourceConfig</ulink>
    if an alternative is not specified. If an alternative is specified that
    does not depend on the asm.jar then it is no longer necessary to include
    the asm.jar in the minimum set of required jars.</para>
  </section>

  <section id="core_client">
    <title>Core client</title>

    <para>Maven developers require a dependency on the <ulink
    url="http://maven.java.net/service/local/artifact/maven/redirect?r=&repository;&amp;g=com.sun.jersey&amp;a=jersey-client&amp;v=&version;&amp;e=pom">jersey-client</ulink>
    module. The following dependency needs to be added to the pom:
    <programlisting language="xml">&lt;dependency&gt;
    &lt;groupId&gt;com.sun.jersey&lt;/groupId&gt;
    &lt;artifactId&gt;jersey-client&lt;/artifactId&gt;
    &lt;version&gt;&version;&lt;/version&gt;
&lt;/dependency&gt;</programlisting> Non-maven developers require:
    <itemizedlist>
        <listitem>
          <ulink
          url="http://maven.java.net/service/local/artifact/maven/redirect?r=&repository;&amp;g=com.sun.jersey&amp;a=jersey-client&amp;v=&version;&amp;e=jar">jersey-client.jar</ulink>

          ,
        </listitem>

        <listitem>
          <ulink
          url="http://maven.java.net/service/local/artifact/maven/redirect?r=&repository;&amp;g=com.sun.jersey&amp;a=jersey-core&amp;v=&version;&amp;e=jar">jersey-core.jar</ulink>
        </listitem>

      </itemizedlist> or, if using the jersey-bundle: <itemizedlist>
        <listitem>
          <ulink
          url="http://maven.java.net/service/local/artifact/maven/redirect?r=&repository;&amp;g=com.sun.jersey&amp;a=jersey-bundle&amp;v=&version;&amp;e=jar">jersey-bundle.jar</ulink>
        </listitem>

      </itemizedlist></para>

    <para>The use of client with the Apache HTTP client to make HTTP request
    and receive HTTP responses requires a dependency on the <ulink
    url="http://maven.java.net/service/local/artifact/maven/redirect?r=&repository;&amp;g=com.sun.jersey.contribs&amp;a=jersey-apache-client&amp;v=&version;&amp;e=pom">jersey-apache-client</ulink>
    module. The following dependency needs to be added to the pom:
    <programlisting language="xml">&lt;dependency&gt;
    &lt;groupId&gt;com.sun.jersey.contribs&lt;/groupId&gt;
    &lt;artifactId&gt;jersey-apache-client&lt;/artifactId&gt;
    &lt;version&gt;&version;&lt;/version&gt;
&lt;/dependency&gt;</programlisting></para>
  </section>

  <section>
    <title>Container</title>

    <section>
      <title>Grizzly HTTP Web server</title>

      <para>Maven developers, deploying an application using the Grizzly2 HTTP
      Web server, require a dependency on the <ulink
      url="http://maven.java.net/service/local/artifact/maven/redirect?r=&repository;&amp;g=com.sun.jersey&amp;a=jersey-grizzly2&amp;v=&version;&amp;e=pom">jersey-grizzly2</ulink>      
      module.</para>

      <para>Non-maven developers require: <ulink
      url="http://maven.java.net/service/local/artifact/maven/redirect?r=&repository;&amp;g=com.sun.jersey&amp;a=jersey-grizzly2&amp;v=&version;&amp;e=jar">jersey-grizzly2.jar</ulink>,
  <ulink
      url="http://search.maven.org/remotecontent?filepath=org/glassfish/grizzly/grizzly-http-server/&grizzly2.version;/grizzly-http-server-&grizzly2.version;.jar">grizzly-http-server.jar</ulink>,
 and <ulink
      url="http://search.maven.org/remotecontent?filepath=org/glassfish/grizzly/grizzly-http/&grizzly2.version;/grizzly-http-&grizzly2.version;.jar">grizzly-http.jar</ulink></para>
    </section>

    <section>
      <title>Grizzly Servlet container</title>

      <para>Maven developers, deploying an application using the Grizzly Servlet container, require a dependency on the <ulink
      url="http://maven.java.net/service/local/artifact/maven/redirect?r=&repository;&amp;g=com.sun.jersey&amp;a=jersey-grizzly2-servlet&amp;v=&version;&amp;e=pom">jersey-grizzly2-servlet</ulink>
      module.</para>

      <para>Non-maven developers require: <ulink
      url="http://maven.java.net/service/local/artifact/maven/redirect?r=&repository;&amp;g=com.sun.jersey&amp;a=jersey-grizzly2-servlet&amp;v=&version;&amp;e=jar">jersey-grizzly2-servlet.jar</ulink>,
     <ulink
      url="http://search.maven.org/remotecontent?filepath=org/glassfish/grizzly/grizzly-http-servlet/&grizzly2.version;/grizzly-http-servlet-&grizzly2.version;.jar">grizzly-http-servlet.jar</ulink>,
     <ulink
      url="http://maven.java.net/service/local/artifact/maven/redirect?r=&repository;&amp;g=com.sun.jersey&amp;a=jersey-grizzly2&amp;v=&version;&amp;e=jar">jersey-grizzly2.jar</ulink>,
     <ulink
      url="http://search.maven.org/remotecontent?filepath=org/glassfish/javax.servlet/&javax.servlet.version;/javax.servlet-&javax.servlet.version;.jar">javax.servlet-&javax.servlet.version;.jar</ulink></para>
    </section>

    <section>
      <title>Simple HTTP Web server</title>

      <para>Maven developers, deploying an application using the Simple HTTP
      Web server, require a dependency on the <ulink url="http://maven.java.net/service/local/artifact/maven/redirect?r=&repository;&amp;g=com.sun.jersey.contribs&amp;a=jersey-simple-server&amp;v=&version;&amp;e=pom">jersey-simple-server</ulink>
      module.</para>
    </section>
    <section>
      <title>Light weight HTTP server</title>

      <para>Deploying an application using the light weight HTTP server
      requires no additional dependences, as Java SE 6 already contains everything needed.</para>
    </section>

    <section>
      <title>Servlet</title>

      <para>Deploying an application on a servlet container requires a
      deployment dependency with that container.</para>

      <para>See the Java documentation <ulink
      url="http://jersey.java.net/nonav/apidocs/&version;/jersey/com/sun/jersey/spi/container/servlet/package-summary.html">here</ulink>
      on how to configure the servlet container.</para>

      <para>Using servlet:
      <code>com.sun.jersey.spi.container.servlet.ServletContainer</code>
      requires a dependency on the <ulink
      url="http://maven.java.net/service/local/artifact/maven/redirect?r=&repository;&amp;g=com.sun.jersey&amp;a=jersey-servlet&amp;v=&version;&amp;e=pom">jersey-servlet</ulink> module.</para>

      <para>Maven developers using servlet:
      <code>com.sun.jersey.server.impl.container.servlet.ServletAdaptor</code>
      in a non-EE 5 servlet require a dependency on the <ulink
      url="http://search.maven.org/remotecontent?filepath=javax/persistence/persistence-api/1.0.2/persistence-api-1.0.2.pom">persistence-api</ulink>
      module in addition.</para>

      <para>Non-Maven developers require: <ulink
      url="http://search.maven.org/remotecontent?filepath=javax/persistence/persistence-api/1.0.2/persistence-api-1.0.2.jar">persistence-api.jar</ulink></para>
    </section>
  </section>

  <section>
    <title>Entity</title>

    <section>
      <title>JAXB</title>

          <para>XML serialization support of Java types that are JAXB beans
          requires a dependency on the JAXB reference implementation version 2.x
          or higher (see later for specific version constraints with respect to
          JSON support). Deploying an application for XML serialization support
          requires no additional dependencies, since Java SE 6 ships with JAXB 2.x support.
          Alternatively, instead of JAXB RI, you can use MOXy as your JAXB implementation (version of 2.3.x or higher is required)</para>

          <section>
              <title>JAXB RI (reference implementation)</title>
          <para>Maven developers, using JSON serialization support of JAXB beans
          when using the MIME media type <code>application/json</code> require a
          dependency on the <ulink url="http://maven.java.net/service/local/artifact/maven/redirect?r=&repository;&amp;g=com.sun.jersey&amp;a=jersey-json&amp;v=&version;&amp;e=pom">jersey-json</ulink>
          module (no explicit dependency on jaxb-impl is required). This module
          depends on the JAXB reference implementation version 2.1.12 or greater,
          and such a version is required when enabling support for the JAXB
          natural JSON convention. For all other supported JSON conventions any
          JAXB 2.x version may be utilized. The following dependency needs to be
          added to the pom: <programlisting language="xml">&lt;dependency&gt;
    &lt;groupId&gt;com.sun.jersey&lt;/groupId&gt;
    &lt;artifactId&gt;jersey-json&lt;/artifactId&gt;
    &lt;version&gt;&version;&lt;/version&gt;
&lt;/dependency&gt;</programlisting></para>

          <para>Non-maven developers require: <itemizedlist>
              <listitem>
                <ulink
                url="http://repository.codehaus.org/org/codehaus/jackson/jackson-core-asl/&jackson.version;/jackson-core-asl-&jackson.version;.jar">jackson-core-asl.jar</ulink>

                ,
              </listitem>

              <listitem>
                <ulink
                url="http://repository.codehaus.org/org/codehaus/jackson/jackson-mapper-asl/&jackson.version;/jackson-mapper-asl-&jackson.version;.jar">jackson-mapper-asl.jar</ulink>

                ,
              </listitem>

              <listitem>
                <ulink
                url="http://repository.codehaus.org/org/codehaus/jackson/jackson-jaxrs/&jackson.version;/jackson-jaxrs-&jackson.version;.jar">jackson-jaxrs.jar</ulink>

                ,
              </listitem>

              <listitem>
                <ulink
                url="http://repo1.maven.org/maven2/org/codehaus/jettison/jettison/1.1/jettison-1.1.jar">jettison.jar</ulink>

                ,
              </listitem>

              <listitem>
                <ulink
                url="http://search.maven.org/remotecontent?filepath=com/sun/xml/bind/jaxb-impl/2.2.4-1/jaxb-impl-2.2.4-1.jar">jaxb-impl.jar</ulink>

                ,
              </listitem>

              <listitem>
                <ulink
                url="http://search.maven.org/remotecontent?filepath=javax/xml/bind/jaxb-api/2.2.4/jaxb-api-2.2.4.jar">jaxb-api.jar</ulink>

                ,
              </listitem>

              <listitem>
                <ulink
                url="http://search.maven.org/remotecontent?filepath=javax/activation/activation/1.1.1/activation-1.1.1.jar">activation.jar</ulink>

                ,
              </listitem>

              <listitem>
                <ulink
                url="http://search.maven.org/remotecontent?filepath=javax/xml/stream/stax-api/1.0-2/stax-api-1.0-2.jar">stax-api.jar</ulink>
              </listitem>
            </itemizedlist> and additionally, if not depending on the <ulink url="http://maven.java.net/service/local/artifact/maven/redirect?r=&repository;&amp;g=com.sun.jersey&amp;a=jersey-bundle&amp;v=&version;&amp;e=jar">jersey-bundle.jar</ulink>,
          non-maven developers require: <ulink url="http://maven.java.net/service/local/artifact/maven/redirect?r=&repository;&amp;g=com.sun.jersey&amp;a=jersey-json&amp;v=&version;&amp;e=jar">jersey-json.jar</ulink></para>
              <para><emphasis>Note:</emphasis> Jersey JSON module of version 1.13 and later requires the <ulink
                      url="http://repository.codehaus.org/org/codehaus/jackson/jackson-core-asl/&jackson.version;/jackson-core-asl-&jackson.version;.jar">jackson-core-asl.jar</ulink> library to be present on the classpath.</para>
          <para>Maven developers, using Fast Infoset serialization support of JAXB
          beans with using the MIME media type
          <code>application/fastinfoset</code> require a dependency on the <ulink url="http://maven.java.net/service/local/artifact/maven/redirect?r=&repository;&amp;g=com.sun.jersey&amp;a=jersey-fastinfoset&amp;v=&version;&amp;e=pom">jersey-fastinfoset</ulink>
          module (no dependency on jaxb-impl is required). The following
          dependency needs to be added to the pom: <programlisting language="xml">&lt;dependency&gt;
    &lt;groupId&gt;com.sun.jersey&lt;/groupId&gt;
    &lt;artifactId&gt;jersey-fastinfoset&lt;/artifactId&gt;
    &lt;version&gt;&version;&lt;/version&gt;
&lt;/dependency&gt;</programlisting></para>

          <para>Non-maven developers require: <itemizedlist>
              <listitem>
                <ulink
                url="http://search.maven.org/remotecontent?filepath=com/sun/xml/fastinfoset/FastInfoset/1.2.12/FastInfoset-1.2.12.jar">FastInfoset.jar</ulink>

                ,
              </listitem>

              <listitem>
                <ulink
                url="http://search.maven.org/remotecontent?filepath=com/sun/xml/bind/jaxb-impl/2.2.4-1/jaxb-impl-2.2.4-1.jar">jaxb-impl.jar</ulink>

                ,
              </listitem>

              <listitem>
                <ulink
                url="http://search.maven.org/remotecontent?filepath=javax/xml/bind/jaxb-api/2.2.4/jaxb-api-2.2.4.jar">jaxb-api.jar</ulink>

                ,
              </listitem>

              <listitem>
                <ulink
                url="http://search.maven.org/remotecontent?filepath=javax/activation/activation/1.1.1/activation-1.1.1.jar">activation.jar</ulink>

                ,
              </listitem>

              <listitem>
                <ulink
                url="http://search.maven.org/remotecontent?filepath=javax/xml/stream/stax-api/1.0-2/stax-api-1.0-2.jar">stax-api.jar</ulink>
              </listitem>
            </itemizedlist> and additionally, if not depending on the <ulink url="http://maven.java.net/service/local/artifact/maven/redirect?r=&repository;&amp;g=com.sun.jersey&amp;a=jersey-bundle&amp;v=&version;&amp;e=jar">jersey-bundle.jar</ulink>,
          non-maven developers require: <ulink url="http://maven.java.net/service/local/artifact/maven/redirect?r=&repository;&amp;g=com.sun.jersey&amp;a=jersey-fastinfoset&amp;v=&version;&amp;e=jar">jersey-fastinfoset.jar</ulink></para>
              </section>

        <section>
            <title>MOXy</title>
            <para>Maven developers, using JSON serialization support of JAXB beans
                when using the MIME media type <code>application/json</code> require a
                dependency on the <ulink url="http://maven.java.net/service/local/artifact/maven/redirect?r=&repository;&amp;g=com.sun.jersey&amp;a=jersey-json&amp;v=&version;&amp;e=pom">jersey-json</ulink>
                module (explicit dependency on org.eclipse.persistence.moxy is required). The following dependencies need to be
                added to the pom: <programlisting language="xml">&lt;dependency&gt;
     &lt;groupId&gt;com.sun.jersey&lt;/groupId&gt;
     &lt;artifactId&gt;jersey-json&lt;/artifactId&gt;
     &lt;version&gt;&version;&lt;/version&gt;
     &lt;exclusions&gt;
         &lt;exclusion&gt;
             &lt;exclusion&gt;com.sun.xml.bind&lt;exclusion&gt;
             &lt;exclusion&gt;jaxb-impl&lt;exclusion&gt;
         &lt;/exclusion&gt;
     &lt;/exclusions&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
    &lt;groupId&gt;org.eclipse.persistence&lt;/groupId&gt;
    &lt;artifactId&gt;org.eclipse.persistence.moxy&lt;/artifactId&gt;
    &lt;version&gt;2.3.2&lt;/version&gt;
&lt;/dependency&gt;</programlisting></para>
            <para>
                Also an additional repository should be added to the pom: <programlisting language="xml">&lt;repository&gt;
    &lt;id&gt;eclipselink.repository&lt;/id&gt;
    &lt;name&gt;Eclipse Maven Repository&lt;/name&gt;
    &lt;url&gt;http://www.eclipse.org/downloads/download.php?r=1&amp;nf=1&amp;file=/rt/eclipselink/maven.repo&lt;/url&gt;
    &lt;layout&gt;default&lt;/layout&gt;
&lt;/repository&gt;</programlisting></para>

            <para>Non-maven developers require: <itemizedlist>
                <listitem>
                    <ulink
                            url="http://repository.codehaus.org/org/codehaus/jackson/jackson-core-asl/&jackson.version;/jackson-core-asl-&jackson.version;.jar">jackson-core-asl.jar</ulink>

                    ,
                </listitem>

                <listitem>
                    <ulink
                            url="http://repository.codehaus.org/org/codehaus/jackson/jackson-mapper-asl/&jackson.version;/jackson-mapper-asl-&jackson.version;.jar">jackson-mapper-asl.jar</ulink>

                    ,
                </listitem>

                <listitem>
                    <ulink
                            url="http://repository.codehaus.org/org/codehaus/jackson/jackson-jaxrs/&jackson.version;/jackson-jaxrs-&jackson.version;.jar">jackson-jaxrs.jar</ulink>

                    ,
                </listitem>

                <listitem>
                    <ulink
                            url="http://repo1.maven.org/maven2/org/codehaus/jettison/jettison/1.1/jettison-1.1.jar">jettison.jar</ulink>

                    ,
                </listitem>

                <listitem>
                    <ulink
                            url="http://download.eclipse.org/rt/eclipselink/maven.repo/org/eclipse/persistence/org.eclipse.persistence.moxy/2.3.2/org.eclipse.persistence.moxy-2.3.2.jar">org.eclipse.persistence.moxy.jar</ulink>

                    ,
                </listitem>

                <listitem>
                    <ulink
                            url="http://download.eclipse.org/rt/eclipselink/maven.repo/org/eclipse/persistence/org.eclipse.persistence.antlr/2.3.2/org.eclipse.persistence.antlr-2.3.2.jar">org.eclipse.persistence.antlr.jar</ulink>

                    ,
                </listitem>

                <listitem>
                    <ulink
                            url="http://download.eclipse.org/rt/eclipselink/maven.repo/org/eclipse/persistence/org.eclipse.persistence.core/2.3.2/org.eclipse.persistence.core-2.3.2.jar">org.eclipse.persistence.core.jar</ulink>

                    ,
                </listitem>

                <listitem>
                    <ulink
                            url="http://download.eclipse.org/rt/eclipselink/maven.repo/org/eclipse/persistence/org.eclipse.persistence.asm/2.3.2/org.eclipse.persistence.asm-2.3.2.jar">org.eclipse.persistence.asm.jar</ulink>

                    ,
                </listitem>

                <listitem>
                    <ulink
                            url="http://search.maven.org/remotecontent?filepath=javax/xml/bind/jaxb-api/2.2.4/jaxb-api-2.2.4.jar">jaxb-api.jar</ulink>

                    ,
                </listitem>

                <listitem>
                    <ulink
                            url="http://search.maven.org/remotecontent?filepath=javax/activation/activation/1.1.1/activation-1.1.1.jar">activation.jar</ulink>

                    ,
                </listitem>

                <listitem>
                    <ulink
                            url="http://search.maven.org/remotecontent?filepath=javax/xml/stream/stax-api/1.0-2/stax-api-1.0-2.jar">stax-api.jar</ulink>
                </listitem>
            </itemizedlist> and additionally, if not depending on the <ulink url="http://maven.java.net/service/local/artifact/maven/redirect?r=&repository;&amp;g=com.sun.jersey&amp;a=jersey-bundle&amp;v=&version;&amp;e=jar">jersey-bundle.jar</ulink>,
                non-maven developers require: <ulink url="http://maven.java.net/service/local/artifact/maven/redirect?r=&repository;&amp;g=com.sun.jersey&amp;a=jersey-json&amp;v=&version;&amp;e=jar">jersey-json.jar</ulink></para>
            <para>For further information on how to set MOXy as your JAXB provider, refer to the: <ulink url="http://blog.bdoughan.com/2011/05/specifying-eclipselink-moxy-as-your.html">Specifying EclipseLink MOXy as Your JAXB Provider</ulink></para>
            <para><emphasis>Note:</emphasis> Jersey JSON module of version 1.13 and later requires the <ulink
                    url="http://repository.codehaus.org/org/codehaus/jackson/jackson-core-asl/&jackson.version;/jackson-core-asl-&jackson.version;.jar">jackson-core-asl.jar</ulink> library to be present on the classpath.</para>
        </section>
    </section>

    <section>
      <title>Atom</title>

      <para>The use of the Java types
      <code>org.apache.abdera.model.{Categories, Entry, Feed, Service}</code>
      requires a dependency on Apache Abdera.</para>

      <para>Maven developers require a dependency on the <ulink url="http://maven.java.net/service/local/artifact/maven/redirect?r=&repository;&amp;g=com.sun.jersey.contribs&amp;a=jersey-atom-abdera&amp;v=&version;&amp;e=pom">jersey-atom-abdera</ulink>
      module. The following dependency needs to be added to the pom:
      <programlisting language="xml">&lt;dependency&gt;
    &lt;groupId&gt;com.sun.jersey.contribs&lt;/groupId&gt;
    &lt;artifactId&gt;jersey-atom-abdera&lt;/artifactId&gt;
    &lt;version&gt;&version;&lt;/version&gt;
&lt;/dependency&gt;</programlisting></para>

      <para>The use of the Java types
      <code>com.sun.syndication.feed.atom.Entry</code> and
      <code>com.sun.syndication.feed.atom.Feed</code> requires a dependency on
      ROME version 0.9 or higher.</para>

      <para>Maven developers require a dependency on the <ulink url="http://maven.java.net/service/local/artifact/maven/redirect?r=&repository;&amp;g=com.sun.jersey&amp;a=jersey-atom&amp;v=&version;&amp;e=pom">jersey-atom</ulink>
      module. The following dependency needs to be added to the pom:
      <programlisting language="xml">&lt;dependency&gt;
    &lt;groupId&gt;com.sun.jersey&lt;/groupId&gt;
    &lt;artifactId&gt;jersey-atom&lt;/artifactId&gt;
    &lt;version&gt;&version;&lt;/version&gt;
&lt;/dependency&gt;</programlisting></para>

      <para>Non-maven developers require: <itemizedlist>
          <listitem>
            <ulink
            url="http://search.maven.org/remotecontent?filepath=rome/rome/1.0/rome-1.0.jar">rome.jar</ulink>

            ,
          </listitem>

          <listitem>
            <ulink
            url="http://search.maven.org/remotecontent?filepath=jdom/jdom/1.0/jdom-1.0.jar">jdom.jar</ulink>
          </listitem>
        </itemizedlist> and additionally, if not depending on the <ulink url="http://maven.java.net/service/local/artifact/maven/redirect?r=&repository;&amp;g=com.sun.jersey&amp;a=jersey-bundle&amp;v=&version;&amp;e=jar">jersey-bundle.jar</ulink>,
      non-maven developers require: <ulink url="http://maven.java.net/service/local/artifact/maven/redirect?r=&repository;&amp;g=com.sun.jersey&amp;a=jersey-atom&amp;v=&version;&amp;e=jar">jersey-atom.jar</ulink></para>
    </section>

    <section>
      <title>JSON</title>

      <para>The use of the Java types
      <code>org.codehaus.jettison.json.JSONObject</code> and
      <code>org.codehaus.jettison.json.JSONArray</code> requires Jettison
      version 1.1 or higher.</para>

      <para>Maven developers require a dependency on the <ulink url="http://maven.java.net/service/local/artifact/maven/redirect?r=&repository;&amp;g=com.sun.jersey&amp;a=jersey-json&amp;v=&version;&amp;e=pom">jersey-json</ulink>
      module. The following dependency needs to be added to the pom:
      <programlisting language="xml">&lt;dependency&gt;
    &lt;groupId&gt;com.sun.jersey&lt;/groupId&gt;
    &lt;artifactId&gt;jersey-json&lt;/artifactId&gt;
    &lt;version&gt;&version;&lt;/version&gt;
&lt;/dependency&gt;</programlisting></para>

      <para>Non-maven developers require: <ulink
      url="http://repo1.maven.org/maven2/org/codehaus/jettison/jettison/1.1/jettison-1.1.jar">jettison.jar</ulink>
      and additionally, if not depending on the <ulink url="http://maven.java.net/service/local/artifact/maven/redirect?r=&repository;&amp;g=com.sun.jersey&amp;a=jersey-bundle&amp;v=&version;&amp;e=jar">jersey-bundle.jar</ulink>
      non-maven developers require: <ulink url="http://maven.java.net/service/local/artifact/maven/redirect?r=&repository;&amp;g=com.sun.jersey&amp;a=jersey-json&amp;v=&version;&amp;e=jar">jersey-json.jar</ulink></para>
    </section>

    <section>
      <title>Mail and MIME multipart</title>

      <para>The use of the Java type
      <code>javax.mail.internet.MimeMultipart</code>
      requires Java Mail version 1.4 or higher.</para>

      <para>Maven developers require a dependency on the <ulink
      url="http://search.maven.org/remotecontent?filepath=javax/mail/mail/1.4.4/mail-1.4.4.pom">java-mail</ulink>
      module.</para>

      <para>Non-maven developers require: <itemizedlist>
          <listitem>
            <ulink
            url="http://search.maven.org/remotecontent?filepath=javax/mail/mail/1.4.4/mail-1.4.4.jar">mail.jar</ulink>

            ,
          </listitem>

          <listitem>
            <ulink
            url="http://search.maven.org/remotecontent?filepath=javax/activation/activation/1.1.1/activation-1.1.1.jar">activation.jar</ulink>
          </listitem>
        </itemizedlist></para>

      <para>Jersey ships with a high-level MIME multipart API. Maven
      developers requires a dependency on the <ulink url="http://maven.java.net/service/local/artifact/maven/redirect?r=&repository;&amp;g=com.sun.jersey.contribs&amp;a=jersey-multipart&amp;v=&version;&amp;e=pom">jersey-multipart</ulink>
      module. The following dependency needs to be added to the pom:
      <programlisting language="xml">&lt;dependency&gt;
    &lt;groupId&gt;com.sun.jersey.contribs&lt;/groupId&gt;
    &lt;artifactId&gt;jersey-multipart&lt;/artifactId&gt;
    &lt;version&gt;&version;&lt;/version&gt;
&lt;/dependency&gt;</programlisting></para>

      <para>Non-maven developers require: <itemizedlist>
          <listitem>
            <ulink url="http://search.maven.org/remotecontent?filepath=org/jvnet/mimepull/1.3/mimepull-1.3.jar">mimepull.jar</ulink>

            ,
          </listitem>

          <listitem>
              <ulink url="http://maven.java.net/service/local/artifact/maven/redirect?r=&repository;&amp;g=com.sun.jersey.contribs&amp;a=jersey-multipart&amp;v=&version;&amp;e=jar">jersey-multipart.jar</ulink>
          </listitem>
        </itemizedlist></para>
    </section>

    <section>
      <title>Activation</title>

      <para>The use of the Java type <code>javax.activation.DataSource</code>
      requires no additional dependencies, as Java SE 6 ships everything needed.</para>
    </section>
  </section>

  <section>
    <title>Tools</title>

    <para>By default WADL for resource classes is generated dynamically at
    runtime. WADL support requires a dependency on the JAXB reference
    implementation version 2.x or higher. Deploying an application for WADL
    support requires no additional dependences, since Java SE 6 ships with JAXB 2.x support.</para>

    <para>The WADL ant task requires the same set of dependences as those for
    runtime WADL support.</para>
  </section>

  <section>
    <title>Spring</title>

    <para>Maven developers, using Spring 2.0.x or Spring 2.5.x, require a
    dependency on the <ulink url="http://maven.java.net/service/local/artifact/maven/redirect?r=&repository;&amp;g=com.sun.jersey.contribs&amp;a=jersey-spring&amp;v=&version;&amp;e=pom">jersey-spring</ulink>
    module. The following dependency needs to be added to the pom:
    <programlisting language="xml">&lt;dependency&gt;
    &lt;groupId&gt;com.sun.jersey.contribs&lt;/groupId&gt;
    &lt;artifactId&gt;jersey-spring&lt;/artifactId&gt;
    &lt;version&gt;&version;&lt;/version&gt;
&lt;/dependency&gt;</programlisting></para>

    <para>See the Java documentation <ulink
    url="http://jersey.java.net/nonav/apidocs/&version;/contribs/jersey-spring/com/sun/jersey/spi/spring/container/servlet/package-summary.html">here</ulink>
    on how to integrate Jersey-based Web applications with Spring.</para>
  </section>

  <section>
    <title>Guice</title>

    <para>Maven developers, using Guice 2.0, require a dependency on the
    <ulink url="http://maven.java.net/service/local/artifact/maven/redirect?r=&repository;&amp;g=com.sun.jersey.contribs&amp;a=jersey-guice&amp;v=&version;&amp;e=pom">jersey-guice</ulink>
    module. The following dependency needs to be added to the pom:
    <programlisting language="xml">&lt;dependency&gt;
    &lt;groupId&gt;com.sun.jersey.contribs&lt;/groupId&gt;
    &lt;artifactId&gt;jersey-guice&lt;/artifactId&gt;
    &lt;version&gt;&version;&lt;/version&gt;
&lt;/dependency&gt;</programlisting></para>

    <para>See the Java documentation <ulink
    url="http://jersey.java.net/nonav/apidocs/&version;/contribs/jersey-guice/com/sun/jersey/guice/spi/container/servlet/package-summary.html">here</ulink>
    on how to integrate Jersey-based Web applications with Guice.</para>

    <para>The Jersey Guice support may also be used with <ulink
    url="http://code.google.com/p/guiceyfruit/">GuiceyFruit</ulink>, a set of
    extensions on top of Guice 2.0, such as support for Java EE artifacts like
    <code>@PostConstruct</code>/<code>@PreDestroy</code>,
    <code>@Resource</code> and <code>@PersistenceContext</code>. To avail of
    GuiceyFruit features exclude the guice dependency from the maven central
    repo and add the following:</para>

    <para><programlisting language="xml">&lt;dependency&gt;
    &lt;groupId&gt;org.guiceyfruit&lt;/groupId&gt;
    &lt;artifactId&gt;guiceyfruit&lt;/artifactId&gt;
    &lt;version&gt;2.0&lt;/version&gt;
&lt;/dependency&gt;
...
&lt;repository&gt;
    &lt;id&gt;guice-maven&lt;/id&gt;
    &lt;name&gt;guice maven&lt;/name&gt;
    &lt;url&gt;<ulink
          url="http://guiceyfruit.googlecode.com/svn/repo/releases/">http://guiceyfruit.googlecode.com/svn/repo/releases/</ulink>&lt;/url&gt;
&lt;/repository&gt;</programlisting></para>
  </section>

  <section>
    <title>Jersey Test Framework</title>

    <para><emphasis>NOTE that breaking changes have occurred between 1.1.1-ea
    and 1.1.2-ea. See the end of this section for details.</emphasis></para>

    <para>Jersey Test Framework allows you to test your RESTful Web Services
    on a wide range of containers. It supports light-weight containers such as
    Grizzly, Embedded GlassFish, and the Light Weight HTTP Server in addition
    to regular web containers such as GlassFish and Tomcat. Developers may
    plug in their own containers.</para>

    <para>A developer may write tests using the Junit 4.x framework can extend
    from the abstract <ulink
    url="http://jersey.java.net/nonav/apidocs/&version;/jersey-test-framework/jersey-test-framework-core/com/sun/jersey/test/framework/JerseyTest.html">JerseyTest</ulink>
    class.</para>

    <para>Maven developers require a dependency on the <ulink url="http://maven.java.net/service/local/artifact/maven/redirect?r=&repository;&amp;g=com.sun.jersey.jersey-test-framework&amp;a=jersey-test-framework-grizzly&amp;v=&version;&amp;e=pom">jersey-test-framework-grizzly</ulink>
    module. The following dependency needs to be added to the pom:
    <programlisting language="xml">&lt;dependency&gt;
    &lt;groupId&gt;com.sun.jersey.jersey-test-framework&lt;/groupId&gt;
    &lt;artifactId&gt;jersey-test-framework-grizzly&lt;/artifactId&gt;
    &lt;version&gt;&version;&lt;/version&gt;
    &lt;scope&gt;test&lt;/scope&gt;
&lt;/dependency&gt;</programlisting></para>

    <para>When utilizing an embedded container this framework can manage
    deployment and testing of your web services. However, the framework
    currently doesn't support instantiating and deploying on external
    containers.</para>

    <para>The test framework provides the following test container factories:
    <itemizedlist>
        <listitem>
          <code>com.sun.jersey.test.framework.spi.container.http.HTTPContainerFactory</code>

           for testing with the Light Weight HTTP server.
        </listitem>

        <listitem>
          <code>com.sun.jersey.test.framework.spi.container.inmemory.InMemoryTestContainerFactory</code>

           for testing in memory without using HTTP.
        </listitem>

        <listitem>
          <code>com.sun.jersey.test.framework.spi.container.grizzly.GrizzlyTestContainerFactory</code>

           for testing with low-level Grizzly.
        </listitem>

        <listitem>
          <code>com.sun.jersey.test.framework.spi.container.grizzly.web.GrizzlyWebTestContainerFactory</code>

           for testing with Web-based Grizzly.
        </listitem>

         <listitem>
          <code>com.sun.jersey.test.framework.spi.container.grizzly2.GrizzlyTestContainerFactory</code>

           for testing with low-level Grizzly2.
        </listitem>

        <listitem>
          <code>com.sun.jersey.test.framework.spi.container.grizzly2.web.GrizzlyWebTestContainerFactory</code>

           for testing with Web-based Grizzly2.
        </listitem>

        <listitem>
          <code>com.sun.jersey.test.framework.spi.container.embedded.glassfish.EmbeddedGlassFishTestContainerFactory</code>

           for testing with embedded GlassFish v3
        </listitem>

        <listitem>
          <code>com.sun.jersey.test.framework.spi.container.external.ExternalTestContainerFactory</code>

           for testing with application deployed externally, for example to GlassFish or Tomcat. 
        </listitem>
      </itemizedlist></para>

    <para>The system property <code>jersey.test.containerFactory</code> is
    utilized to declare the default test container factory that shall be used
    for testing, the value of which is the fully qualified class name of a
    test container factory class. If the property is not declared then the
    GrizzlyWebTestContainerFactory is utilized as default test container
    factory.</para>

    <para>To test a maven-based web project with an external container such as
    GlassFish, create the war file then deploy as follows (assuming that the
    pom file is set up for deployment): <programlisting>mvn clean package -Dmaven.test.skip=true
</programlisting> Then execute the tests as follows: <programlisting>mvn test \ -Djersey.test.containerFactory=com.sun.jersey.test.framework.spi.container.embedded.glassfish.external.ExternalTestContainerFactory \
-DJERSEY_HTTP_PORT=&lt;HTTP_PORT&gt;
</programlisting></para>

    <para><emphasis>Breaking changes from 1.1.1-ea to
    1.1.2-ea</emphasis></para>

    <para>The maven project groupId has changed from
    <code>com.sun.jersey.test.framework</code> to
    <code>com.sun.jersey</code></para>

    <para>The extending of Jersey unit test and configuration has changed. See
    <ulink
    url="http://jersey.java.net/nonav/apidocs/&version;/jersey-test-framework/jersey-test-framework-core/com/sun/jersey/test/framework/package-summary.html">here</ulink>
    for an example.</para>

    <para>See the blog entry on <ulink
    url="http://blogs.oracle.com/naresh/entry/jersey_test_framework_makes_it">Jersey
    Test Framework</ulink> for detailed instructions on how to use 1.1.1-ea
    version of the framework in your application.</para>
  </section>
</chapter>
Terms of Use; Privacy Policy; Copyright ©2013-2017 (revision 20160708.bf2ac18)
 
 
Close
loading
Please Confirm
Close