<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="/stylesheets/rss.css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>www.jugpadova.it: Category Tips &amp; Tricks</title>
    <link>http://www.jugpadova.it/articles/category/tips-and-tricks</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description>Java User Group [Padova]</description>
    <item>
      <title>Hello Android Tutorial su Debian Testing</title>
      <description>&lt;p&gt;Questo tutorial ha lo scopo di guidarvi passo passo nella creazione e installazione di un&amp;#8217;applicazione (&lt;em&gt;Hello Android&lt;/em&gt;) all&amp;#8217;interno di un dispositivo Android disponendo di un PC con distribuzione Debian Testing.&lt;/p&gt;


	&lt;p&gt;Di che cosa abbiamo bisogno:&lt;/p&gt;


	&lt;ul&gt;
	&lt;li&gt;Un &lt;span class="caps"&gt;IDE&lt;/span&gt; per sviluppare la nostra app – &lt;strong&gt;Eclipse&lt;/strong&gt;&lt;/li&gt;
		&lt;li&gt;&lt;strong&gt;Android &lt;span class="caps"&gt;SDK&lt;/span&gt;&lt;/strong&gt; – presso Google&lt;/li&gt;
		&lt;li&gt;Un plugin per l&amp;#8217;IDE (&lt;strong&gt;&lt;span class="caps"&gt;ADT&lt;/span&gt;&lt;/strong&gt;) per poter creare il nostro package .apk&lt;/li&gt;
		&lt;li&gt;Uno smartphone Android – &lt;strong&gt;Motorola Flipout&lt;/strong&gt;&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;Intanto segnalo il fatto che si potrebbe utilizzare come &lt;span class="caps"&gt;IDE&lt;/span&gt; &lt;strong&gt;Netbeans&lt;/strong&gt; (ne sono un utilizzatore convinto), ma il problema è che nei repositories Debian siamo attualmente fermi alla versione 6.0.1 che non supporta l&amp;#8217;attuale plugin &lt;em&gt;nbandroid&lt;/em&gt; :-(&lt;/p&gt;


	&lt;p&gt;Iniziamo a configurare la nostra distro per ottenere il risultato desiderato: creare un package .apk da inviare al nostro smartphone.&lt;/p&gt;
