-
Notifications
You must be signed in to change notification settings - Fork 888
/
Installation_Configuration.xml
executable file
·805 lines (759 loc) · 33.2 KB
/
Installation_Configuration.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
<chapter id="Installation_Configuration">
<title>Installation/Configuration</title>
<para>
RESTEasy is installed and configured in different ways depending on which environment you are running in.
If you are running in JBoss AS 6-M4 (milestone 4) or higher, resteasy is already bundled and integrated
completely
so there is very little you have to do. If you are running in a different distribution, there is some manual
installation and configuration you will have to do.
</para>
<section id="upgrading-as7">
<title>Upgrading Resteasy Within JBoss AS 7</title>
<para>
Resteasy is bundled with JBoss AS 7. You will likely have the need to upgrade Resteasy in AS7. The Resteasy
distribution comes with a zip file called resteasy-jboss-modules-3.0.7.Final.zip. Unzip this file while
with the modules/ directory of the JBoss AS7 distribution. This will overwrite some of the existing files there.
</para>
</section>
<section id="upgrading-eap61">
<title>Upgrading Resteasy Within JBoss EAP 6.1</title>
<para>
Resteasy is bundled with JBoss EAP 6.1. You will likely have the need to upgrade Resteasy in JBoss EAP 6.1. The Resteasy
distribution comes with a zip file called resteasy-jboss-modules-3.0.7.Final.zip. Unzip this file while
with the modules/system/layers/base/ directory of the JBoss EAP 6.1 distribution. This will overwrite some of the existing files there.
</para>
</section>
<section id="upgrading-wildfly">
<title>Upgrading Resteasy Within Wildfly</title>
<para>
Resteasy is bundled with Wildfly. You will likely have the need to upgrade Resteasy in Wildfly. The Resteasy
distribution comes with a zip file called resteasy-jboss-modules-wf8-3.0.7.Final.zip. Unzip this file while
with the modules/system/layers/base/ directory of the Wildfly distribution. This will overwrite some of the existing files there.
</para>
</section>
<section>
<title>Configuring in JBoss AS 7, EAP, and Wildfly</title>
<para>
RESTEasy is bundled with JBoss/Wildfly and completely integrated as per the requirements of Java EE 6.
First you must at least provide an empty web.xml file. You can of course deploy any custom servlet, filter
or security constraint you want to within your web.xml, but the least amount of work is to create an empty
web.xml file. Also, resteasy context-params are available if you want to tweak turn on/off any specific
resteasy feature.
</para>
<para>
<programlisting>
<![CDATA[
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
</web-app>
]]>
</programlisting>
</para>
<para>
Since we're not using a jax-rs servlet mapping, we must define an Application class that is annotated with
the @ApplicationPath annotation. If you return any empty set for by classes and singletons, your WAR will
be scanned for JAX-RS annotation resource and provider classes.
</para>
<programlisting>
import javax.ws.rs.ApplicationPath;
import javax.ws.rs.core.Application;
@ApplicationPath("/root-path")
public class MyApplication extends Application
{
}
</programlisting>
<para>
The Resteasy distribution has ported the "Restful Java" O'Reilly workbook examples to AS7. You can
find these under the directory examples/oreilly-workbook-as7.
</para>
<section>
<title>Resteasy Modules in AS7, EAP6.1, Wildfly</title>
<para>
Resteasy and JAX-RS are automically loaded into your deployment's classpath, if and only if you are deploying
a JAX-RS Application. If you only want to use the client library, you will have to create a dependency
for it within your deployment. Also, only some resteasy features are automatically loaded. To bring
in these libraries, you'll have to create a jboss-deployment-structure.xml file within your WEB-INF
directory of your WAR file. Here's an example:
</para>
<programlisting>
<![CDATA[
<jboss-deployment-structure>
<deployment>
<dependencies>
<module name="org.jboss.resteasy.resteasy-yaml-provider" services="import"/>
</dependencies>
</deployment>
</jboss-deployment-structure>]]>
</programlisting>
<para>The <literal>services</literal> attribute must be set to import for modules that have default providers
that must be registered. The following
table specifies which modules are loaded by default when JAX-RS services are deployed and which aren't.
</para>
<para>
<table>
<tgroup cols="3" rowsep="1" colsep="1">
<thead>
<row>
<entry>
Module Name
</entry>
<entry>
Loaded by Default
</entry>
<entry>
Description
</entry>
</row>
</thead>
<tbody>
<row>
<entry>
org.jboss.resteasy.resteasy-jaxrs
</entry>
<entry>
yes
</entry>
<entry>
Core resteasy libraries for server and client. You will need to include this in your deployment
if you are only using JAX-RS client
</entry>
</row>
<row>
<entry>
org.jboss.resteasy.resteasy-cdi
</entry>
<entry>
yes
</entry>
<entry>
Resteasy CDI integration
</entry>
</row>
<row>
<entry>
org.jboss.resteasy.resteasy-jaxb-provider
</entry>
<entry>
yes
</entry>
<entry>
XML JAXB integration.
</entry>
</row>
<row>
<entry>
org.jboss.resteasy.resteasy-atom-provider
</entry>
<entry>
yes
</entry>
<entry>
Resteasy's atom library.
</entry>
</row>
<row>
<entry>
org.jboss.resteasy.resteasy-jackson-provider
</entry>
<entry>
yes
</entry>
<entry>
Integration with the JSON parser and object mapper, Jackson.
</entry>
</row>
<row>
<entry>
org.jboss.resteasy.resteasy-jsapi
</entry>
<entry>
yes
</entry>
<entry>
Resteasy's Javascript API.
</entry>
</row>
<row>
<entry>
org.jboss.resteasy.resteasy-multipart-provider
</entry>
<entry>
yes
</entry>
<entry>
Features for dealing with multipart formats.
</entry>
</row>
<row>
<entry>
org.jboss.resteasy.resteasy-crypto
</entry>
<entry>
no
</entry>
<entry>
S/MIME, DKIM, and support for other security formats.
</entry>
</row>
<row>
<entry>
org.jboss.resteasy.jose-jwt
</entry>
<entry>
no
</entry>
<entry>
JOSE-JWT library. JSON Web Token.
</entry>
</row>
<row>
<entry>
org.jboss.resteasy.resteasy-jettison-provider
</entry>
<entry>
no
</entry>
<entry>
Alternative JAXB-like parser for JSON.
</entry>
</row>
<row>
<entry>
org.jboss.resteasy.resteasy-yaml-provider
</entry>
<entry>
no
</entry>
<entry>
YAML marshalling.
</entry>
</row>
<row>
<entry>
org.jboss.resteasy.skeleton-key
</entry>
<entry>
no
</entry>
<entry>
OAuth2 support for AS7.
</entry>
</row>
</tbody>
</tgroup>
</table>
</para>
</section>
</section>
<section>
<title>Standalone Resteasy in Servlet 3.0 Containers</title>
<para>
If you are using resteasy outside of JBoss/Wildfly, in a standalone servlet container like Tomcat or Jetty
you will need to include the core Resteasy jars in your WAR file. Resteasy provides integration with standalone
Servlet 3.0 containers via the <literal>ServletContainerInitializer</literal> integration interface. To
use this, you must also include the <literal>resteasy-servlet-initializer</literal> artifact in your WAR
file as well.
</para>
<programlisting>
<![CDATA[
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-servlet-initializer</artifactId>
<version>3.0.7.Final</version>
</dependency>
]]>
</programlisting>
<para>
We strongly suggest that you
use Maven to build your WAR files as RESTEasy is split into
a bunch of different modules. You can see an example Maven project in one of the examples in the examples/
directory.
If you are not using Maven,when you download RESTeasy and unzip it you will see a lib/ directory that contains the libraries
needed by resteasy.
Copy these into your /WEB-INF/lib directory. Place your JAX-RS annotated class resources and providers
within
one or more jars within /WEB-INF/lib or your raw class files within /WEB-INF/classes.
</para>
</section>
<section>
<title>Standalone Resteasy in Older Servlet Containers</title>
<para>
The <literal>resteasy-servlet-initializer</literal> artifact will not work in Servlet versions older than
3.0. You'll then have to manually declare the Resteasy servlet in your WEB-INF/web.xml file of your WAR project.
For example:
</para>
<para>
<programlisting>
<![CDATA[
<web-app>
<display-name>Archetype Created Web Application</display-name>
<servlet>
<servlet-name>Resteasy</servlet-name>
<servlet-class>
org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher
</servlet-class>
<init-param>
<param-name>javax.ws.rs.Application</param-name>
<param-value>com.restfully.shop.services.ShoppingApplication</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>Resteasy</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
</web-app>
]]>
</programlisting>
</para>
<para>
The Resteasy servlet is responsible for initializing some basic components of RESTeasy.
</para>
</section>
<section>
<title>Configuration Switches</title>
<para>Resteasy receives configuration options from <context-param> elements.</para>
<para>
<table frame="topbot">
<tgroup cols="3" rowsep="1" colsep="1">
<thead>
<row>
<entry>
Option Name
</entry>
<entry>
Default Value
</entry>
<entry>
Description
</entry>
</row>
</thead>
<tbody>
<row>
<entry>
resteasy.servlet.mapping.prefix
</entry>
<entry>
no default
</entry>
<entry>
If the url-pattern for the Resteasy servlet-mapping is not /*
</entry>
</row>
<row>
<entry>
resteasy.scan
</entry>
<entry>
false
</entry>
<entry>
Automatically scan WEB-INF/lib jars and WEB-INF/classes directory for both @Provider and
JAX-RS resource classes (@Path, @GET, @POST etc..) and register them
</entry>
</row>
<row>
<entry>
resteasy.scan.providers
</entry>
<entry>
false
</entry>
<entry>
Scan for @Provider classes and register them
</entry>
</row>
<row>
<entry>
resteasy.scan.resources
</entry>
<entry>
false
</entry>
<entry>
Scan for JAX-RS resource classes
</entry>
</row>
<row>
<entry>
resteasy.providers
</entry>
<entry>
no default
</entry>
<entry>
A comma delimited list of fully qualified @Provider class names you want to register
</entry>
</row>
<row>
<entry>
resteasy.use.builtin.providers
</entry>
<entry>
true
</entry>
<entry>
Whether or not to register default, built-in @Provider classes. (Only available in
1.0-beta-5 and later)
</entry>
</row>
<row>
<entry>
resteasy.resources
</entry>
<entry>
no default
</entry>
<entry>
A comma delimited list of fully qualified JAX-RS resource class names you want to
register
</entry>
</row>
<row>
<entry>
resteasy.jndi.resources
</entry>
<entry>
no default
</entry>
<entry>
A comma delimited list of JNDI names which reference objects you want to register as
JAX-RS resources
</entry>
</row>
<row>
<entry>
javax.ws.rs.Application
</entry>
<entry>
no default
</entry>
<entry>
Fully qualified name of Application class to bootstrap in a spec portable way
</entry>
</row>
<row>
<entry>
resteasy.media.type.mappings
</entry>
<entry>
no default
</entry>
<entry>
Replaces the need for an Accept header by mapping file name extensions (like .xml or
.txt) to a media type. Used when the client
is unable to use a Accept header to choose a representation (i.e. a browser). See JAX-RS
Content Negotiation chapter for more details.
</entry>
</row>
<row>
<entry>
resteasy.language.mappings
</entry>
<entry>
no default
</entry>
<entry>
Replaces the need for an Accept-Language header by mapping file name extensions (like
.en or .fr) to a language. Used when the client
is unable to use a Accept-Language header to choose a language (i.e. a browser). See
JAX-RS Content Negotiation chapter for more details
</entry>
</row>
<row>
<entry>
resteasy.document.expand.entity.references
</entry>
<entry>
true
</entry>
<entry>
Expand external entities in org.w3c.dom.Document files
</entry>
</row>
<row>
<entry>
resteasy.wider.request.matching
</entry>
<entry>
true
</entry>
<entry>
Turns off the JAX-RS spec defined class-level expression filtering and instead
tries to match version every method's full path.
</entry>
</row>
<row>
<entry>
resteasy.use.container.form.params
</entry>
<entry>
true
</entry>
<entry>
Will use the HttpServletRequest.getParameterMap() method to obtain form parameters.
Use this switch if you are calling this method within a servlet filter or eating
the input stream within the filter.
</entry>
</row>
</tbody>
</tgroup>
</table>
</para>
<para>
The resteasy.servlet.mapping.prefix <context param> variable must be set if your servlet-mapping for
the Resteasy servlet has a url-pattern other than /*. For example, if the url-pattern is
</para>
<para>
<programlisting>
<servlet-mapping>
<servlet-name>Resteasy</servlet-name>
<url-pattern>/restful-services/*</url-pattern>
</servlet-mapping>
</programlisting>
</para>
<para>
Then the value of resteasy-servlet.mapping.prefix must be:
</para>
<para>
<programlisting>
<context-param>
<param-name>resteasy.servlet.mapping.prefix</param-name>
<param-value>/restful-services</param-value>
</context-param>
</programlisting>
</para>
</section>
<section id="javax.ws.rs.core.Application">
<title>javax.ws.rs.core.Application</title>
<para>
The javax.ws.rs.core.Application class is a standard JAX-RS class that you may implement to provide
information on your deployment. It is simply a class the lists all JAX-RS root resources and providers.
</para>
<para>
<programlisting>
/**
* Defines the components of a JAX-RS application and supplies additional
* metadata. A JAX-RS application or implementation supplies a concrete
* subclass of this abstract class.
*/
public abstract class Application
{
private static final Set<Object> emptySet = Collections.emptySet();
/**
* Get a set of root resource and provider classes. The default lifecycle
* for resource class instances is per-request. The default lifecycle for
* providers is singleton.
* <p/>
* <p>Implementations should warn about and ignore classes that do not
* conform to the requirements of root resource or provider classes.
* Implementations should warn about and ignore classes for which
* {@link #getSingletons()} returns an instance. Implementations MUST
* NOT modify the returned set.</p>
*
* @return a set of root resource and provider classes. Returning null
* is equivalent to returning an empty set.
*/
public abstract Set<Class<?>> getClasses();
/**
* Get a set of root resource and provider instances. Fields and properties
* of returned instances are injected with their declared dependencies
* (see {@link Context}) by the runtime prior to use.
* <p/>
* <p>Implementations should warn about and ignore classes that do not
* conform to the requirements of root resource or provider classes.
* Implementations should flag an error if the returned set includes
* more than one instance of the same class. Implementations MUST
* NOT modify the returned set.</p>
* <p/>
* <p>The default implementation returns an empty set.</p>
*
* @return a set of root resource and provider instances. Returning null
* is equivalent to returning an empty set.
*/
public Set<Object> getSingletons()
{
return emptySet;
}
}
</programlisting>
</para>
<para>
</para>
<para>
To use Application you must set a servlet init-param, javax.ws.rs.Application with a fully qualified class
that implements Application. For example:
</para>
<para>
<programlisting> <![CDATA[
<servlet>
<servlet-name>Resteasy</servlet-name>
<servlet-class>
org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher
</servlet-class>
<init-param>
<param-name>javax.ws.rs.Application</param-name>
<param-value>com.restfully.shop.services.ShoppingApplication</param-value>
</init-param>
</servlet> ]]> </programlisting>
</para>
<para>
If you have this set, you should probably turn off automatic scanning as this will probably result in
duplicate classes being registered.
</para>
<para>
</para>
</section>
<section id="listener">
<title>RESTEasy as a ServletContextListener</title>
<para>
This section is pretty much deprecated if you are using a Servlet 3.0 container or higher. Skip it if
you are and read the configuration section above on installing in Servlet 3.0.
The initialization of RESTEasy can be performed within a ServletContextListener instead of within the
Servlet. You may need this if you are writing custom Listeners that need to interact with RESTEasy at boot
time. An example of this is the RESTEasy Spring integration that requires a Spring ServletContextListener.
The org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap class is a ServletContextListener that
configures an instance of an ResteasyProviderFactory and Registry. You can obtain instances of a
ResteasyProviderFactory and Registry from the ServletContext attributes
org.jboss.resteasy.spi.ResteasyProviderFactory and org.jboss.resteasy.spi.Registry. From these instances you
can programmatically interact with RESTEasy registration interfaces.
</para>
<programlisting>
<![CDATA[
<web-app>
<listener>
<listener-class>
org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap
</listener-class>
</listener>
<!-- ** INSERT YOUR LISTENERS HERE!!!! -->
<servlet>
<servlet-name>Resteasy</servlet-name>
<servlet-class>
org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher
</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Resteasy</servlet-name>
<url-pattern>/resteasy/*</url-pattern>
</servlet-mapping>
</web-app>
]]>
</programlisting>
</section>
<section id="filter">
<title>RESTEasy as a servlet Filter</title>
<para>
This section is pretty much deprecated if you are using a Servlet 3.0 container or higher. Skip it if
you are and read the configuration section above on installing in Servlet 3.0.
The downside of running Resteasy as a Servlet is that you cannot have static resources like .html and .jpeg
files in the
same path as your JAX-RS services. Resteasy allows you to run as a Filter instead. If a JAX-RS resource is
not
found under the URL requested, Resteasy will delegate back to the base servlet container to resolve URLs.
</para>
<programlisting>
<![CDATA[
<web-app>
<filter>
<filter-name>Resteasy</filter-name>
<filter-class>
org.jboss.resteasy.plugins.server.servlet.FilterDispatcher
</filter-class>
<init-param>
<param-name>javax.ws.rs.Application</param-name>
<param-value>com.restfully.shop.services.ShoppingApplication</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>Resteasy</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>]]>
</programlisting>
</section>
<section id="RESTEasyLogging">
<title>RESTEasyLogging</title>
<para>
RESTEasy supports logging via java.util.logging, Log4j, or Slf4j. How it picks which framework to delegate to is
expressed in the following algorithm:
</para>
<itemizedlist>
<listitem>
<para>If log4j is in the application's classpath, log4j will be used</para>
</listitem>
<listitem>
<para>If slf4j is in the application's classpath, slf4j will be used</para>
</listitem>
<listitem>
<para>java.util.logging is the default if neither log4j or slf4j is in the classpath</para>
</listitem>
<listitem>
<para>If the servlet context param resteasy.logger.type is set to JUL, LOG4J, or SLF4J will override this default behavior</para>
</listitem>
</itemizedlist>
<para>
The logging categories are still a work in progress, but the initial set should make it easier to
troubleshoot issues. Currently, the framework has defined the following log categories:
</para>
<para>
<table frame="topbot">
<tgroup cols="2" rowsep="1" colsep="1">
<thead>
<row>
<entry>
Category
</entry>
<entry>
Function
</entry>
</row>
</thead>
<tbody>
<row>
<entry>
org.jboss.resteasy.core
</entry>
<entry>
Logs all activity by the core RESTEasy implementation
</entry>
</row>
<row>
<entry>
org.jboss.resteasy.plugins.providers
</entry>
<entry>
Logs all activity by RESTEasy entity providers
</entry>
</row>
<row>
<entry>
org.jboss.resteasy.plugins.server
</entry>
<entry>
Logs all activity by the RESTEasy server implementation.
</entry>
</row>
<row>
<entry>
org.jboss.resteasy.specimpl
</entry>
<entry>
Logs all activity by JAX-RS implementing classes
</entry>
</row>
<row>
<entry>
org.jboss.resteasy.mock
</entry>
<entry>
Logs all activity by the RESTEasy mock framework
</entry>
</row>
</tbody>
</tgroup>
</table>
</para>
</section>
</chapter>