-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathindex.html
936 lines (936 loc) · 52.9 KB
/
index.html
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
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>
Weld: Documentation
</title>
<meta content="width=device-width, initial-scale=1.0" name="viewport">
<meta content="FAQ, Links to Weld documentation" name="description">
<link href="/images/weld_icon_32x.ico" rel="shortcut icon" type="image/x-icon">
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" type="text/css">
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css" rel="stylesheet" type="text/css">
<link href="//static.jboss.org/css/tabzilla.css" media="screen" rel="stylesheet" type="text/css">
<link href="https://weld.cdi-spec.org/stylesheets/styles.css" rel="stylesheet" type="text/css">
<script src="//static.jboss.org/theme/js/libs/jquery/jquery-1.9.1.min.js" type="text/javascript"></script>
<script src="//static.jboss.org/js/_jbossorg-tabzilla.js" type="text/javascript"></script>
<!--[if lt IE 9]>
<script src="//html5shim.googlecode.com/svn/trunk/html5.js" type="text/javascript"></script>
<![endif]-->
<link href="https://weld.cdi-spec.org/news.atom" rel="alternate" type="application/atom+xml">
<link href="//cdn.jsdelivr.net/highlight.js/8.9.1/styles/hybrid.min.css" rel="stylesheet">
<script src="//cdn.jsdelivr.net/highlight.js/8.9.1/highlight.min.js" type="text/javascript"></script>
<script>
hljs.initHighlightingOnLoad();
</script>
</head>
<body>
<div class="container-fluid">
<div class="row">
<div class="col-md-2 col-sm-3">
<div class="sidebar-nav">
<div class="navbar navbar-default" role="navigation">
<div class="navbar-header">
<button ="button" class="navbar-toggle" data-target=".sidebar-navbar-collapse" data-toggle="collapse">
<span class="sr-only">
Toggle navigation
</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a ="#" class="visible-xs navbar-brand">
<img alt="Weld Logo" src="/images/weld_logo_100x.png">
</a>
</div>
<div class="collapse navbar-collapse sidebar-navbar-collapse">
<ul class="nav navbar-nav">
<li>
<a href="/">
<i class="fa fa-home"></i>
Home
</a>
</li>
<li>
<a href="/download">
<i class="fa fa-download"></i>
Download
</a>
</li>
<li>
<a href="/news">
<i class="fa fa-newspaper-o"></i>
News
</a>
</li>
<li>
<a href="https://issues.jboss.org/projects/WELD?selectedItem=com.atlassian.jira.jira-projects-plugin:release-page" target="_blank">
<i class="fa fa-road"></i>
Road Map
</a>
</li>
<li>
<a href="/documentation">
<i class="fa fa-book"></i>
Docs & FAQ
</a>
</li>
<li>
<a href="/news/tags/tips">
<i class="fa fa-lightbulb-o"></i>
Tips and Tricks
</a>
</li>
<li>
<a href="/community">
<i class="fa fa-group"></i>
Community
</a>
</li>
<li>
<a href="http://github.com/weld" target="_blank">
<i class="fa fa-github-alt"></i>
Source Code
</a>
</li>
<li>
<a href="https://issues.jboss.org/browse/WELD#selectedTab=com.atlassian.jira.plugin.system.project%3Asummary-panel" target="_blank">
<i class="fa fa-tasks"></i>
Bug Tracker
</a>
</li>
<li>
<a href="https://twitter.com/jbossweld" target="_blank">
<i class="fa fa-twitter"></i>
Follow @jbossweld
</a>
</li>
</ul>
</div>
</div>
</div>
</div>
<div class="col-md-10 col-sm-9">
<div class="row hidden-xs">
<div class="dropup">
<div id="ajbossproject">
A JBoss Project
</div>
<a class="tabnav-closed" href="#" id="tab">Red Hat</a>
<script>
window.addEventListener('load', function() {renderTabzilla("Weld", "weld", false )}, false);
</script>
</div>
</div>
<div class="row">
<div class="col-md-4">
<a href="/">
<img alt="Weld Logo" class="hidden-xs weld-home-logo" src="/images/weld_logo_450x.png">
</a>
</div>
<div class="col-md-8">
<img alt="CDI tagcloud" class="hidden-xs hidden-sm cdi-background" src="/images/CDIbackground.png">
</div>
</div>
<div class="row content-wrapper">
<div class="col-md-12">
<h1>Documentation</h1>
<p>Weld reference documentation can be viewed online or downloaded as a PDF.</p>
<ul>
<li>
The latest Weld 6 version:
<ul>
<li>
<a href="http://docs.jboss.org/weld/reference/latest/en-US/html_single/" target="_blank">HTML (Single page)</a>
</li>
<li>
<a href="http://docs.jboss.org/weld/reference/latest/en-US/pdf/weld-reference.pdf" target="_blank">PDF</a>
</li>
</ul>
</li>
<li>
The latest Weld 5 version:
<ul>
<li>
<a href="http://docs.jboss.org/weld/reference/latest-5.1/en-US/html_single/" target="_blank">HTML (Single page)</a>
</li>
<li>
<a href="http://docs.jboss.org/weld/reference/latest-5.1/en-US/pdf/weld-reference.pdf" target="_blank">PDF</a>
</li>
</ul>
</li>
<li>
The latest Weld 4 version:
<ul>
<li>
<a href="http://docs.jboss.org/weld/reference/latest-4.0/en-US/html_single/" target="_blank">HTML (Single page)</a>
</li>
<li>
<a href="http://docs.jboss.org/weld/reference/latest-4.0/en-US/pdf/weld-reference.pdf" target="_blank">PDF</a>
</li>
</ul>
</li>
<li>
The latest Weld 3 version:
<ul>
<li>
<a href="http://docs.jboss.org/weld/reference/latest-3.1/en-US/html_single/" target="_blank">HTML (Single page)</a>
</li>
<li>
<a href="http://docs.jboss.org/weld/reference/latest-3.1/en-US/pdf/weld-reference.pdf" target="_blank">PDF</a>
</li>
</ul>
</li>
<li>
<a href="http://docs.jboss.org/weld/reference/" target="_blank">Browse documentation for older Weld releases</a>
</li>
</ul>
<a name="faq_contents"></a>
<h1>FAQ</h1>
<ul>
<li>
<a href="#0">
If I create a thread in my CDI bean, how will Weld react?
</a>
</li>
<li>
<a href="#1">
Why does Weld leave some proxy class definitions lying around when I undeploy my application? How can I prevent this?
</a>
</li>
<li>
<a href="#2">
Some of my beans aren’t deployed and I can’t see why?
</a>
</li>
<li>
<a href="#3">
Why does Weld set character encoding of an HTTP request/response body to ISO-8859-1?
</a>
</li>
<li>
<a href="#4">
My application bundles a third-party library which uses javax.inject annotations. This library was not intended to be a CDI library but on CDI 1.1 this library is being picked up as an implicit bean archive and breaks the deployment of my application. Why is this happening?
</a>
</li>
<li>
<a href="#5">
How can I bundle my entire SE application with Weld into a single jar?
</a>
</li>
<li>
<a href="#6">
I use the Instance API to obtain bean instances. Why does it seem to cause a memory leak?
</a>
</li>
<li>
<a href="#7">
How do I enable debug logging for Weld in a specific container?
</a>
</li>
<li>
<a href="#8">
What do WELD-000225, WELD-000335 and WELD-000715 warnings mean?
</a>
</li>
<li>
<a href="#9">
What is the relation between Weld, CDI and Java EE versions?
</a>
</li>
<li>
<a href="#10">
How do I enable debug logging for Weld SE?
</a>
</li>
<li>
<a href="#11">
How to deploy a Weld application to a Jetty standalone instance?
</a>
</li>
<li>
<a href="#12">
How to patch WildFly with newer Weld version?
</a>
</li>
<li>
<a href="#13">
What’s the difference between <code>@ApplicationScoped</code> and <code>@Singleton</code>?
</a>
</li>
</ul>
<hr>
<div id="0">
<h2>
If I create a thread in my CDI bean, how will Weld react?
</h2>
<div class="paragraph">
<p>Weld assumes requests are single threaded, and uses thread locals to isolate requests. This means that if user created threads are used then built in implementation of the session scope, the request scope and the conversation scope, will become dissociated, and you will find they are no longer active in the new thread, nor able to access their contextual data. The Weld <a href="http://docs.jboss.org/weld/reference/latest/en-US/html/contexts.html">reference guide</a> contains information on how to associate a request to a context and activate it. Doing this in your new thread will cause the contexts to be active, and contain the same contextual data.</p>
</div>
<div class="paragraph">
<p>The dependent context and the application context will work as usual in any user created thread.</p>
</div>
<a href="#faq_contents">
<i class="fa fa-arrow-circle-o-up fa-lg"></i>
Top
</a>
<hr>
</div>
<div id="1">
<h2>
Why does Weld leave some proxy class definitions lying around when I undeploy my application? How can I prevent this?
</h2>
<div class="paragraph">
<p>When a Weld-enabled application is deployed on an application server or a web server, proxy classes for beans implementing interfaces or extending classes contained in common libraries are loaded in the class loader (CL) for that library, not the thread context class loader (TCCL). This means that these proxy classes will not be removed from the server when the application is undeployed.</p>
</div>
<div class="paragraph">
<p>The reason for this approach is to support the use of package scoped classes and members of classes which need to be proxied as beans. Thus the TCCL is not used for the proxy classes generated by Weld.</p>
</div>
<div class="paragraph">
<p>One way to prevent this problem is to simply deploy those libraries with your application. In this scenario, those classes are loaded in a CL associated with the application and will thus be removed when the application is undeployed.</p>
</div>
<a href="#faq_contents">
<i class="fa fa-arrow-circle-o-up fa-lg"></i>
Top
</a>
<hr>
</div>
<div id="2">
<h2>
Some of my beans aren’t deployed and I can’t see why?
</h2>
<div class="paragraph">
<p>Weld will not create beans if it can’t load the class, or some class dependency. If that happens, you’ll see a note in the server log.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code>WELD-000119: Not generating any bean definitions from org.jboss.weld.tests.beanDeployment.noclassdeffound.Bar because of underlying class loading error</code></pre>
</div>
</div>
<div class="paragraph">
<p>You can view more details by increasing the log level of the application server to DEBUG.</p>
</div>
<a href="#faq_contents">
<i class="fa fa-arrow-circle-o-up fa-lg"></i>
Top
</a>
<hr>
</div>
<div id="3">
<h2>
Why does Weld set character encoding of an HTTP request/response body to ISO-8859-1?
</h2>
<div class="paragraph">
<p><strong>Update</strong>: Since Weld 2.2 the conversation context is activated lazily and this problem does not occur.
If you are using an older version of Weld or need the conversation context to be activated eagerly, read further.</p>
</div>
<div class="paragraph">
<p>An application may set character encoding of a request by calling the <a href="http://docs.oracle.com/javaee/6/api/javax/servlet/ServletRequest.html#setCharacterEncoding(java.lang.String)">ServletRequest.setCharacterEncoding()</a> method. This method has a limitation: it has to be called before the request parameters or request body are read, otherwise the method call has no effect.</p>
</div>
<div class="paragraph">
<p>In order to properly activate the conversation context, Weld reads the <em>cid</em> request parameter in the beginning of request processing (see <a href="http://docs.jboss.org/cdi/spec/1.1/cdi-spec.html#conversation_context">the CDI spec for details</a>). As a side-effect, this makes it impossible to change the character encoding later in the request processing (since request parameters have been read already). As a result, an application servlet or filter that tries to set character encoding will not work since it does that too late.</p>
</div>
<div class="paragraph">
<p>A workaround is to have the application encoding-setting filter to be called before Weld tries to read the "cid" parameter in the ConversationFilter. This can be done by mapping the custom filter <em>before</em> Weld’s ConversationFilter in web.xml</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-xml" data-lang="xml"><web-app 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" version="3.0">
 <filter>
 <filter-name>SetCharacterEncoding</filter-name>
 <filter-class>org.apache.catalina.filters.SetCharacterEncodingFilter</filter-class>
 <init-param>
 <param-name>encoding</param-name>
 <param-value>UTF-8</param-value>
 </init-param>
 <init-param>
 <param-name>ignore</param-name>
 <param-value>false</param-value>
 </init-param>
 </filter>
 <filter-mapping>
 <filter-name>SetCharacterEncoding</filter-name>
 <url-pattern>/*</url-pattern>
 </filter-mapping>
 <filter-mapping>
 <filter-name>CDI Conversation Filter</filter-name>
 <url-pattern>/*</url-pattern>
 </filter-mapping>
</web-app></code></pre>
</div>
</div>
<a href="#faq_contents">
<i class="fa fa-arrow-circle-o-up fa-lg"></i>
Top
</a>
<hr>
</div>
<div id="4">
<h2>
My application bundles a third-party library which uses javax.inject annotations. This library was not intended to be a CDI library but on CDI 1.1 this library is being picked up as an implicit bean archive and breaks the deployment of my application. Why is this happening?
</h2>
<div class="paragraph">
<p>Firstly, this issue only affects CDI 1.1. If possible, go and upgrade to CDI 1.2 (Weld 2.2 or later) where this issue does not occur.</p>
</div>
<div class="paragraph">
<p>If you cannot do that, read further:
This is a <a href="https://issues.jboss.org/browse/CDI-377">known issue</a> in the CDI 1.1 specification and occurs with third-party libraries such as <a href="https://code.google.com/p/guava-libraries/issues/detail?id=1433">Guava</a>.</p>
</div>
<div class="paragraph">
<p>A workaround is to configure the application server to require the beans.xml file in bean archives (suppress implicit bean archives). The way to configure this varies across application servers:</p>
</div>
<div class="paragraph">
<p><strong>GlassFish 4</strong></p>
</div>
<div class="paragraph">
<p>global configuration:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code>asadmin set configs.config.server-config.cdi-service.enable-implicit-cdi=false</code></pre>
</div>
</div>
<div class="paragraph">
<p>per-deployment configuration:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code>asadmin deploy --property implicitCdiEnabled=false <archive></code></pre>
</div>
</div>
<div class="paragraph">
<p><strong>WildFly 8</strong></p>
</div>
<div class="paragraph">
<p>global configuration:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code>/subsystem=weld:write-attribute(name=require-bean-descriptor,value=true)</code></pre>
</div>
</div>
<div class="paragraph">
<p>per-deployment configuration - add the following content to META-INF/jboss-all.xml of the application</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code><jboss xmlns="urn:jboss:1.0">
 <weld xmlns="urn:jboss:weld:1.0" require-bean-descriptor="true"/>
</jboss></code></pre>
</div>
</div>
<a href="#faq_contents">
<i class="fa fa-arrow-circle-o-up fa-lg"></i>
Top
</a>
<hr>
</div>
<div id="5">
<h2>
How can I bundle my entire SE application with Weld into a single jar?
</h2>
<div class="paragraph">
<p>Weld internal classes are not intended to be used in a CDI deployment. As a result, you may <a href="https://issues.jboss.org/browse/WELD-1129">encounter validation errors</a> when packaging your application together with Weld in a single fat jar file.</p>
</div>
<div class="paragraph">
<p>A workaround is to exclude Weld classes from bean scanning:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-xml" data-lang="xml"><beans xmlns="http://xmlns.jcp.org/xml/ns/javaee"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd"
 version="1.1" bean-discovery-mode="all">
 <scan>
 <exclude name="org.jboss.weld.**" />
 </scan>
</beans></code></pre>
</div>
</div>
<a href="#faq_contents">
<i class="fa fa-arrow-circle-o-up fa-lg"></i>
Top
</a>
<hr>
</div>
<div id="6">
<h2>
I use the Instance API to obtain bean instances. Why does it seem to cause a memory leak?
</h2>
<div class="paragraph">
<p>The Instance API is often used in loops to obtain multiple instances of a certain bean. Here is an example:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-java" data-lang="java"> @Inject
 private Instance<A> instance;

 public void foo() {
 // obtain multiple instances of A
 for (;;) {
 instance.get();
 }</code></pre>
</div>
</div>
<div class="paragraph">
<p>By default, each object obtained using Instance remains managed (is not released) until the Instance object is destroyed. This can easily create a memory leak.
Therefore, the application should explicitly destroy obtained instances when it no longer needs by calling the <a href="http://docs.jboss.org/cdi/api/1.1/javax/enterprise/inject/Instance.html#destroy(T)">Instance.destroy()</a> method.</p>
</div>
<a href="#faq_contents">
<i class="fa fa-arrow-circle-o-up fa-lg"></i>
Top
</a>
<hr>
</div>
<div id="7">
<h2>
How do I enable debug logging for Weld in a specific container?
</h2>
<div id="preamble">
<div class="sectionbody">
<div class="paragraph">
<p>When things do not work as expected, more information might be helpful in solving the problem.
For this reason, you might want to enable the debug (fine) log level for Weld.
Each container has its own way to do this:</p>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_wildfly">WildFly</h3>
<div class="paragraph">
<p>(more info: <a href="https://docs.jboss.org/author/display/WFLY8/Logging+Configuration">Logging Configuration - WildFly</a>)</p>
</div>
<div class="paragraph">
<p>global configuration - add the following content to the logging subsystem in $JBOSS_HOME/standalone/configuration/standalone-full.xml</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code><logger category="org.jboss.weld">
 <level name="DEBUG"/>
</logger></code></pre>
</div>
</div>
<div class="paragraph">
<p>per-deployment configuration - add the following line to the logging configuration file (e.g. META-INF/logging.properties) of the application</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code>org.jboss.weld.level=DEBUG</code></pre>
</div>
</div>
<div class="admonitionblock tip">
<table>
<tr>
<td class="icon">
<div class="title">Tip</div>
</td>
<td class="content">
If you want to see the debug messages also in the console, make sure the console handler’s level is set to at least DEBUG.
</td>
</tr>
</table>
</div>
</div>
<div class="sect2">
<h3 id="_wildfly_swarm">WildFly Swarm</h3>
<div class="paragraph">
<p>(more info: <a href="http://docs.wildfly-swarm.io/2017.11.0/#_logging_2">Logging Fraction</a>)</p>
</div>
<div class="paragraph">
<p>run the uberjar with the following system property:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code>-Dswarm.logging.loggers.[org.jboss.weld].level=DEBUG</code></pre>
</div>
</div>
<div class="admonitionblock tip">
<table>
<tr>
<td class="icon">
<div class="title">Tip</div>
</td>
<td class="content">
You can also use categories to filter messages - see also <a href="/news/2016/10/01/tip1-logging/">Weld Tip 1 - Logging</a>.
</td>
</tr>
</table>
</div>
</div>
<div class="sect2">
<h3 id="_glassfish">GlassFish</h3>
<div class="paragraph">
<p>(more info: <a href="http://docs.oracle.com/cd/E19798-01/821-1751/ghgwi/index.html">Setting Log Levels - GlassFish</a>)</p>
</div>
<div class="paragraph">
<p>global configuration - add the following line to _domain-dir_/config/logging.properties</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code>org.jboss.weld.level=FINE</code></pre>
</div>
</div>
<div class="paragraph">
<p><strong>Tomcat</strong> (more info: <a href="http://tomcat.apache.org/tomcat-7.0-doc/logging.html">Logging in Tomcat</a>)</p>
</div>
<div class="paragraph">
<p>global configuration - add the following line to $CATALINA_HOME/conf/logging.properties</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code>org.jboss.weld.level=FINE</code></pre>
</div>
</div>
<div class="paragraph">
<p>per-deployment configuration - add the following line to WEB-INF/classes/logging.properties</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code>org.jboss.weld.level=FINE</code></pre>
</div>
</div>
<div class="paragraph">
<p><strong>Jetty</strong></p>
</div>
<div class="paragraph">
<p>For enabling debug logging on Jetty, see <a href="http://www.eclipse.org/jetty/documentation/current/configuring-logging.html">Jetty Logging</a></p>
</div>
</div>
<a href="#faq_contents">
<i class="fa fa-arrow-circle-o-up fa-lg"></i>
Top
</a>
<hr>
</div>
<div id="8">
<h2>
What do WELD-000225, WELD-000335 and WELD-000715 warnings mean?
</h2>
<div class="paragraph">
<p>When running on Tomcat with asynchronous Servlets you may observe the following warnings:</p>
</div>
<div class="listingblock">
<div class="content">
<pre>WARN: WELD-000225: Bean store leak was detected during org.jboss.weld.context.http.HttpSessionContextImpl association: org.apache.catalina.connector.Request@5d22c824
WARN: WELD-000335: Conversation context is already active, most likely it was not cleaned up properly during previous request processing: org.apache.catalina.connector.Request@5d22c824
WARN: WELD-000715: HttpContextLifecycle guard not set. The Servlet container is not fully compliant.</pre>
</div>
</div>
<div class="paragraph">
<p>A hook exists in the Servlet specification for integrating frameworks such as Weld into a Servlet container.
This hooks is called <code>ServletRequestListener</code>. The problem here is that Tomcat implements these hooks in a different
way than all the other implementations (Undertow, JBoss Web, Jetty and Grizzly).
Tomcat’s implementation does not allow for an integrating framework that uses ThreadLocals (like Weld does) to be used
correctly in asynchronous Servlet requests. As a result, these warnings are observed as Weld is not able to clean up contexts and
bean instances properly at the end of a request. See the <a href="https://issues.apache.org/bugzilla/show_bug.cgi?id=57314">Tomcat bug report</a>
for more details.</p>
</div>
<a href="#faq_contents">
<i class="fa fa-arrow-circle-o-up fa-lg"></i>
Top
</a>
<hr>
</div>
<div id="9">
<h2>
What is the relation between Weld, CDI and Java EE versions?
</h2>
<div class="paragraph">
<p>Weld versions do not match CDI versioning.
An overview is provided in the following table:</p>
</div>
<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 16.6666%;">
<col style="width: 16.6666%;">
<col style="width: 16.6666%;">
<col style="width: 16.6666%;">
<col style="width: 33.3336%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-center valign-top">Weld version</th>
<th class="tableblock halign-center valign-top">CDI version</th>
<th class="tableblock halign-center valign-top">Java version</th>
<th class="tableblock halign-center valign-top">Java EE version</th>
<th class="tableblock halign-right valign-top">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-center valign-top"><p class="tableblock">1.1</p></td>
<td class="tableblock halign-center valign-top"><p class="tableblock">1.0</p></td>
<td class="tableblock halign-center valign-top"><p class="tableblock">6+</p></td>
<td class="tableblock halign-center valign-top"><p class="tableblock">6</p></td>
<td class="tableblock halign-right valign-top"><p class="tableblock">Not actively developed anymore. Support available with <a href="https://developers.redhat.com/products/eap/overview/">JBoss EAP 6</a></p></td>
</tr>
<tr>
<td class="tableblock halign-center valign-top"><p class="tableblock">2.1</p></td>
<td class="tableblock halign-center valign-top"><p class="tableblock">1.1</p></td>
<td class="tableblock halign-center valign-top"><p class="tableblock">6+</p></td>
<td class="tableblock halign-center valign-top"><p class="tableblock">7</p></td>
<td class="tableblock halign-right valign-top"><p class="tableblock">Not actively developed anymore.</p></td>
</tr>
<tr>
<td class="tableblock halign-center valign-top"><p class="tableblock">2.2</p></td>
<td class="tableblock halign-center valign-top"><p class="tableblock">1.2</p></td>
<td class="tableblock halign-center valign-top"><p class="tableblock">6+</p></td>
<td class="tableblock halign-center valign-top"><p class="tableblock">7</p></td>
<td class="tableblock halign-right valign-top"><p class="tableblock">Not actively developed anymore.</p></td>
</tr>
<tr>
<td class="tableblock halign-center valign-top"><p class="tableblock">2.3</p></td>
<td class="tableblock halign-center valign-top"><p class="tableblock">1.2</p></td>
<td class="tableblock halign-center valign-top"><p class="tableblock">7+</p></td>
<td class="tableblock halign-center valign-top"><p class="tableblock">7</p></td>
<td class="tableblock halign-right valign-top"><p class="tableblock">Not actively developed anymore. Support available with <a href="https://developers.redhat.com/products/eap/overview/">JBoss EAP 7.0</a></p></td>
</tr>
<tr>
<td class="tableblock halign-center valign-top" style="background-color: #eee;"><p class="tableblock">2.4</p></td>
<td class="tableblock halign-center valign-top" style="background-color: #eee;"><p class="tableblock">1.2</p></td>
<td class="tableblock halign-center valign-top" style="background-color: #eee;"><p class="tableblock">7+</p></td>
<td class="tableblock halign-center valign-top" style="background-color: #eee;"><p class="tableblock">7</p></td>
<td class="tableblock halign-right valign-top" style="background-color: #eee;"><p class="tableblock">In maintenance mode. Support available with <a href="https://developers.redhat.com/products/eap/overview/">JBoss EAP 7.1</a></p></td>
</tr>
<tr>
<td class="tableblock halign-center valign-top" style="background-color: #7ab6ef;"><p class="tableblock">3.0</p></td>
<td class="tableblock halign-center valign-top" style="background-color: #7ab6ef;"><p class="tableblock">2.0</p></td>
<td class="tableblock halign-center valign-top" style="background-color: #7ab6ef;"><p class="tableblock">8+</p></td>
<td class="tableblock halign-center valign-top" style="background-color: #7ab6ef;"><p class="tableblock">8</p></td>
<td class="tableblock halign-right valign-top" style="background-color: #7ab6ef;"><p class="tableblock">Actively developed and stable version of Weld.</p></td>
</tr>
</tbody>
</table>
<a href="#faq_contents">
<i class="fa fa-arrow-circle-o-up fa-lg"></i>
Top
</a>
<hr>
</div>
<div id="10">
<h2>
How do I enable debug logging for Weld SE?
</h2>
<div class="paragraph">
<p>In Weld 2.1 <a href="http://www.slf4j.org">SLF4J</a> was replaced with <a href="https://developer.jboss.org/wiki/JBossLoggingTooling">JBoss Logging</a> which provides support for the internationalization and localization of log messages and exception messages. However, JBoss Logging itself does not write any log messages. Instead, it only constructs a log message and delegates to one of the supported logging frameworks. And so if you want to enable the debug logging for Weld SE, you’ll have to <strong>identify</strong> and <strong>configure</strong> the underlying logging framework.</p>
</div>
<div class="paragraph">
<p><strong>Which logging framework writes data?</strong></p>
</div>
<div class="paragraph">
<p>The supported "back-end" frameworks include:</p>
</div>
<div class="olist arabic">
<ol class="arabic">
<li>
<p><a href="https://developer.jboss.org/wiki/StandaloneJBossLogManager">jboss-logmanager</a></p>
</li>
<li>
<p><a href="http://logging.apache.org/log4j/2.x/">Log4j</a></p>
</li>
<li>
<p><a href="http://www.slf4j.org/">SLF4J</a></p>
</li>
<li>
<p>JDK logging</p>
</li>
</ol>
</div>
<div class="paragraph">
<p>A system property <code>org.jboss.logging.provider</code> may be used to specify the logging framework directly. Supported values are <code>jboss</code>, <code>jdk</code>, <code>log4j</code> and <code>slf4j</code>. If this system property is not set, JBoss Logging will attempt to find the logging frameworks from the above-mentioned list on the classpath - the first one found is taken.</p>
</div>
<div class="paragraph">
<p><strong>Simple way for testing purposes</strong></p>
</div>
<div class="paragraph">
<p>If you just want to see the debug log messages as quickly as possible try to add <code>org.slf4j:slf4j-simple</code> on the classpath, set the "back-end" framwork to <code>slf4j</code> and change the level for <code>org.jboss.weld</code>, e.g.:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code><dependency>
 <groupId>org.slf4j</groupId>
 <artifactId>slf4j-simple</artifactId>
 <version>1.7.2</version>
 <scope>test</scope>
</dependency></code></pre>
</div>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code>mvn clean test -Dtest=MyWeldSETest -Dorg.jboss.logging.provider=slf4j -Dorg.slf4j.simpleLogger.log.org.jboss.weld=debug</code></pre>
</div>
</div>
<a href="#faq_contents">
<i class="fa fa-arrow-circle-o-up fa-lg"></i>
Top
</a>
<hr>
</div>
<div id="11">
<h2>
How to deploy a Weld application to a Jetty standalone instance?
</h2>
<div class="paragraph">
<p>You should not experience any classloading issues when starting Jetty as an embedded webapp server from within another Java program. However, if you’re using a Jetty standalone instance the deployment with bundled Weld Servlet integration will probably fail and you may observe a similar message in the log:</p>
</div>
<div class="listingblock">
<div class="content">
<pre>FAILED org.eclipse.jetty.annotations.ServletContainerInitializerListener@124d02b2: java.lang.NoClassDefFoundError: org/eclipse/jetty/servlet/ServletContextHandler$Decorator
java.lang.NoClassDefFoundError: org/eclipse/jetty/servlet/ServletContextHandler$Decorator</pre>
</div>
</div>
<div class="paragraph">
<p>The reason is that since Jetty 8 some internal classes are not visible from the web application.
See also <a href="http://www.eclipse.org/jetty/documentation/current/jetty-classloading.html#setting-server-classes">Setting Server Classes</a>.
Therefore, we have to tell Jetty not to hide the system classes which Weld integration code is using.
We can use the <code>jetty-web.xml</code> descriptor (see also <a href="https://www.eclipse.org/jetty/documentation/current/jetty-web-xml-config.html">Jetty XML Reference</a>):</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-xml" data-lang="xml"><?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure.dtd">
<Configure class="org.eclipse.jetty.webapp.WebAppContext">
 <Call name="prependServerClass">
 <Arg>-org.eclipse.jetty.util.Decorator</Arg>
 </Call>
 <Call name="prependServerClass">
 <Arg>-org.eclipse.jetty.util.DecoratedObjectFactory</Arg>
 </Call>
 <Call name="prependServerClass">
 <Arg>-org.eclipse.jetty.server.handler.ContextHandler.</Arg>
 </Call>
 <Call name="prependServerClass">
 <Arg>-org.eclipse.jetty.server.handler.ContextHandler</Arg>
 </Call>
 <Call name="prependServerClass">
 <Arg>-org.eclipse.jetty.servlet.ServletContextHandler</Arg>
 </Call>
</Configure></code></pre>
</div>
</div>
<div class="paragraph">
<p>Note that Jetty distributions (from version <strong>9.2.4</strong>) contain a <strong>dedicated <a href="http://www.eclipse.org/jetty/documentation/current/framework-weld.html">CDI/Weld module</a></strong> which allows to deploy a CDI application without bundling the Weld Servlet integration code.
However, note that if you want to deploy application using CDI along with JSF (e.g. weld-numberguess example) you need to copy the following dependencies directly to the CDI module directory:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>JSF API</p>
</li>
<li>
<p>JSF IMPL</p>
</li>
<li>
<p><a href="http://search.maven.org/#search|ga|1|weld-core-jsf">Weld Core JSF</a></p>
</li>
</ul>
</div>
<a href="#faq_contents">
<i class="fa fa-arrow-circle-o-up fa-lg"></i>
Top
</a>
<hr>
</div>
<div id="12">
<h2>
How to patch WildFly with newer Weld version?
</h2>
<div class="paragraph">
<p>Each version of WildFly is shipped with given version of Weld.
However, for every Weld release we also prepare a patch for WildFly which allows you to easily upgrade Weld version.
The patch has a form of <code>.zip</code> file with name such as <code>wildfly-10.1.0.Final-weld-3.0.0.Beta1-patch.zip</code>.
The above indicates that the patch is meant for WildFly version 10.1.0.Final and applies Weld in version 3.0.0.Beta1.
Using this patch for other WildFly versions is not guaranteed to work.</p>
</div>
<div class="paragraph">
<p>Here is an example how to apply the patch for Weld 3.0.0.Beta1 onto WildFly 10.1.0.Final:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>Download WildFly (10.1.0.Final) and unzip it to desired location.</p>
</li>
<li>
<p>Download Weld patch.</p>
</li>
<li>
<p>Navigate to the WildFly folder.</p>
</li>
<li>
<p>Run the following command to apply the patch.</p>
</li>
</ul>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code>$>/{$WILDFLY_FOLDER}/bin/jboss-cli.bat|sh --command="patch apply /path/to/patch/wildfly-10.1.0.Final-weld-3.0.0.Beta1-patch.zip"</code></pre>
</div>
</div>
<div class="ulist">
<ul>
<li>
<p>You should now see an outcome such as this one.</p>
</li>
</ul>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code>{
 "outcome" : "success",
 "result" : {}
}</code></pre>
</div>
</div>
<div class="ulist">
<ul>
<li>
<p>That’s it! Now you can start your WildFly and try out new Weld.</p>
</li>
</ul>
</div>
<a href="#faq_contents">
<i class="fa fa-arrow-circle-o-up fa-lg"></i>
Top
</a>
<hr>
</div>
<div id="13">
<h2>
What’s the difference between <code>@ApplicationScoped</code> and <code>@Singleton</code>?
</h2>
<div id="preamble">
<div class="sectionbody">
<div class="paragraph">
<p>Both these contexts behave very similarly.
A single bean instance is created and shared across the application.
However, there are some important differences.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_client_proxy">Client Proxy</h2>
<div class="sectionbody">
<div class="paragraph">
<p>First of all, <code>@ApplicationScoped</code> is a <strong>normal</strong> scope whereas <code>@Singleton</code> is a <strong>pseudo-scope</strong> (using the CDI terminology).
What does it mean?
In the first place, for normal scopes a <a href="https://docs.jboss.org/cdi/spec/2.0/cdi-spec.html#client_proxies">client proxy</a> is always injected.
This is a container construct that delegates all method calls to the current bean instance.
While this may seem as an unnecessary overhead, it allows the container to do the following:</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_serialization">Serialization</h2>
<div class="sectionbody">
<div class="paragraph">
<p>The client proxies are serializable even when the bean itself may not be.
Therefore, you can <code>@Inject</code> a normal-scoped bean into a bean with a passivating scope (such as <code>@SessionScoped</code>).
See <a href="https://docs.jboss.org/weld/reference/latest/en-US/html/scopescontexts.html#_the_singleton_pseudo_scope">Weld Reference Guide</a> for more information.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_lazy_creation">Lazy Creation</h2>
<div class="sectionbody">
<div class="paragraph">
<p>The container initializes the bean instances of normal scoped beans lazily.
In other words, when injecting an <code>@ApplicationScoped</code> bean a new instance is not created until actually used.
Instead, a shared client proxy is injected.
See <a href="http://weld.cdi-spec.org/news/2016/10/25/tip3-performance/#_lazy_initialization_of_bean_instances">Weld Tip 3 - Boost performance of Weld apps</a> for more information.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_circular_dependencies">Circular Dependencies</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Client proxies make it possible to <a href="https://docs.jboss.org/cdi/spec/2.0/cdi-spec.html#injection_and_resolution">support circularities</a> in the bean dependency graph.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_manual_bean_destruction">Manual Bean Destruction</h2>
<div class="sectionbody">
<div class="paragraph">
<p>There are also some use cases where it’s desirable to destroy/recreate a bean instance via <code>Instance.destroy()</code> or <code>AlterableContext.destroy()</code>.
With client proxy in place, all injection points operate on proxy objects that can lookup the contextual instance on demand therefore making it simple and safe to replace the contextual instance for a new one.
On the other hand injecting a direct reference and attempting the same would lead to stale bean instances or working with outdated states of those instances.</p>
</div>
</div>
</div>
<a href="#faq_contents">
<i class="fa fa-arrow-circle-o-up fa-lg"></i>
Top
</a>
<hr>
</div>
</div>
</div>
</div>
</div>
</div>
<footer>
<div class="row">
<div class="container" id="companyfooter">
<div class="redhatlogo" style="text-align:center;">
<div class="logospacer" style="height:10px;"></div>
<a href="http://www.redhat.com/">
<img src="https://static.jboss.org/theme/images/common/redhat_logo.png">
</a>
</div>
</div>
</div>
</footer>
</body>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js" type="text/javascript"></script>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount','UA-45187401-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
<script>
$(document).ready(function() {
$('#toggle_menu').click(function(){
$("#mobile_menu").toggle();
});
});
</script>
</html>