&lt;h3&gt;1. Eclipse &lt;span class="caps"&gt;IDE&lt;/span&gt;&lt;/h3&gt;


	&lt;p&gt;Diamo da riga di comando:&lt;/p&gt;


	&lt;p&gt;&lt;code&gt;$ apt-get install eclipse&lt;/code&gt;&lt;/p&gt;


	&lt;p&gt;e verranno installati in automatico tutti i pacchetti necessari (tra cui &lt;code&gt;eclipse-jdt eclipse-pde eclipse-platform eclipse-platform-data eclipse-plugin-cvs eclipse-rcp&lt;/code&gt;).&lt;/p&gt;


	&lt;h3&gt;2. Android &lt;span class="caps"&gt;SDK&lt;/span&gt;&lt;/h3&gt;


	&lt;p&gt;Preleviamo da &lt;a href="http://developer.android.com"&gt;developer.android.com&lt;/a&gt; il pacchetto .tgz per la nostra piattaforma:&lt;/p&gt;


	&lt;p&gt;&lt;code&gt;$ wget http://dl.google.com/android/android-sdk_r07-linux_x86.tgz&lt;/code&gt;&lt;/p&gt;


	&lt;p&gt;ed estraiamolo nella home del nostro debian user:&lt;/p&gt;


	&lt;p&gt;&lt;code&gt;$ tar xvzf android-sdk_r07-linux_x86.tgz &lt;/code&gt;&lt;/p&gt;


	&lt;h3&gt;3. Android Development Tools (ADT) Plugin per Eclipse&lt;/h3&gt;


	&lt;p&gt;Eclipse dà la possibilità di inserire nell&amp;#8217;IDE un &lt;span class="caps"&gt;URL&lt;/span&gt; attraverso il quale trovare ed installare i plugins. In particolare per installare l&amp;#8217;ADT Plugin basta avviare l&amp;#8217;IDE e selezionare dal menu:&lt;/p&gt;


	&lt;p&gt;&lt;code&gt;Window → Preferences&lt;/code&gt;&lt;/p&gt;


	&lt;p&gt;Su questa finestra:&lt;/p&gt;


	&lt;ul&gt;
	&lt;li&gt;dalla lista a sinistra apriamo la sezione &lt;em&gt;Install/Update&lt;/em&gt;&lt;/li&gt;
		&lt;li&gt;selezioniamo &lt;em&gt;Available Software Sites&lt;/em&gt;&lt;/li&gt;
		&lt;li&gt;clicchiamo sul bottone &lt;em&gt;Add&lt;/em&gt; a destra&lt;/li&gt;
		&lt;li&gt;inseriamo l&amp;#8217;indirizzo dove reperire il plugin: &lt;code&gt;https://dl-ssl.google.com/android/eclipse/&lt;/code&gt;&lt;/li&gt;
		&lt;li&gt;e infine clicchiamo su &lt;em&gt;OK&lt;/em&gt;&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;&lt;a href="/files/androidtutorial_adt-plugin-repo.png"&gt;&lt;img src="/files/androidtutorial_adt-plugin-repo_small.png" alt="" /&gt;&lt;/a&gt;&lt;/p&gt;


	&lt;p&gt;Ora andiamo sul menu:&lt;/p&gt;


	&lt;p&gt;&lt;code&gt;Help → Install New Software&lt;/code&gt;&lt;/p&gt;


	&lt;p&gt;Su questa finestra dal menu a tendina &lt;em&gt;Work with:&lt;/em&gt; selezionate il repository appena inserito. Sotto scegliete &lt;em&gt;Android Development Tools&lt;/em&gt; e proseguite nelle successive schermate (tra queste ci sarà anche l&amp;#8217;accettazione della licenza).&lt;/p&gt;


	&lt;p&gt;&lt;a href="/files/androidtutorial_adt-plugin-select.png"&gt;&lt;img src="/files/androidtutorial_adt-plugin-select_small.png" alt="" /&gt;&lt;/a&gt;&lt;/p&gt;


	&lt;p&gt;A questo punto l&amp;#8217;IDE chiede di essere riavviato.
Dopo ciò, bisogna configurare il plugin in modo che sfrutti l&amp;#8217;Android &lt;span class="caps"&gt;SDK&lt;/span&gt; installato al &lt;em&gt;punto 2&lt;/em&gt;. Andiamo su:&lt;/p&gt;


	&lt;p&gt;&lt;code&gt;Window → Preferences&lt;/code&gt;&lt;/p&gt;


	&lt;p&gt;Troveremo sulla lista a sinistra una nuova voce: &lt;em&gt;Android&lt;/em&gt;. Selezioniamola e clicchiamo sul bottone &lt;em&gt;Browse&lt;/em&gt; a destra inserendo la posizione dell&amp;#8217;Android &lt;span class="caps"&gt;SDK&lt;/span&gt; del &lt;em&gt;punto 2&lt;/em&gt; (&lt;code&gt;/home/stylee/android-sdk-linux_x86&lt;/code&gt;).&lt;/p&gt;


	&lt;p&gt;Se qualcosa dovesse andare storto, vi riporto il link alla &lt;a href="http://developer.android.com/sdk/eclipse-adt.html"&gt;guida esaustiva&lt;/a&gt; per l&amp;#8217;installazione e configurazione del plugin.&lt;/p&gt;


	&lt;h3&gt;4. Configurazione dell&amp;#8217;Android &lt;span class="caps"&gt;SDK&lt;/span&gt; tramite il tool &lt;em&gt;the Android &lt;span class="caps"&gt;SDK&lt;/span&gt; and &lt;span class="caps"&gt;AVD&lt;/span&gt; Manager&lt;/em&gt;&lt;/h3&gt;


	&lt;p&gt;Il plugin è configurato all&amp;#8217;interno dell&amp;#8217;IDE. Ora dobbiamo configurare l&amp;#8217;ambiente dell&amp;#8217; Android &lt;span class="caps"&gt;SDK&lt;/span&gt; per definire quale sarà il nostro dispositivo su cui svilupperemo l&amp;#8217;applicazione. Il tool da utilizzare è lanciabile direttamente dall&amp;#8217;interno di Eclipse con il bottone sul pannello pricipale:&lt;/p&gt;


	&lt;p&gt;&lt;img src="/files/androidtutorial_tool-bottone.png" alt="" /&gt;&lt;/p&gt;


	&lt;p&gt;Nel caso particolare, per produrre un package installabile sul mio &lt;em&gt;Motorola FlipOut&lt;/em&gt;, dovrò installare le &lt;em&gt;&lt;span class="caps"&gt;API 7&lt;/span&gt; per Android v2.1&lt;/em&gt; (menu &lt;em&gt;Available Packages&lt;/em&gt; sulla sinistra):&lt;/p&gt;


	&lt;p&gt;&lt;a href="/files/androidtutorial_tool-add.png"&gt;&lt;img src="/files/androidtutorial_tool-add_small.png" alt="" /&gt;&lt;/a&gt;&lt;/p&gt;


	&lt;p&gt;Dopo le &lt;span class="caps"&gt;API&lt;/span&gt; bisogna creare un &lt;em&gt;Android Virtual Device&lt;/em&gt; sul quale verrà testata la nostra app (tramite emulatore). Selezioniamo la voce &lt;em&gt;Virtual Devices&lt;/em&gt; sulla sinistra. Il mio FlipOut ha &lt;strong&gt;2Gb&lt;/strong&gt; di scheda di memoria SD, Android &lt;strong&gt;2.1&lt;/strong&gt; e risoluzione &lt;strong&gt;&lt;span class="caps"&gt;QVGA&lt;/span&gt;&lt;/strong&gt;.&lt;/p&gt;


	&lt;p&gt;&lt;a href="/files/androidtutorial_tool-avd.png"&gt;&lt;img src="/files/androidtutorial_tool-avd_small.png" alt="" /&gt;&lt;/a&gt;&lt;/p&gt;


	&lt;h3&gt;5. Hello Android&lt;/h3&gt;


	&lt;p&gt;Creiamo un nuovo progetto con il wizard sulla barra principale di Eclipse:&lt;/p&gt;


	&lt;p&gt;&lt;img src="/files/androidtutorial_newandroid-bottone1.png" alt="" /&gt;&lt;/p&gt;


	&lt;p&gt;Compilate i vari campi a vostro piacimento, seguendo le linee guida:&lt;/p&gt;


	&lt;p&gt;&lt;a href="/files/androidtutorial_newandroid-project.png"&gt;&lt;img src="/files/androidtutorial_newandroid-project_small.png" alt="" /&gt;&lt;/a&gt;&lt;/p&gt;


	&lt;p&gt;Aprite nell&amp;#8217;editor la classe &lt;code&gt;it.santasoft.helloandroid.HelloAndroid&lt;/code&gt; e modificate in questo modo:&lt;/p&gt;


&lt;pre&gt;
package it.santasoft.helloandroid;

import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;

public class HelloAndroid extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        TextView tv = new TextView(this);
        tv.setText("Hello JUGPadova! From my Android Device");
        setContentView(tv);
    }
}
&lt;/pre&gt;

	&lt;p&gt;Ora che abbiamo sistemato il codice, passiamo alla compilazione premendo il tasto sul pannello dell&amp;#8217;IDE&lt;/p&gt;


	&lt;p&gt;&lt;code&gt;Run → As Android Application&lt;/code&gt;&lt;/p&gt;


	&lt;p&gt;Verrà compilato il nostro package e lanciato l&amp;#8217;emulatore definito precedentemente nella sezione &lt;em&gt;Android Virtual Devices&lt;/em&gt;. Munitevi di pazienza e attendete qualche minuto che l&amp;#8217;emulatore si avvii&amp;#8230; e vedrete il risultato sperato.&lt;/p&gt;


	&lt;p&gt;Per maggiori informazioni e per alcuni approfondimenti sull&amp;#8217;app &lt;em&gt;HelloAndroid&lt;/em&gt; visitate &lt;a href="http://developer.android.com/resources/tutorials/hello-world.html"&gt;questo link su &lt;code&gt;developer.android.com&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;


	&lt;h3&gt;6. Installazione del package .apk sul dispositivo Android&lt;/h3&gt;


	&lt;p&gt;Individuiamo il pacchetto &lt;em&gt;Hello Android.apk&lt;/em&gt; all&amp;#8217;interno dell&amp;#8217;alberatura del nostro progetto compilato in Eclipse:&lt;/p&gt;


	&lt;p&gt;&lt;code&gt;Hello Android → bin → it → Hello Android.apk&lt;/code&gt;&lt;/p&gt;


	&lt;p&gt;Sul nostro dispositivo Android andiamo ad installare dall&amp;#8217;&lt;em&gt;Android Market&lt;/em&gt; uno dei tanti &lt;strong&gt;Apps Installer&lt;/strong&gt; che ci permettono di gestire pacchetti .apk all&amp;#8217;interno della scheda di memoria SD esterna. Io utilizzo &lt;em&gt;appInstaller&lt;/em&gt; di &lt;em&gt;Gregory House&lt;/em&gt;.&lt;/p&gt;


	&lt;p&gt;Spegniamo il nostro dispositivo Android, estraiamo la scheda di memoria, inseriamola sul nostro PC e trasferiamo nella directory radice il package &lt;em&gt;Hello android.apk&lt;/em&gt;; smontiamo la scheda, reinseriamo nel dispositivo e accendiamo.&lt;/p&gt;


	&lt;p&gt;Per questioni di sicurezza è disabilitata di default l&amp;#8217;opzione di poter installare applicazioni al di fuori dell&amp;#8217;&lt;em&gt;Android Market&lt;/em&gt;, perciò per il nostro scopo navighiamo nel menu del nostro dispositivo e abilitiamo l&amp;#8217;opzione&lt;/p&gt;


	&lt;p&gt;&lt;code&gt;Impostazioni → Applicazioni → Origini Sconosciute&lt;/code&gt;&lt;/p&gt;


	&lt;p&gt;Avviamo l&amp;#8217;applicazione &lt;em&gt;appInstaller&lt;/em&gt; e scegliamo il nostro package &lt;em&gt;Hello, Android&lt;/em&gt;. E finalmente otteniamo&lt;/p&gt;


	&lt;p&gt;&lt;a href="/files/androidtutorial_P1080967.JPG"&gt;&lt;img src="/files/androidtutorial_P1080967_small.JPG" alt="" /&gt;&lt;/a&gt;&lt;/p&gt;


	&lt;p&gt;Altro metodo molto veloce (testato di persona) se sul nostro Debian PC abbiamo installato il web server &lt;em&gt;apache&lt;/em&gt; e siamo in una rete wifi domestica è il seguente.&lt;/p&gt;


	&lt;ul&gt;
	&lt;li&gt;Copiamo il nostro &lt;em&gt;Hello Android.apk&lt;/em&gt; sulla root del webserver Apache &amp;#8211; &lt;code&gt;/var/www&lt;/code&gt; di default&lt;/li&gt;
		&lt;li&gt;Verifichiamo quale sia l&amp;#8217;indirizzo IP del Debian PC connesso alla rete wifi domestica &amp;#8211; supponiamo &lt;code&gt;192.168.2.51&lt;/code&gt;&lt;/li&gt;
		&lt;li&gt;Attiviamo il wifi sul dispositivo Android&lt;/li&gt;
		&lt;li&gt;Apriamo il browser del nostro smartphone all&amp;#8217;indirizzo: &lt;code&gt;http://192.168.2.51/Hello%20Android.apk&lt;/code&gt;&lt;/li&gt;
		&lt;li&gt;Dopo che il browser ha finito di scaricare il pacchetto comparirà una notifica: toccate la riga della notifica e vi verrà chiesto se volete installare il pacchetto.&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;(il &lt;code&gt;%20&lt;/code&gt; sostituisce lo spazio negli &lt;span class="caps"&gt;URL&lt;/span&gt;).&lt;/p&gt;</description>
      <pubDate>Sun, 17 Oct 2010 13:54:00 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:b0841483-1e9e-4146-ad07-83afbf89a300</guid>
      <author>Dario Santamaria</author>
      <link>http://www.jugpadova.it/articles/2010/10/17/hello-android-tutorial-su-debian-testing</link>
      <category>Tips &amp; Tricks</category>
      <category>Programmazione</category>
      <category>android</category>
      <category>Eclipse</category>
      <category>debian</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Debugging tests of a Maven project in NetBeans</title>
      <description>&lt;p&gt;Occasionally I experienced some problems in debugging test classes using NetBeans with Maven projects. Simply, the debugger started but didn&amp;#8217;t attach to the running tests.&lt;/p&gt;


	&lt;p&gt;Eventually I discovered the reason!&lt;/p&gt;


	&lt;p&gt;I used to configure the surefire plugin with:&lt;/p&gt;


&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_xml "&gt;&lt;span class="punct"&gt;&amp;lt;&lt;/span&gt;&lt;span class="tag"&gt;plugin&lt;/span&gt;&lt;span class="punct"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="punct"&gt;&amp;lt;&lt;/span&gt;&lt;span class="tag"&gt;groupId&lt;/span&gt;&lt;span class="punct"&gt;&amp;gt;&lt;/span&gt;org.apache.maven.plugins&lt;span class="punct"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="tag"&gt;groupId&lt;/span&gt;&lt;span class="punct"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="punct"&gt;&amp;lt;&lt;/span&gt;&lt;span class="tag"&gt;artifactId&lt;/span&gt;&lt;span class="punct"&gt;&amp;gt;&lt;/span&gt;maven-surefire-plugin&lt;span class="punct"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="tag"&gt;artifactId&lt;/span&gt;&lt;span class="punct"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="punct"&gt;&amp;lt;&lt;/span&gt;&lt;span class="tag"&gt;configuration&lt;/span&gt;&lt;span class="punct"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="punct"&gt;&amp;lt;&lt;/span&gt;&lt;span class="tag"&gt;skip&lt;/span&gt;&lt;span class="punct"&gt;&amp;gt;&lt;/span&gt;false&lt;span class="punct"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="tag"&gt;skip&lt;/span&gt;&lt;span class="punct"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="punct"&gt;&amp;lt;&lt;/span&gt;&lt;span class="tag"&gt;useFile&lt;/span&gt;&lt;span class="punct"&gt;&amp;gt;&lt;/span&gt;true&lt;span class="punct"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="tag"&gt;useFile&lt;/span&gt;&lt;span class="punct"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="punct"&gt;&amp;lt;&lt;/span&gt;&lt;span class="tag"&gt;forkMode&lt;/span&gt;&lt;span class="punct"&gt;&amp;gt;&lt;/span&gt;once&lt;span class="punct"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="tag"&gt;forkMode&lt;/span&gt;&lt;span class="punct"&gt;&amp;gt;&lt;/span&gt; &lt;span class="comment"&gt;&amp;lt;!-- always, once or never --&amp;gt;&lt;/span&gt;
        &lt;span class="comment"&gt;&amp;lt;!-- &amp;lt;reportFormat&amp;gt;plain&amp;lt;/reportFormat&amp;gt; --&amp;gt;&lt;/span&gt;
        &lt;span class="punct"&gt;&amp;lt;&lt;/span&gt;&lt;span class="tag"&gt;argLine&lt;/span&gt;&lt;span class="punct"&gt;&amp;gt;&lt;/span&gt;-Xmx512M&lt;span class="punct"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="tag"&gt;argLine&lt;/span&gt;&lt;span class="punct"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="punct"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="tag"&gt;configuration&lt;/span&gt;&lt;span class="punct"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="punct"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="tag"&gt;plugin&lt;/span&gt;&lt;span class="punct"&gt;&amp;gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

	&lt;p&gt;The problem is the &lt;code&gt;argLine&lt;/code&gt; parameter. It will override the parameters the Mevenide plugin will pass for debugging tests. So, I commented it in my configuration:&lt;/p&gt;


&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_xml "&gt;&lt;span class="punct"&gt;&amp;lt;&lt;/span&gt;&lt;span class="tag"&gt;plugin&lt;/span&gt;&lt;span class="punct"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="punct"&gt;&amp;lt;&lt;/span&gt;&lt;span class="tag"&gt;groupId&lt;/span&gt;&lt;span class="punct"&gt;&amp;gt;&lt;/span&gt;org.apache.maven.plugins&lt;span class="punct"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="tag"&gt;groupId&lt;/span&gt;&lt;span class="punct"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="punct"&gt;&amp;lt;&lt;/span&gt;&lt;span class="tag"&gt;artifactId&lt;/span&gt;&lt;span class="punct"&gt;&amp;gt;&lt;/span&gt;maven-surefire-plugin&lt;span class="punct"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="tag"&gt;artifactId&lt;/span&gt;&lt;span class="punct"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="punct"&gt;&amp;lt;&lt;/span&gt;&lt;span class="tag"&gt;configuration&lt;/span&gt;&lt;span class="punct"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="punct"&gt;&amp;lt;&lt;/span&gt;&lt;span class="tag"&gt;skip&lt;/span&gt;&lt;span class="punct"&gt;&amp;gt;&lt;/span&gt;false&lt;span class="punct"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="tag"&gt;skip&lt;/span&gt;&lt;span class="punct"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="punct"&gt;&amp;lt;&lt;/span&gt;&lt;span class="tag"&gt;useFile&lt;/span&gt;&lt;span class="punct"&gt;&amp;gt;&lt;/span&gt;true&lt;span class="punct"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="tag"&gt;useFile&lt;/span&gt;&lt;span class="punct"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="punct"&gt;&amp;lt;&lt;/span&gt;&lt;span class="tag"&gt;forkMode&lt;/span&gt;&lt;span class="punct"&gt;&amp;gt;&lt;/span&gt;once&lt;span class="punct"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="tag"&gt;forkMode&lt;/span&gt;&lt;span class="punct"&gt;&amp;gt;&lt;/span&gt; &lt;span class="comment"&gt;&amp;lt;!-- always, once or never --&amp;gt;&lt;/span&gt;
        &lt;span class="comment"&gt;&amp;lt;!-- &amp;lt;reportFormat&amp;gt;plain&amp;lt;/reportFormat&amp;gt; --&amp;gt;&lt;/span&gt;
        &lt;span class="comment"&gt;&amp;lt;!--argLine&amp;gt;-Xmx512M&amp;lt;/argLine--&amp;gt;&lt;/span&gt; &lt;span class="comment"&gt;&amp;lt;!-- don't use if you want to debug tests in NetBeans --&amp;gt;&lt;/span&gt;
    &lt;span class="punct"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="tag"&gt;configuration&lt;/span&gt;&lt;span class="punct"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="punct"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="tag"&gt;plugin&lt;/span&gt;&lt;span class="punct"&gt;&amp;gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

	&lt;p&gt;...and now I can debug my tests!&lt;/p&gt;
</description>
      <pubDate>Wed, 20 Feb 2008 11:30:00 -0600</pubDate>
      <guid isPermaLink="false">urn:uuid:b0ff11e9-ed4b-438c-8d7a-074b62a507ab</guid>
      <author>Lucio Benfante</author>
      <link>http://www.jugpadova.it/articles/2008/02/20/debugging-tests-of-a-maven-project-in-netbeans</link>
      <category>Tips &amp; Tricks</category>
      <category>Programmazione</category>
      <category>maven</category>
      <category>test</category>
      <category>debug</category>
      <category>netbeans</category>
    </item>
    <item>
      <title>Iterating on non-iterable classes</title>
      <description>&lt;p&gt;(You&amp;#8217;ll find all the code of this post in &lt;a href="http://www.benfante.com/bensite/sourcecode.jsf"&gt;Benfante&amp;#8217;s Utilities&lt;/a&gt; mini-library)&lt;/p&gt;

&lt;p&gt;One of the futures I &amp;#8216;m reappraising is the JDK 5 enhanced for statement.&lt;/p&gt;

&lt;p&gt;I still consider it too limited, but it&amp;#8217;s very comfortable in the simplest (and maybe common) cases.&lt;/p&gt;

&lt;p&gt;But&amp;#8230;what if the elements on which you want to iterate are not managed by an Iterable class?&lt;/p&gt;

&lt;p&gt;For example, this happens with the &lt;a href="http://www.xom.nu/"&gt;XOM&lt;/a&gt; library, where the Element.getChildElements returns an instance of the Elements class, wich is neither a Collection, or an Iterable class. So, for iterating on children elements, you have to use the basic for statement:&lt;/p&gt;

&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_java "&gt;for (int i=0; i &amp;lt; elements.size(); i++) {
  Element element = elements.get(i);
  // etc...
}&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;I would like to write simply:&lt;/p&gt;

&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_java "&gt;for (Element element: elements) {
  // etc...
}&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;So I wrote an &lt;strong&gt;&lt;code&gt;Iterabletor&lt;/code&gt;&lt;/strong&gt; class that builds a proxy around a class, enhancing it with the Iterable interface.&lt;/p&gt;

&lt;p&gt;Now You can write:&lt;/p&gt;

&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_java "&gt;Iterable&amp;lt;Element&amp;gt; iterable =
  new Iterabletor&amp;lt;Element&amp;gt;(elements).getIterable();

for (Element element: iterable) {
  // etc...
}&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Take a look at how I realaized this.&lt;/p&gt;

&lt;p&gt;First, the &lt;code&gt;Iterabletor&lt;/code&gt; class:&lt;/p&gt;

&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_java "&gt;package com.benfante.utils.iterabletor;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.util.Iterator;

/**
 * A class for add iterability to another class
 * 
 * @author lucio
 */
public class Iterabletor&amp;lt;T&amp;gt; implements InvocationHandler {

    private final Object obj;
    private Class&amp;lt;? extends Iterator&amp;gt; iteratorClass;

    /**
     * Prepare for iterability the passed object using a XOMIterator.
     *
     * @param The object on which iterate.
     */
    @SuppressWarnings(value = &amp;quot;unchecked&amp;quot;)
    public Iterabletor(Object obj) {
        this.obj = obj;
        this.iteratorClass = XOMIterator.class;
    }

    /**
     * Prepare for iterability the passed object using the passed iterator class.
     *
     * @param The object on which iterate.
     */
    public Iterabletor(Object obj, Class&amp;lt;? extends Iterator&amp;gt; iteratorClass) {
        this.obj = obj;
        this.iteratorClass = iteratorClass;
    }

    @SuppressWarnings(value = &amp;quot;unchecked&amp;quot;)
    public synchronized Iterable&amp;lt;T&amp;gt; getIterable() {
        Class&amp;lt;?&amp;gt; objClass = obj.getClass();
        Class&amp;lt;?&amp;gt;[] oldInterfaces = objClass.getInterfaces();
        Class&amp;lt;?&amp;gt;[] newInterfaces = new Class&amp;lt;?&amp;gt;[oldInterfaces.length + 1];
        System.arraycopy(oldInterfaces, 0, newInterfaces, 0, oldInterfaces.length);
        newInterfaces[newInterfaces.length - 1] = Iterable.class;
        return (Iterable&amp;lt;T&amp;gt;) Proxy.newProxyInstance(objClass.getClassLoader(),
                newInterfaces,
                this);
    }

    @SuppressWarnings(value = &amp;quot;unchecked&amp;quot;)
    private Iterator&amp;lt;T&amp;gt; iterator() {
        try {
            return (Iterator&amp;lt;T&amp;gt;) iteratorClass
                .getConstructor(Object.class).newInstance(obj);
        } catch (Exception e) {
            throw new UnsupportedOperationException(&amp;quot;No contructor(object)&amp;quot;, e);
        }
    }

    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        if (method.getName().equals(&amp;quot;iterator&amp;quot;)) {
            return this.iterator();
        } else {
            try {
                return method.invoke(obj, args);
            } catch (InvocationTargetException ite) {
                throw ite.getCause();
            }
        }
    }
}&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;The default Iterator is XOMIterator (you can imagine why this name :) ), which reflect on the &amp;#8220;collection&amp;#8221;, calling the get(int) and size() methods:&lt;/p&gt;

&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_java "&gt;package com.benfante.utils.iterabletor;

import java.util.Iterator;
import org.apache.log4j.Logger;

/**
 * An Iterator for XOM-like collection classes
 * ...i.e. classes with get(int) and size() methods.
 * 
 * @author lucio
 */
public class XOMIterator&amp;lt;T&amp;gt; implements Iterator&amp;lt;T&amp;gt; {

    private static final Logger logger = Logger.getLogger(XOMIterator.class);
    private Object obj;
    private int index;

    public XOMIterator(Object obj) {
        this.obj = obj;
    }

    public boolean hasNext() {
        try {
            int count = ((java.lang.Integer) obj.getClass()
                    .getMethod(&amp;quot;size&amp;quot;, new Class[0])
                    .invoke(obj)).intValue();
            return index &amp;lt; count;
        } catch (Exception ex) {
            logger.error(&amp;quot;No size() method in the target object (&amp;quot;
                    + obj.getClass().getName() + &amp;quot;)&amp;quot;, ex);
            throw
                    new UnsupportedOperationException(
                    &amp;quot;No size() method in the target object (&amp;quot;
                    + obj.getClass().getName() + &amp;quot;)&amp;quot;, ex);
        }
    }

    @SuppressWarnings(value = &amp;quot;unchecked&amp;quot;)
    public T next() {
        try {
            return (T) obj.getClass()
                    .getMethod(&amp;quot;get&amp;quot;, new Class&amp;lt;?&amp;gt;[]{int.class})
                    .invoke(obj, new Integer(index++));
        } catch (Exception ex) {
            logger.error(&amp;quot;No get(int) method in the target object (&amp;quot;
                    + obj.getClass().getName() + &amp;quot;)&amp;quot;, ex);
            throw
                    new UnsupportedOperationException(
                    &amp;quot;No get(int) method in the target object (&amp;quot;
                    + obj.getClass().getName() + &amp;quot;)&amp;quot;, ex);
        }
    }

    public void remove() {
        throw new UnsupportedOperationException(&amp;quot;Not supported.&amp;quot;);
    }
}&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Of course, You can use a different Iterator:&lt;/p&gt;

&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_java "&gt;Iterator&amp;lt;MyElement&amp;gt; iterable =
    new Iterabletor&amp;lt;MyElement&amp;gt;(element, MyIterator.class)
        .getIterable();&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</description>
      <pubDate>Fri, 27 Jul 2007 06:42:00 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:eef63133-72a4-4a79-8d9b-61c0efb7be20</guid>
      <author>Lucio Benfante</author>
      <link>http://www.jugpadova.it/articles/2007/07/27/iterating-on-non-iterable-classes</link>
      <category>Tips &amp; Tricks</category>
      <category>Software</category>
      <category>Iterable</category>
      <category>Iterator</category>
      <category>for</category>
      <category>reflection</category>
      <category>proxy</category>
    </item>
    <item>
      <title>JDBC url for oracle RAC</title>
      <description>If you have to connect to oracle &lt;span class="caps"&gt;RAC&lt;/span&gt; (Real Application Cluster) using &lt;span class="caps"&gt;JDBC&lt;/span&gt; with thin driver, the classic url:
&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_xml "&gt;jdbc:oracle:thin:@&lt;span class="punct"&gt;&amp;lt;&lt;/span&gt;&lt;span class="tag"&gt;HOST&lt;/span&gt;&lt;span class="punct"&gt;&amp;gt;&lt;/span&gt;:1521:&lt;span class="punct"&gt;&amp;lt;&lt;/span&gt;&lt;span class="tag"&gt;SID&lt;/span&gt;&lt;span class="punct"&gt;&amp;gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
doesn&amp;#8217;t work and you get the error &lt;span class="caps"&gt;ORA&lt;/span&gt; &amp;#8211; 12505.&lt;br&gt;
Instead, you must use this url:
&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_xml "&gt;jdbc:oracle:thin:@(DESCRIPTION=(LOAD_BALANCE=on)
(ADDRESS=(PROTOCOL=TCP)(HOST=host1) (PORT=1521))
(ADDRESS=(PROTOCOL=TCP)(HOST=host2) (PORT=1521))
(CONNECT_DATA=(SERVICE_NAME=service)))&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
If you have an oracle client, like &lt;a href="http://www.toadsoft.com"&gt;toad&lt;/a&gt;, check the tsnames.ora for the correct values of &lt;span class="caps"&gt;SERVICE&lt;/span&gt;_NAME and host.
</description>
      <pubDate>Wed, 11 Apr 2007 20:07:00 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:d5eb2504-76e7-4d47-b81c-aaba5ed70fc9</guid>
      <author>Enrico Giurin</author>
      <link>http://www.jugpadova.it/articles/2007/04/11/jdbc-url-for-oracle-rac</link>
      <category>Tips &amp; Tricks</category>
      <category>jdbc</category>
      <category>oracle</category>
      <trackback:ping>http://www.jugpadova.it/articles/trackback/28454</trackback:ping>
    </item>
    <item>
      <title>Tomcat 5.5.20 and JavaMail Sessions</title>
      <description>&lt;p&gt;&lt;em&gt;You&amp;#8217;ll find an article in italian on the same topic in &lt;a href="http://benfante.blogspot.com/2007/03/tomcat-castrato.html"&gt;my personal blog&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;In &lt;a href="http://tomcat.apache.org"&gt;Tomcat&lt;/a&gt; you can define a JNDI Resource for a JavaMail session putting the following code in you Context definition:&lt;/p&gt;

&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_xml "&gt;&lt;span class="punct"&gt;&amp;lt;&lt;/span&gt;&lt;span class="tag"&gt;Resource&lt;/span&gt; &lt;span class="attribute"&gt;name&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;mail/Session&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt; &lt;span class="attribute"&gt;auth&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;Container&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt;
            &lt;span class="attribute"&gt;type&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;javax.mail.Session&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt;
            &lt;span class="attribute"&gt;mail.smtp.host&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;localhost&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;/&amp;gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;And in you web.xml:&lt;/p&gt;

&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_xml "&gt;&lt;span class="punct"&gt;&amp;lt;&lt;/span&gt;&lt;span class="tag"&gt;resource-ref&lt;/span&gt;&lt;span class="punct"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="punct"&gt;&amp;lt;&lt;/span&gt;&lt;span class="tag"&gt;res-ref-name&lt;/span&gt;&lt;span class="punct"&gt;&amp;gt;&lt;/span&gt;mail/Session&lt;span class="punct"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="tag"&gt;res-ref-name&lt;/span&gt;&lt;span class="punct"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="punct"&gt;&amp;lt;&lt;/span&gt;&lt;span class="tag"&gt;res-type&lt;/span&gt;&lt;span class="punct"&gt;&amp;gt;&lt;/span&gt;javax.mail.Session&lt;span class="punct"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="tag"&gt;res-type&lt;/span&gt;&lt;span class="punct"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="punct"&gt;&amp;lt;&lt;/span&gt;&lt;span class="tag"&gt;res-auth&lt;/span&gt;&lt;span class="punct"&gt;&amp;gt;&lt;/span&gt;Container&lt;span class="punct"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="tag"&gt;res-auth&lt;/span&gt;&lt;span class="punct"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="punct"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="tag"&gt;resource-ref&lt;/span&gt;&lt;span class="punct"&gt;&amp;gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Then you can use it in you code:&lt;/p&gt;

&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_java "&gt;Context initCtx = new InitialContext();
Session session =
    (Session) envCtx.lookup(&amp;quot;java:comp/env/mail/Session&amp;quot;);&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Using Tomcat 5.5.20 (and 5.5.17, and 5.5.23&amp;#8230;and maybe other versions) the last statement will produce a &lt;code&gt;ClassNotFoundException: org.apache.naming.factory.MailSessionFactory&lt;/code&gt;. The cause is obviously that class is missing from the &lt;code&gt;common/lib/naming-factory.jar&lt;/code&gt; distributed by Tomcat. I don&amp;#8217;t know if it was a (repeated) problem in building Tomcat. Luckly the source code of that class is still present in the source distribution of Tomcat. Simply it isn&amp;#8217;t included in the build process if you don&amp;#8217;t have the &lt;a href="http://java.sun.com/products/javamail/"&gt;JavaMail&lt;/a&gt; and the &lt;a href="http://java.sun.com/products/javabeans/jaf/"&gt;JavaBeans Activation Framework&lt;/a&gt; in the build classpath. So I re-built the &lt;code&gt;naming-factory.jar&lt;/code&gt; file and substituted in &lt;code&gt;common/lib&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;You can rebuild your own JAR, or download my new &lt;a href="http://snipurl.com/nfjar"&gt;naming-factory.jar&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I discovered this problem (bug?) installing &lt;a href="http://www.liferay.com/"&gt;LifeRay&lt;/a&gt; 4.1.2 using the WAR distribution. On the contrary the LifeRay-Tomcat bundle contains the correct &lt;code&gt;naming-factory.jar&lt;/code&gt; yet. The LifeRay error in this case is more obscure. It reports a &lt;code&gt;javax.naming.NameNotFoundException: Name mail is not bound in this Context&lt;/code&gt;! Of course the JNDI Resource is correctly configured. This happens because LifeRay try to guess the JNDI name of the resource, that changes for the different application servers. So that exception comes from one of the attempts, and the real problem is lost and hidden. So, if you&amp;#8217;ll see a such message, don&amp;#8217;t spend time re-re-re-configuring your JNDI resources&amp;#8230;but patch Tomcat!&lt;/p&gt;</description>
      <pubDate>Tue, 13 Mar 2007 07:40:00 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:8264d2f3-ac82-4f1e-9212-4686009a2acc</guid>
      <author>Lucio Benfante</author>
      <link>http://www.jugpadova.it/articles/2007/03/13/tomcat-5-5-20-and-javamail-sessions</link>
      <category>Tips &amp; Tricks</category>
      <category>Programmazione</category>
      <category>Tomcat</category>
      <category>JavaMail</category>
      <category>JNDI</category>
      <category>bug</category>
      <trackback:ping>http://www.jugpadova.it/articles/trackback/21441</trackback:ping>
    </item>
    <item>
      <title>Ma voi le wrappate le liste?</title>
      <description>&lt;p&gt;Ciao, in un progetto su cui sto lavorando  sto provando un approccio che non avevo mai usato in passato per le liste di oggetti java, immaginate che di avere una lista tipo:&lt;/p&gt;


&lt;code&gt;&lt;pre&gt;
List&amp;lt;SomeObject&amp;gt; list = new ArrayList&amp;lt;SomeObject&amp;gt;();
&lt;/pre&gt;&lt;/code&gt;

	&lt;p&gt;Se volessi estrarre dalla lista tutti gli elementi aventi un certo campo valorizzato ad un dato valore, ovvero fare un filtro, farei:&lt;/p&gt;


&lt;code&gt;&lt;pre&gt;
class SomeObject {
  public static List&amp;lt;SomeObject&amp;gt; filterByField(List&amp;lt;SomeObject&amp;gt; input, String value) {
    // ciclo la lista input e restituisco una lista nuova con gli oggetti che hanno field=value 
  }
}
&lt;/pre&gt;&lt;/code&gt;

	&lt;p&gt;usato così:&lt;/p&gt;


&lt;code&gt;&lt;pre&gt;
List&amp;lt;SomeObject&amp;gt; all = new ArrayList&amp;lt;SomeObject&amp;gt;();
List&amp;lt;SomeObject&amp;gt; filtered = SomeObject.filterByField(all, "someValue");
&lt;/pre&gt;&lt;/code&gt;

	&lt;p&gt;Il fatto però di avere metodi statici &amp;#8216;helper&amp;#8217; dentro &lt;code&gt;SomeObject&lt;/code&gt; per aggiungere funzionalità ad una lista non mi piace molto&amp;#8230; ho provato invece a wrappare &lt;code&gt;List&lt;/code&gt; e a spostare il metodo &lt;code&gt;filerByValue&lt;/code&gt; da &lt;code&gt;SomeObject&lt;/code&gt; alla nuova classe  &lt;code&gt;SomeObjects&lt;/code&gt;:&lt;/p&gt;


&lt;code&gt;&lt;pre&gt;
class SomeObjects extends ArrayList&amp;lt;SomeObject&amp;gt; {
   public SomeObjects filterByField(String value){
     // filtro ciclando gli elementi in this e restituisco una nuova istanza di SomeObjects
   }
}
&lt;/pre&gt;&lt;/code&gt;

Il codice di utilizzo quindi diventa: 
&lt;code&gt;&lt;pre&gt;
SomeObjects all = new SomeObjects();
SomeObjects filtered = all.filterByField("someValue");
&lt;/pre&gt;&lt;/code&gt;

	&lt;p&gt;Che mi pare molto più pulito e leggible, che ve ne pare?&lt;/p&gt;


	&lt;p&gt;So che non è un gran cambiamento, ma ho un parametro in meno per ogni &lt;code&gt;filterByXXX&lt;/code&gt; che desidero aggiungere e ogni metodo è nel posto che gli compete, ovvero i medoti per filtrare una lista stanno nella lista e non come metodi helper dell&amp;#8217;oggetto contenuto.&lt;/p&gt;


	&lt;p&gt;Un&amp;#8217;altro punto dove questo approccio è utile è nei Dao che wrappano funzionalità di IBatis o Hibernate, dove si trova spesso codice di questo tipo per prevenire il ritorno di liste nulle:&lt;/p&gt;


&lt;code&gt;&lt;pre&gt;
List&amp;lt;SomeObject&amp;gt; result = new ArrayList&amp;lt;SomeObject&amp;gt;();
result.addAll( ...queryForList("your query", param));
return result;
&lt;/pre&gt;&lt;/code&gt;

	&lt;p&gt;Con i wrapper possiamo scrivere un costruttore ad hoc, che prende una lista in input e fa &lt;code&gt;addAll(...)&lt;/code&gt; solo se è diversa da &lt;code&gt;null&lt;/code&gt;:&lt;/p&gt;


&lt;code&gt;&lt;pre&gt;
public class SomeObjects extends ArrayList&amp;lt;SomeObject&amp;gt; {

    public SomeObjects () {}

    public SomeObjects (Collection&amp;lt;SomeObject&amp;gt; c) {
       if (c!=null) addAll(c);
    }
}
&lt;/pre&gt;&lt;/code&gt;

	&lt;p&gt;E il codice di utilizzo diventa magicamente:&lt;/p&gt;


&lt;code&gt;&lt;pre&gt;
return new SomeObjects(...queryForList("your query", param));
&lt;/pre&gt;&lt;/code&gt;

	&lt;p&gt;Fatemi sapere che ne pensate, io mi sto trovando bene con questo approccio.&lt;/p&gt;


	&lt;p&gt;&lt;small&gt;
&lt;em&gt;_ &lt;a href="mailto:paolo.dona@seesaw.it"&gt;Paolo Donà&lt;/a&gt; si occupa di sviluppo web in Java e Ruby, sviluppo progetti su commessa e formazione/training. Potete contattarlo via mail o leggere il suo blog &lt;a href="http://blog.seesaw.it"&gt;aziendale&lt;/a&gt; o &lt;a href="http://paolodona.blogspot.com"&gt;personale&lt;/a&gt;. _&lt;/em&gt;
&lt;/small&gt;&lt;/p&gt;
</description>
      <pubDate>Wed, 06 Dec 2006 08:45:00 -0600</pubDate>
      <guid isPermaLink="false">urn:uuid:020e07a4-edb2-4dfe-890c-2d06a79b9207</guid>
      <author>Paolo Dona'</author>
      <link>http://www.jugpadova.it/articles/2006/12/06/ma-voi-le-wrappate-le-liste</link>
      <category>Tips &amp; Tricks</category>
      <category>list</category>
      <trackback:ping>http://www.jugpadova.it/articles/trackback/10900</trackback:ping>
    </item>
    <item>
      <title>Mi domando...davvero so &amp;lt;code&amp;gt;null&amp;lt;/code&amp;gt;(a)?</title>
      <description>&lt;p&gt;&amp;#8220;La vera saggezza sta in colui che sa di non sapere! Perchè io so di sapere più di te, che pensi di sapere.&amp;#8221; (Socrate) Allora i programmatori Java dovrebbero essere molto saggi, perchè dovrebbero essere convinti di (non) conoscere &lt;code&gt;null&lt;/code&gt; molto bene. Ma siamo così sicuri?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Domanda 1:&lt;/strong&gt; Di che tipo è il litteral &lt;code&gt;null&lt;/code&gt;?&lt;/p&gt;

&lt;p&gt;&lt;em&gt;qui prossimamente la risposta&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Domanda 2:&lt;/strong&gt; Assegnando il litteral &lt;code&gt;null&lt;/code&gt; ad una variabile, devo fare un cast esplicito?&lt;/p&gt;

&lt;p&gt;&lt;em&gt;qui prossimamente la risposta&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Domanda 3:&lt;/strong&gt; C&amp;#8217;è qualche caso in cui ha senso fare un cast esplicito di un litteral &lt;code&gt;null&lt;/code&gt;?&lt;/p&gt;

&lt;p&gt;&lt;em&gt;qui prossimamente la risposta&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Domanda 4:&lt;/strong&gt; Assegnando il litteral &lt;code&gt;null&lt;/code&gt; ad una variabile, posso aspettarmi una ClassCastException?&lt;/p&gt;

&lt;p&gt;&lt;em&gt;qui prossimamente la risposta&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Domanda 5:&lt;/strong&gt; Può accadere una NullPointerException assegnando un valore ad una variabile di un tipo primitivo?&lt;/p&gt;

&lt;p&gt;&lt;em&gt;qui prossimamente la risposta&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&amp;#8230;altre? Se conoscete qualche stranezza riguardante il &lt;code&gt;null&lt;/code&gt;(a)&amp;#8230;scrivete&amp;#8230;scrivete&amp;#8230;&lt;/p&gt;

&lt;blockquote&gt;
    &lt;p&gt;Hey! Ma che razza di post è questo? L&amp;#8217;idea è di dare degli argomenti di discussione legati principalmente alla conoscenza delle basi del linguaggio Java. &lt;/p&gt;
    
    &lt;p&gt;Da tali discussioni deriverà sicuramente una migliore conoscenza di alcuni aspetti di base del linguaggio, necessari, ad esempio, per superare le certificazioni Programmer e Developer, ma anche, magari, per programmare un po&amp;#8217; meglio.&lt;/p&gt;
    
    &lt;p&gt;Quindi, commentate&amp;#8230;commentate&amp;#8230;Chi darà la risposta megliore se la vedrà riportata sopra (o eventualmente un mix delle risposte migliori), con ovviamente il riconoscimento della paternità, o maternità, nel caso delle gentili signore che vorranno cimentarsi.&lt;/p&gt;
&lt;/blockquote&gt;
</description>
      <pubDate>Fri, 03 Nov 2006 17:00:00 -0600</pubDate>
      <guid isPermaLink="false">urn:uuid:810fc7a1-3b96-43d7-8a77-f80dcb5767a9</guid>
      <author>Lucio Benfante</author>
      <link>http://www.jugpadova.it/articles/2006/11/03/mi-domando-davvero-so-null-a</link>
      <category>Tips &amp; Tricks</category>
      <category>java</category>
      <category>quiz</category>
      <category>certification</category>
    </item>
    <item>
      <title>Mi domando...java.lang.Math?</title>
      <description>&lt;p&gt;A proposito della classe java.lang.Math&amp;#8230;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Domanda 1:&lt;/strong&gt; E&amp;#8217; possibile estenderla, creando una nuova classe che deriva da essa?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Lost:&lt;/strong&gt; No, la classe java.lang.Math è stata definita final e quindi non è possibile estenderla.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Domanda 2:&lt;/strong&gt; Ha senso crearne un&amp;#8217;istanza?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Lost:&lt;/strong&gt; No, la classe java.lang.Math non ha costruttore pubblico.&lt;/p&gt;

&lt;p&gt;&amp;#8230;altre?&lt;/p&gt;

&lt;blockquote&gt;
    &lt;p&gt;Hey! Ma che razza di post è questo? L&amp;#8217;idea è di dare degli argomenti di discussione legati principalmente alla conoscenza delle basi del linguaggio Java. &lt;/p&gt;
    
    &lt;p&gt;Da tali discussioni deriverà sicuramente una migliore conoscenza di alcuni aspetti di base del linguaggio, necessari, ad esempio, per superare le certificazioni Programmer e Developer, ma anche, magari, per programmare un po&amp;#8217; meglio.&lt;/p&gt;
    
    &lt;p&gt;Quindi, commentate&amp;#8230;commentate&amp;#8230;Chi darà la risposta megliore se la vedrà riportata sopra (o eventualmente un mix delle risposte migliori), con ovviamente il riconoscimento della paternità, o maternità, nel caso delle gentili signore che vorranno cimentarsi.&lt;/p&gt;
&lt;/blockquote&gt;
</description>
      <pubDate>Wed, 11 Oct 2006 16:06:00 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:e8fb015b-205a-4bd2-8ecb-6158688a0973</guid>
      <author>Lucio Benfante</author>
      <link>http://www.jugpadova.it/articles/2006/10/11/mi-domando-java-lang-math</link>
      <category>Tips &amp; Tricks</category>
      <category>java</category>
      <category>quiz</category>
      <category>certification</category>
      <trackback:ping>http://www.jugpadova.it/articles/trackback/4679</trackback:ping>
    </item>
    <item>
      <title>Mustang SplashScreen</title>
      <description>&lt;p&gt;&lt;a href="https://mustang.dev.java.net/"&gt;Mustang&lt;/a&gt; will be the next release of the Java Standard Edition (Java SE 6). At present Mustang is in beta, it will be delivered in &lt;a href="http://weblogs.java.net/blog/ray_gans/archive/2006/01/where_we_are_wi.html"&gt;Autumn 2006&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;One of the new &lt;a href="http://java.sun.com/developer/technicalArticles/J2SE/Desktop/mustang/index.html"&gt;desktop features&lt;/a&gt;
of Mustang is the capability of showing a splash screen even before the starting of the Java Virtual Machine.&lt;/p&gt;

&lt;p&gt;You can configure the splash screen by command line:&lt;/p&gt;

&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;java -splash:mysplash.gif MyApplication&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;&amp;#8230;or, if your application is packaged in a JAR file, using the &lt;em&gt;SplashScreen-Image&lt;/em&gt; option in the manifest file:&lt;/p&gt;

&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;Manifest-Version: 1.0
Main-Class: MyApplication
SplashScreen-Image: mysplash.gif&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;For testing this new cool feature of Mustang, I wrote a small example, with some supporting classes. For trying it you can download the Splasher.jar file from &lt;a href="http://www.snipurl.com/bencode"&gt;here&lt;/a&gt;. Execute it using:&lt;/p&gt;

&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;java -jar Splasher.jar&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;&amp;#8230;of course you have to download and install &lt;a href="https://mustang.dev.java.net/"&gt;Mustang&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;After the launch of the JVM the application can control and even drawing on the splash screen, retriving the SplashScreen object:&lt;/p&gt;

&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_java "&gt;SplashScreen splash = SplashScreen.getSplashScreen();
Graphics2D g = (Graphics2D)splash.getGraphics();
Rectangle r = splash.getBounds();
FontMetrics fm = g.getFontMetrics();
// drawing a message at the bottom of the splash screen
g.drawString(&amp;quot;Welcome!&amp;quot;,
            1, (int)r.getHeight()-1-fm.getDescent());
splash.update();&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;You can dismiss the splash screen using the close() method:&lt;/p&gt;

&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_java "&gt;splash.close();&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;This call is usually not needed as the splash screen will be &lt;strong&gt;automatically&lt;/strong&gt; closed when the first window of the application will be made visible.&lt;/p&gt;

&lt;p&gt;Some useful links:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="http://download.java.net/jdk6/docs/api/java/awt/SplashScreen.html"&gt;SplashScreen javadoc&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://java.sun.com/developer/JDCTechTips/2005/tt1115.html"&gt;A JDC TechTip&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://java.sun.com/developer/technicalArticles/J2SE/Desktop/mustang/splashscreen/"&gt;An SDN article&lt;/a&gt; (little outdated, but still good)&lt;/li&gt;
&lt;/ul&gt;</description>
      <pubDate>Sat, 01 Apr 2006 09:45:00 -0600</pubDate>
      <guid isPermaLink="false">urn:uuid:8f4a2b91-9de9-448e-8dcc-c068905c686c</guid>
      <author>Lucio Benfante</author>
      <link>http://www.jugpadova.it/articles/2006/04/01/mustang-splashscreen</link>
      <category>Tips &amp; Tricks</category>
      <category>Mustang</category>
      <category>desktop</category>
      <category>splash screen</category>
    </item>
    <item>
      <title>Accessing a resource within a .jar</title>
      <description>&lt;p&gt;Sometimes it is useful to distribute an application in a jar file through Java Web Start or any other way. So, you could have to read some resource (images or properties file) from inside a jar. 
How can you do it ? It&amp;#8217;s very simple, here&amp;#8217;s an example to retrieve an image:&lt;/p&gt;

&lt;p&gt;&lt;code lang="java"&gt;
ImageIcon image = (new ImageIcon(getClass().getResource("yourpackage/mypackage/image.gif")));&lt;br/&gt;
&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;In general, you can retrieve an InputStream in the following way:&lt;/p&gt;

&lt;p&gt;&lt;code lang="java"&gt;
InputStream is = this.getClass().getClassLoader()
&amp;nbsp;&amp;nbsp;&amp;nbsp;.getResourceAsStream("yourpackage/mypackage/myfile.xml");
&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;It will run inside or outside the jar. Enjoy !&lt;/p&gt;
</description>
      <pubDate>Sun, 05 Feb 2006 19:08:00 -0600</pubDate>
      <guid isPermaLink="false">urn:uuid:8ad0326e-b2dd-4cd3-ab45-133901572a60</guid>
      <author>Emanuele Gesuato</author>
      <link>http://www.jugpadova.it/articles/2006/02/05/accessing-a-resource-within-a-jar</link>
      <category>Tips &amp; Tricks</category>
      <category>jar</category>
      <category>resource</category>
      <trackback:ping>http://www.jugpadova.it/articles/trackback/49</trackback:ping>
    </item>
    <item>
      <title>Installing Java Studio Creator 2 on Debian</title>
      <description>&lt;p&gt;On Linux, the required distribution for Java Studio Creator 2 (now &lt;a href="http://developers.sun.com/members/promo/freetools/jscreator2.jsp" target="_blank"&gt;Free&lt;/a&gt; for all SDN members) is Fedora. I&amp;#8217;m a Debian user and I succeeded to install it, however.&lt;br /&gt;
The first time my installation completes too soon, without correctly installing Java Application Server. I read the FAQs and I found a page saying:&lt;br /&gt;
&lt;i&gt;Check if the following RPM packages exist on your system:&lt;/i&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt; either &lt;code&gt;libstdc++&lt;/code&gt; or &lt;code&gt;compat-libstdc++&lt;/code&gt; &lt;/li&gt;
&lt;li&gt; either &lt;code&gt;libstdc++-devel&lt;/code&gt; or &lt;code&gt;compat-libstdc++-devel&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;i&gt;If these are missing, first install them. Then restart the Java Studio Creator installer.
&lt;/i&gt;&lt;br/&gt;&lt;/p&gt;

&lt;p&gt;The correct Debian (Etch) packages (&lt;i&gt;&lt;code&gt;apt-get&lt;/code&gt; &amp;#8216;em!&lt;/i&gt;) are&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;libstdc++2.10-glibc2.2&lt;/code&gt; and&lt;/li&gt;
&lt;li&gt;&lt;code&gt;libstdc++2.10-dev&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I don&amp;#8217;t know if both are required or only the first one, but now the whole installation of Java Studio Creator 2 is complete.&lt;br /&gt;&lt;br/&gt;
Thanks to &lt;a href="http://blogs.sun.com/roller/page/coldrick?entry=using_java_netbeans_and_sun" target="_blank"&gt;David Coldrick&amp;#8217;s Weblog&lt;/a&gt; (installation on Ubuntu of JSCreator 1).&lt;/p&gt;
</description>
      <pubDate>Thu, 26 Jan 2006 19:34:00 -0600</pubDate>
      <guid isPermaLink="false">urn:uuid:66b9784f-321f-4a04-93e7-4302c536c3e8</guid>
      <author>Dario Santamaria</author>
      <link>http://www.jugpadova.it/articles/2006/01/26/installing-java-studio-creator-2-on-debian</link>
      <category>Tips &amp; Tricks</category>
      <category>install</category>
      <category>creator</category>
      <category>debian</category>
    </item>
    <item>
      <title>Xom</title>
      <description>&lt;p&gt;Today I want to introduce you into &lt;span class="caps"&gt;XOM&lt;/span&gt;, which is one of the two arguments I&amp;#8217;m going to talk about in our &lt;a href="http://upcoming.org/event/50575/"&gt;next meeting&lt;/a&gt; (the second is &lt;span class="caps"&gt;JSF 1&lt;/span&gt;.2). 
What is &lt;span class="caps"&gt;XOM&lt;/span&gt;? Someone could think it&amp;#8217;s yet another &lt;span class="caps"&gt;XML&lt;/span&gt; library. In part that&amp;#8217;s true.&lt;/p&gt;
&lt;p&gt;In Javapolis I attended to &lt;span class="caps"&gt;XOM&lt;/span&gt;&amp;#8217;s father, Elliotte Rusty Harold, talk. Harold wrote a very good &lt;a href="http://www.cafeconleche.org/books/xmljava/"&gt;book about &lt;span class="caps"&gt;XML&lt;/span&gt;&lt;/a&gt; and as he said during the conference, only after writing that book he can say that he is able to manage all the problem arising with &lt;span class="caps"&gt;DOM&lt;/span&gt;, JDOM and dom4j. So he proposes a new library which in his aim is correct, easy to use and easy to learn.&lt;/p&gt;


	&lt;p&gt;What lacked his presentation was some live examples, so in the next meeting I get into code in order to compare those libraries. I&amp;#8217;ll show you some common pitfalls using &lt;span class="caps"&gt;DOM&lt;/span&gt; api, and what are the counterparts in &lt;span class="caps"&gt;XOM&lt;/span&gt;.&lt;/p&gt;


	&lt;p&gt;If you want to check out &lt;span class="caps"&gt;XOM&lt;/span&gt; you can go to the &lt;a href="http://www.xom.nu"&gt;main site&lt;/a&gt;. In Harold&amp;#8217;s site you can find the &lt;a href="http://www.cafeconleche.org/slides/javapolis/xom/"&gt;javapolis slides&lt;/a&gt;&lt;/p&gt;</description>
      <pubDate>Sun, 15 Jan 2006 16:22:00 -0600</pubDate>
      <guid isPermaLink="false">urn:uuid:0dc0af4b-f6c2-4a5e-a790-24af61d018ff</guid>
      <author>Andrea Nasato</author>
      <link>http://www.jugpadova.it/articles/2006/01/15/xom</link>
      <category>Tips &amp; Tricks</category>
      <category>xom</category>
      <category>xml</category>
    </item>
    <item>
      <title>Serialize a bean using jdbc</title>
      <description>&lt;p&gt;Sometimes,  in my work as programmer, I need to serialize an object (bean) into a table, in a BLOB field, as well as retrieves bean from a ResultSet.
I have realized a simple example that, using JDBC, allows to obtain this.&lt;/p&gt;
&lt;p&gt;Here the method to fill PreparedStatement :&lt;/p&gt;

&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_java "&gt;public static void fillPreparedStatement(PreparedStatement pst, int index,
         Serializable obj) throws Exception {

      if (obj != null) {
         ByteArrayOutputStream regStore = new ByteArrayOutputStream();

         ObjectOutputStream regObjectStream = new ObjectOutputStream(regStore);
         regObjectStream.writeObject(obj);
         byte[] regBytes = regStore.toByteArray();
         regObjectStream.close();
         regStore.close();
         ByteArrayInputStream regArrayStream = new ByteArrayInputStream(regBytes);
         pst.setBinaryStream(index, regArrayStream, regBytes.length);
      }// end of if
      else {
         pst.setNull(index, Types.BLOB);
      }
}// end of method
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Here the method to retrieve bean from ResultSet.&lt;/p&gt;

&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_java "&gt;public static Object getFromResultSet(ResultSet rs, String columnName)
         throws Exception {
      byte[] regBytes = rs.getBytes(columnName);
      ByteArrayInputStream regArrayStream = new ByteArrayInputStream(regBytes);
      ObjectInputStream regObjectStream = new ObjectInputStream(
            regArrayStream);
      return regObjectStream.readObject();
}&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;I tested this code using MySQL 4.1 db.
Hope this example could save your valuable time.
Enrico.&lt;/p&gt;</description>
      <pubDate>Tue, 10 Jan 2006 18:19:00 -0600</pubDate>
      <guid isPermaLink="false">urn:uuid:1c49d880-c8d7-4b47-b75b-3e1dcfc292a2</guid>
      <author>Enrico Giurin</author>
      <link>http://www.jugpadova.it/articles/2006/01/10/serialize-a-bean-using-jdbc</link>
      <category>Tips &amp; Tricks</category>
      <category>blob</category>
      <category>jdbc</category>
      <category>bean</category>
    </item>
    <item>
      <title>Maven 2: Spring and JTA dependencies</title>
      <description>&lt;p&gt;Few weeks ago I started using &lt;a href="http://maven.apache.org"&gt;Maven 2&lt;/a&gt; for one of my development projects. The project is very simple, but it has dependencies with some external libraries, in particular with &lt;a href="http://www.springframework.org"&gt;Spring&lt;/a&gt;:&lt;/p&gt;

&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_xml "&gt;&lt;span class="punct"&gt;&amp;lt;&lt;/span&gt;&lt;span class="tag"&gt;dependency&lt;/span&gt;&lt;span class="punct"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="punct"&gt;&amp;lt;&lt;/span&gt;&lt;span class="tag"&gt;groupId&lt;/span&gt;&lt;span class="punct"&gt;&amp;gt;&lt;/span&gt;org.springframework&lt;span class="punct"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="tag"&gt;groupId&lt;/span&gt;&lt;span class="punct"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="punct"&gt;&amp;lt;&lt;/span&gt;&lt;span class="tag"&gt;artifactId&lt;/span&gt;&lt;span class="punct"&gt;&amp;gt;&lt;/span&gt;spring&lt;span class="punct"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="tag"&gt;artifactId&lt;/span&gt;&lt;span class="punct"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="punct"&gt;&amp;lt;&lt;/span&gt;&lt;span class="tag"&gt;version&lt;/span&gt;&lt;span class="punct"&gt;&amp;gt;&lt;/span&gt;1.2.6&lt;span class="punct"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="tag"&gt;version&lt;/span&gt;&lt;span class="punct"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="punct"&gt;&amp;lt;&lt;/span&gt;&lt;span class="tag"&gt;scope&lt;/span&gt;&lt;span class="punct"&gt;&amp;gt;&lt;/span&gt;runtime&lt;span class="punct"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="tag"&gt;scope&lt;/span&gt;&lt;span class="punct"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="punct"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="tag"&gt;dependency&lt;/span&gt;&lt;span class="punct"&gt;&amp;gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Introducing this dependency I had the following errors:&lt;/p&gt;

&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;Downloading: -&amp;gt;
    http://repo1.maven.org/maven2/javax/transaction -&amp;gt;
      /jta/1.0.1B/jta-1.0.1B.jar
[WARNING] Unable to get resource from repository central -&amp;gt;
    (http://repo1.maven.org/maven2)
...
[INFO] Failed to resolve artifact.

required artifacts missing:
 javax.transaction:jta:jar:1.0.1B&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;This happened because Spring has a transitive dependency with the Sun&amp;#8217;s JTA classes, but the JTA jar can&amp;#8217;t be inserted in the &lt;a href="http://www.ibiblio.org/maven2/"&gt;Maven repository&lt;/a&gt; because the Sun&amp;#8217;s Binary License.&lt;/p&gt;

&lt;p&gt;For solving this dependency you have to download the &lt;em&gt;jta-1_0_1B-classes.zip&lt;/em&gt; file from the &lt;a href="http://java.sun.com/products/jta/"&gt;Sun&amp;#8217;s site&lt;/a&gt; and install it into your local repository using the following command:&lt;/p&gt;

&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;mvn install:install-file \
  -Dfile=./jta-1_0_1B-classes.zip \
  -DgroupId=javax.transaction \
  -DartifactId=jta -Dversion=1.0.1B \
  -Dpackaging=jar&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;More general information in these Maven&amp;#8217;s mini guides:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="http://maven.apache.org/guides/mini/guide-coping-with-sun-jars.html"&gt;Coping with SUN JARs&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://maven.apache.org/guides/mini/guide-installing-3rd-party-jars.html"&gt;Guide to installing 3rd party JARs&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</description>
      <pubDate>Sat, 26 Nov 2005 09:06:00 -0600</pubDate>
      <guid isPermaLink="false">urn:uuid:5c3a5a64-f042-489c-bfb0-83d624c95cce</guid>
      <author>Lucio Benfante</author>
      <link>http://www.jugpadova.it/articles/2005/11/26/maven-2-spring-and-jta-depencies</link>
      <category>Tips &amp; Tricks</category>
      <category>maven</category>
      <category>spring</category>
      <category>jta</category>
      <category>dependency</category>
    </item>
    <item>
      <title>JSF and Facelets</title>
      <description>&lt;p&gt;One of the main issues with &lt;span class="caps"&gt;JSF&lt;/span&gt; is the plenty of use of custom tags in the view. If you don&amp;#8217;t want to use a visual instrument like Java Studio Creator, building a page could become a nightmare, especially if your graphic designer uses a huge amount of html components.&lt;/p&gt;


	&lt;p&gt;If you ever tried Tapestry you know that with that framework this is not a problem, when you have the html template you have only to put the proper attribute to dynamically rendered tags and it&amp;#8217;s all done.&lt;/p&gt;


	&lt;p&gt;Now also &lt;span class="caps"&gt;JSF&lt;/span&gt; allows you to do that: the project &lt;a href="https://facelets.dev.java.net/"&gt;facelets&lt;/a&gt; aims to have the same approach used when developing with Tapestry. With facelets you can use templating and write a plain html file as a view.&lt;/p&gt;
&lt;p&gt;Facelets is registered in the &lt;span class="caps"&gt;JSF&lt;/span&gt; framework as a &lt;tt&gt;ViewHandler&lt;/tt&gt;, so the only things you have to do to start using facelest are&lt;/p&gt;


	&lt;ul&gt;
	&lt;li&gt;&lt;em&gt;make &lt;span class="caps"&gt;JSF&lt;/span&gt; use facelets as ViewHandler&lt;/em&gt;: put those lines in the &lt;code&gt;faces-config.xml&lt;/code&gt;&lt;/li&gt;
	&lt;/ul&gt;


&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_xml "&gt;&lt;span class="punct"&gt;&amp;lt;&lt;/span&gt;&lt;span class="tag"&gt;faces-config&lt;/span&gt;&lt;span class="punct"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="punct"&gt;&amp;lt;&lt;/span&gt;&lt;span class="tag"&gt;application&lt;/span&gt;&lt;span class="punct"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="punct"&gt;&amp;lt;&lt;/span&gt;&lt;span class="tag"&gt;view-handler&lt;/span&gt;&lt;span class="punct"&gt;&amp;gt;&lt;/span&gt;com.sun.facelets.FaceletViewHandler&lt;span class="punct"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="tag"&gt;view-handler&lt;/span&gt;&lt;span class="punct"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="punct"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="tag"&gt;application&lt;/span&gt;&lt;span class="punct"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="punct"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="tag"&gt;faces-config&lt;/span&gt;&lt;span class="punct"&gt;&amp;gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

	&lt;ul&gt;
	&lt;li&gt;&lt;em&gt;import libraries&lt;/em&gt;: you have to put in your classpath the facelets implementation jar (jsf-facelets.jar) that you can find in the facelets&amp;#8217; site.&lt;/li&gt;
	&lt;/ul&gt;


	&lt;ul&gt;
	&lt;li&gt;&lt;em&gt;modify the &lt;span class="caps"&gt;DEFAULT&lt;/span&gt;_SUFFIX param&lt;/em&gt;: facelets pages are simple xhtml files. &lt;span class="caps"&gt;JSF&lt;/span&gt; by default uses jsp files as view, so you have to tell the framework that now the views are the xhtml files. To do this you simply modify your &lt;code&gt;web.xml&lt;/code&gt; in this way:&lt;/li&gt;
	&lt;/ul&gt;


&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_xml "&gt;&lt;span class="punct"&gt;&amp;lt;&lt;/span&gt;&lt;span class="tag"&gt;context-param&lt;/span&gt;&lt;span class="punct"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="punct"&gt;&amp;lt;&lt;/span&gt;&lt;span class="tag"&gt;param-name&lt;/span&gt;&lt;span class="punct"&gt;&amp;gt;&lt;/span&gt;javax.faces.DEFAULT_SUFFIX&lt;span class="punct"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="tag"&gt;param-name&lt;/span&gt;&lt;span class="punct"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="punct"&gt;&amp;lt;&lt;/span&gt;&lt;span class="tag"&gt;param-value&lt;/span&gt;&lt;span class="punct"&gt;&amp;gt;&lt;/span&gt;.xhtml&lt;span class="punct"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="tag"&gt;param-value&lt;/span&gt;&lt;span class="punct"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="punct"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="tag"&gt;context-param&lt;/span&gt;&lt;span class="punct"&gt;&amp;gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

	&lt;p&gt;If you don&amp;#8217;t want to become crazy with html stuff (your graphic designer is paid enough for this, isn&amp;#8217;t it?) and you want to use &lt;span class="caps"&gt;JSF&lt;/span&gt;, try out facelets. If you want to learn more about facelets &lt;a href="http://www.jsfcentral.com/articles/facelets_1.html"&gt;here&lt;/a&gt; you can find an introductive article and &lt;a href="https://facelets.dev.java.net/nonav/docs/dev/docbook.html"&gt;here&lt;/a&gt;  you&amp;#8217;ve got the reference documentation.&lt;/p&gt;</description>
      <pubDate>Tue, 22 Nov 2005 11:42:00 -0600</pubDate>
      <guid isPermaLink="false">urn:uuid:10202317-a6f6-4cc3-a51d-2649b0972340</guid>
      <author>Andrea Nasato</author>
      <link>http://www.jugpadova.it/articles/2005/11/22/jsf-and-facelets</link>
      <category>Tips &amp; Tricks</category>
      <category>JSF</category>
      <category>Facelets</category>
    </item>
  </channel>
</rss>

