<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-978841978768050379</id><updated>2024-10-07T07:05:33.554+02:00</updated><title type='text'>dometec&#39;s blog</title><subtitle type='html'>A short-post-blog where I put useful snippet of code. But not only...</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://tipsaboutmywork.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/978841978768050379/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://tipsaboutmywork.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/978841978768050379/posts/default?start-index=26&amp;max-results=25&amp;redirect=false'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/10337520217862613665</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>32</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-978841978768050379.post-5874862435868540219</id><published>2015-01-15T11:49:00.000+01:00</published><updated>2015-01-15T15:35:47.552+01:00</updated><title type='text'>Wildfly 8 - Query My MBean from bash console using twiddle</title><content type='html'>&lt;br /&gt;
[root@CloudServer1 ~]# JBOSS_HOME=/opt/wildfly-8.1.0.Final/ /opt/twiddle-standalone/bin/twiddle.sh -v -s service:jmx:http-remoting-jmx://127.0.0.1:9990 get com.azienda:Name=Statistics,Type=com.azienda.progetto.jmx.Statistics&lt;br /&gt;
11:43:11,851 INFO&amp;nbsp; [Twiddle] replacing JMX service url (service:jmx:rmi:///jndi/rmi://localhost:1090/jmxrmi) with service:jmx:http-remoting-jmx://127.0.0.1:9990&lt;br /&gt;
11:43:11,942 INFO&amp;nbsp; [xnio] XNIO version 3.2.2.Final&lt;br /&gt;
11:43:12,076 INFO&amp;nbsp; [nio] XNIO NIO Implementation Version 3.2.2.Final&lt;br /&gt;
11:43:12,207 INFO&amp;nbsp; [remoting] JBoss Remoting version 4.0.3.Final&lt;br /&gt;
CountDevice=24&lt;br /&gt;
CountDeviceOnline=15&lt;br /&gt;
CountApp={iOS=27, WindowsPhone=1, Android=16}&lt;br /&gt;
[root@CloudServer1 ~]#</content><link rel='replies' type='application/atom+xml' href='http://tipsaboutmywork.blogspot.com/feeds/5874862435868540219/comments/default' title='Commenti sul post'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/978841978768050379/5874862435868540219?isPopup=true' title='0 Commenti'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/978841978768050379/posts/default/5874862435868540219'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/978841978768050379/posts/default/5874862435868540219'/><link rel='alternate' type='text/html' href='http://tipsaboutmywork.blogspot.com/2015/01/wildfly-8-query-my-mbean-from-bash.html' title='Wildfly 8 - Query My MBean from bash console using twiddle'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/10337520217862613665</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-978841978768050379.post-3096415203146193816</id><published>2014-05-19T14:13:00.000+02:00</published><updated>2014-05-19T14:13:45.804+02:00</updated><title type='text'>Quartz 2.2.3 Liquibase table generation</title><content type='html'>&lt;a href=&quot;http://www.utilities-online.info/articles/Quartz-2.2.3-Liquibase-table-generation/&quot;&gt;Quartz 2.2.3 Liquibase table generation&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://tipsaboutmywork.blogspot.com/feeds/3096415203146193816/comments/default' title='Commenti sul post'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/978841978768050379/3096415203146193816?isPopup=true' title='0 Commenti'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/978841978768050379/posts/default/3096415203146193816'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/978841978768050379/posts/default/3096415203146193816'/><link rel='alternate' type='text/html' href='http://tipsaboutmywork.blogspot.com/2014/05/httpwww.html' title='Quartz 2.2.3 Liquibase table generation'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/10337520217862613665</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-978841978768050379.post-1426207285403336622</id><published>2014-02-04T21:40:00.002+01:00</published><updated>2014-05-19T14:14:27.095+02:00</updated><title type='text'>Mount an LVM partition image cloned with dd</title><content type='html'>&lt;a href=&quot;http://www.utilities-online.info/articles/Mount-an-LVM-partition-image-cloned-with-dd/&quot;&gt;Mount an LVM partition image cloned with dd&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://tipsaboutmywork.blogspot.com/feeds/1426207285403336622/comments/default' title='Commenti sul post'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/978841978768050379/1426207285403336622?isPopup=true' title='0 Commenti'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/978841978768050379/posts/default/1426207285403336622'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/978841978768050379/posts/default/1426207285403336622'/><link rel='alternate' type='text/html' href='http://tipsaboutmywork.blogspot.com/2014/02/blog-post_2218.html' title='Mount an LVM partition image cloned with dd'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/10337520217862613665</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-978841978768050379.post-4931487000193860744</id><published>2014-02-04T17:01:00.003+01:00</published><updated>2014-05-19T14:14:53.817+02:00</updated><title type='text'>IMS e JAIN SLEE, un’architettura per lo sviluppo di servizi di telecomunicazione a valore aggiunto (Italian)</title><content type='html'>&lt;a href=&quot;http://www.utilities-online.info/articles/Tesi-Italian&quot;&gt;IMS e JAIN SLEE, un’architettura per lo sviluppo di servizi di telecomunicazione a valore aggiunto (Italian)&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://tipsaboutmywork.blogspot.com/feeds/4931487000193860744/comments/default' title='Commenti sul post'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/978841978768050379/4931487000193860744?isPopup=true' title='0 Commenti'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/978841978768050379/posts/default/4931487000193860744'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/978841978768050379/posts/default/4931487000193860744'/><link rel='alternate' type='text/html' href='http://tipsaboutmywork.blogspot.com/2014/02/blog-post_4.html' title='IMS e JAIN SLEE, un’architettura per lo sviluppo di servizi di telecomunicazione a valore aggiunto (Italian)'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/10337520217862613665</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-978841978768050379.post-1560925305334606744</id><published>2014-02-04T16:48:00.003+01:00</published><updated>2014-05-19T14:15:03.898+02:00</updated><title type='text'>Getting started with Smart Card in Linux</title><content type='html'>&lt;a href=&quot;http://www.utilities-online.info/articles/GettingStarted-With-SmartCard-In-Linux&quot;&gt;Getting started with Smart Card in Linux&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://tipsaboutmywork.blogspot.com/feeds/1560925305334606744/comments/default' title='Commenti sul post'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/978841978768050379/1560925305334606744?isPopup=true' title='0 Commenti'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/978841978768050379/posts/default/1560925305334606744'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/978841978768050379/posts/default/1560925305334606744'/><link rel='alternate' type='text/html' href='http://tipsaboutmywork.blogspot.com/2014/02/blog-post.html' title='Getting started with Smart Card in Linux'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/10337520217862613665</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-978841978768050379.post-1440113469333776567</id><published>2013-10-09T23:07:00.002+02:00</published><updated>2013-10-09T23:07:51.355+02:00</updated><title type='text'>Empty e4 RCP Application with livemodel ready</title><content type='html'>This is the content of Application.e4xml file that represents an empty e4 application with the livemodel tool ready to show when pressed &quot;ALT+F9&quot;:

&lt;br /&gt;
&lt;br /&gt;
&lt;pre style=&quot;background-image: URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhkEkqfom-xviS-R6LpBvbYIzMEfyHkCO2_HjOuwBc-4REF2rgZc8yZLlueL3VKv2czHoDkh4OdmH6ZlCHdoG2-kT1hMgP-Q1NCL34d4ezZMZ6Bi3Cltk_NlA0y2pvTkMiIIkptz_eEnLym/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt; &amp;lt;application:application elementid=&quot;backoffice-rcp.bundle.application&quot; xmi:id=&quot;_KQrIEDEaEeOrvaIJ_du62A&quot; xmi:version=&quot;2.0&quot; xmlns:application=&quot;http://www.eclipse.org/ui/2010/UIModel/application&quot; xmlns:basic=&quot;http://www.eclipse.org/ui/2010/UIModel/application/ui/basic&quot; xmlns:xmi=&quot;http://www.omg.org/XMI&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;&amp;gt;  
  &amp;lt;children elementid=&quot;backoffice-rcp.bundle.trimmedwindow.0&quot; xmi:id=&quot;_PM_UQDEeEeOm9_xoDmNMiQ&quot; xsi:type=&quot;basic:TrimmedWindow&quot;&amp;gt;  
  &amp;lt;handlers command=&quot;_spDM0DEiEeOm9_xoDmNMiQ&quot; contributionuri=&quot;bundleclass://org.eclipse.e4.tools.emf.liveeditor/org.eclipse.e4.tools.emf.liveeditor.OpenLiveDialogHandler&quot; elementid=&quot;e4.tooling.livemodel.handler&quot; xmi:id=&quot;_j2GJcDEiEeOm9_xoDmNMiQ&quot;&amp;gt;  
  &amp;lt;bindingtables bindingcontext=&quot;_thbUYDEkEeOm9_xoDmNMiQ&quot; contributoruri=&quot;platform:/plugin/org.eclipse.platform&quot; elementid=&quot;backoffice-rcp.bundle.bindingtable.0&quot; xmi:id=&quot;_QHHA4DEjEeOm9_xoDmNMiQ&quot;&amp;gt;  
   &amp;lt;bindings command=&quot;_spDM0DEiEeOm9_xoDmNMiQ&quot; elementid=&quot;e4.tooling.livemodel.binding&quot; keysequence=&quot;ALT+F9&quot; xmi:id=&quot;_Q4ezcDEjEeOm9_xoDmNMiQ&quot;&amp;gt;  
  &amp;lt;/bindings&amp;gt;&amp;lt;/bindingtables&amp;gt;  
  &amp;lt;rootcontext description=&quot;Either a dialog or a window is open&quot; elementid=&quot;backoffice-rcp.bundle.bindingcontext.0&quot; name=&quot;In Dialogs and Windows&quot; xmi:id=&quot;_thbUYDEkEeOm9_xoDmNMiQ&quot;&amp;gt;  
  &amp;lt;commands commandname=&quot;Show running app model&quot; description=&quot;Show the running application model&quot; elementid=&quot;e4.tooling.livemodel&quot; xmi:id=&quot;_spDM0DEiEeOm9_xoDmNMiQ&quot;&amp;gt;  
  &amp;lt;addons contributionuri=&quot;bundleclass://org.eclipse.e4.core.commands/org.eclipse.e4.core.commands.CommandServiceAddon&quot; elementid=&quot;org.eclipse.e4.core.commands.service&quot; xmi:id=&quot;_KQrIETEaEeOrvaIJ_du62A&quot;&amp;gt;  
  &amp;lt;addons contributionuri=&quot;bundleclass://org.eclipse.e4.ui.services/org.eclipse.e4.ui.services.ContextServiceAddon&quot; elementid=&quot;org.eclipse.e4.ui.contexts.service&quot; xmi:id=&quot;_KQrIEjEaEeOrvaIJ_du62A&quot;&amp;gt;  
  &amp;lt;addons contributionuri=&quot;bundleclass://org.eclipse.e4.ui.bindings/org.eclipse.e4.ui.bindings.BindingServiceAddon&quot; elementid=&quot;org.eclipse.e4.ui.bindings.service&quot; xmi:id=&quot;_KQrIEzEaEeOrvaIJ_du62A&quot;&amp;gt;  
  &amp;lt;addons contributionuri=&quot;bundleclass://org.eclipse.e4.ui.workbench/org.eclipse.e4.ui.internal.workbench.addons.CommandProcessingAddon&quot; elementid=&quot;org.eclipse.e4.ui.workbench.commands.model&quot; xmi:id=&quot;_KQrIFDEaEeOrvaIJ_du62A&quot;&amp;gt;  
  &amp;lt;addons contributionuri=&quot;bundleclass://org.eclipse.e4.ui.workbench/org.eclipse.e4.ui.internal.workbench.addons.ContextProcessingAddon&quot; elementid=&quot;org.eclipse.e4.ui.workbench.contexts.model&quot; xmi:id=&quot;_KQrIFTEaEeOrvaIJ_du62A&quot;&amp;gt;  
  &amp;lt;addons contributionuri=&quot;bundleclass://org.eclipse.e4.ui.workbench.swt/org.eclipse.e4.ui.workbench.swt.util.BindingProcessingAddon&quot; elementid=&quot;org.eclipse.e4.ui.workbench.bindings.model&quot; xmi:id=&quot;_KQrIFjEaEeOrvaIJ_du62A&quot;&amp;gt;  
  &amp;lt;addons contributionuri=&quot;bundleclass://org.eclipse.e4.ui.workbench/org.eclipse.e4.ui.internal.workbench.addons.HandlerProcessingAddon&quot; elementid=&quot;org.eclipse.e4.ui.workbench.handler.model&quot; xmi:id=&quot;_KQrIFzEaEeOrvaIJ_du62A&quot;&amp;gt;  
 &amp;lt;/addons&amp;gt;&amp;lt;/addons&amp;gt;&amp;lt;/addons&amp;gt;&amp;lt;/addons&amp;gt;&amp;lt;/addons&amp;gt;&amp;lt;/addons&amp;gt;&amp;lt;/addons&amp;gt;&amp;lt;/commands&amp;gt;&amp;lt;/rootcontext&amp;gt;&amp;lt;/handlers&amp;gt;&amp;lt;/children&amp;gt;&amp;lt;/application:application&amp;gt;  
&lt;/code&gt;&lt;/pre&gt;
</content><link rel='replies' type='application/atom+xml' href='http://tipsaboutmywork.blogspot.com/feeds/1440113469333776567/comments/default' title='Commenti sul post'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/978841978768050379/1440113469333776567?isPopup=true' title='0 Commenti'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/978841978768050379/posts/default/1440113469333776567'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/978841978768050379/posts/default/1440113469333776567'/><link rel='alternate' type='text/html' href='http://tipsaboutmywork.blogspot.com/2013/10/empty-e4-rcp-application-with-livemodel.html' title='Empty e4 RCP Application with livemodel ready'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/10337520217862613665</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-978841978768050379.post-8099451196149871728</id><published>2013-10-06T11:52:00.003+02:00</published><updated>2013-10-06T11:52:57.162+02:00</updated><title type='text'>Create a PyQt tray icon to send UDP Datagram</title><content type='html'>&lt;a href=&quot;http://www.utilities-online.info/articles/Create-a-PyQt-tray-icon-to-send-UDP-Datagram/&quot;&gt;Create a PyQt tray icon to send UDP Datagram&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://tipsaboutmywork.blogspot.com/feeds/8099451196149871728/comments/default' title='Commenti sul post'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/978841978768050379/8099451196149871728?isPopup=true' title='0 Commenti'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/978841978768050379/posts/default/8099451196149871728'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/978841978768050379/posts/default/8099451196149871728'/><link rel='alternate' type='text/html' href='http://tipsaboutmywork.blogspot.com/2013/10/create-pyqt-tray-icon-to-send-udp.html' title='Create a PyQt tray icon to send UDP Datagram'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/10337520217862613665</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-978841978768050379.post-4483478014148367176</id><published>2013-05-20T07:41:00.000+02:00</published><updated>2013-05-26T07:57:13.186+02:00</updated><title type='text'>Error mounting ext3 partition: no journal found</title><content type='html'>After some power failures, I can&#39;t mount my HDD ext3 partition.&lt;br /&gt;
The kernel says:&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
EXT4-fs (sde1): mounting ext3 file system using the ext4 subsystem&lt;br /&gt;
EXT4-fs error (device sde1): ext4_iget:3889: inode #8: comm mount: bad extra_isize (33280 != 256)&lt;br /&gt;
EXT4-fs (sde1): no journal found&amp;nbsp;&lt;/blockquote&gt;
&lt;br /&gt;
The solution was to recreate the journal of ext33 partition (from &lt;a href=&quot;http://www.watters.ws/mediawiki/index.php/Repair_ext3_journal_errors&quot;&gt;http://www.watters.ws/mediawiki/index.php/Repair_ext3_journal_errors&lt;/a&gt;):&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
tune2fs -O ^has_journal /dev/sdXY&lt;br /&gt;
&lt;br /&gt;
e2fsck -f /dev/sdXY&lt;br /&gt;
&lt;br /&gt;
tune2fs -j /dev/sdXY&amp;nbsp;&lt;/blockquote&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://tipsaboutmywork.blogspot.com/feeds/4483478014148367176/comments/default' title='Commenti sul post'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/978841978768050379/4483478014148367176?isPopup=true' title='0 Commenti'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/978841978768050379/posts/default/4483478014148367176'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/978841978768050379/posts/default/4483478014148367176'/><link rel='alternate' type='text/html' href='http://tipsaboutmywork.blogspot.com/2013/05/error-mounting-ext3-partition-no.html' title='Error mounting ext3 partition: no journal found'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/10337520217862613665</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-978841978768050379.post-6688002576607808654</id><published>2013-02-17T16:52:00.001+01:00</published><updated>2013-02-17T16:52:05.108+01:00</updated><title type='text'>IpadCharge on Fedora 18 </title><content type='html'>If you installed with you ipad_charge and it dowsn&#39;t work, try to update che /etc/udev/95-ipad_charge.rules with the last one from https://github.com/mkorenkov/ipad_charge. </content><link rel='replies' type='application/atom+xml' href='http://tipsaboutmywork.blogspot.com/feeds/6688002576607808654/comments/default' title='Commenti sul post'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/978841978768050379/6688002576607808654?isPopup=true' title='0 Commenti'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/978841978768050379/posts/default/6688002576607808654'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/978841978768050379/posts/default/6688002576607808654'/><link rel='alternate' type='text/html' href='http://tipsaboutmywork.blogspot.com/2013/02/ipadcharge-on-fedora-18.html' title='IpadCharge on Fedora 18 '/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/10337520217862613665</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-978841978768050379.post-7089099927808210342</id><published>2012-11-11T19:11:00.001+01:00</published><updated>2012-11-11T19:11:05.971+01:00</updated><title type='text'>Redeploy war in Tomcat 7 using curl and bash</title><content type='html'>&lt;pre style=&quot;background-image: URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhkEkqfom-xviS-R6LpBvbYIzMEfyHkCO2_HjOuwBc-4REF2rgZc8yZLlueL3VKv2czHoDkh4OdmH6ZlCHdoG2-kT1hMgP-Q1NCL34d4ezZMZ6Bi3Cltk_NlA0y2pvTkMiIIkptz_eEnLym/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt;
 curl -T - -u user:password &#39;http://servername:8000/manager/text/deploy?update=true&amp;amp;path=/webapp&#39; &amp;lt; webapp.war  

&lt;/code&gt;&lt;/pre&gt;
</content><link rel='replies' type='application/atom+xml' href='http://tipsaboutmywork.blogspot.com/feeds/7089099927808210342/comments/default' title='Commenti sul post'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/978841978768050379/7089099927808210342?isPopup=true' title='0 Commenti'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/978841978768050379/posts/default/7089099927808210342'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/978841978768050379/posts/default/7089099927808210342'/><link rel='alternate' type='text/html' href='http://tipsaboutmywork.blogspot.com/2012/11/redeploy-war-in-tomcat-7-using-curl-and.html' title='Redeploy war in Tomcat 7 using curl and bash'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/10337520217862613665</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-978841978768050379.post-7142026656751265751</id><published>2012-07-17T00:26:00.000+02:00</published><updated>2012-09-01T16:22:38.791+02:00</updated><title type='text'>Hardware reverse engineering - GSM Modem Da Sistemi MT0124</title><content type='html'>I bought this printed circuit board in an electronics fair. It contains a well documented GSM module by Telit and a &lt;span class=&quot;short_text&quot; id=&quot;result_box&quot; lang=&quot;en&quot;&gt;&lt;span class=&quot;hps&quot;&gt;handful&lt;/span&gt; &lt;span class=&quot;hps&quot;&gt;of components for its powering and RS232 serial level converter (from CMOS level 2.8Volt to RS232 7.5Volt):&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhAeXK94LORt9OKUAy3DvM-APB-ZTWI4EqEmiZcgveyB52A7QLOaq17SwgNRoHeRT1JvXXlvuxxznkmFMhvPop0ALgFgXu09d4ILv2uNqHKEpXXXiVffvDzGm3VXhMiqhVivN8PidqxGX0/s1600/Da_Sistemi_MT0124.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;203&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhAeXK94LORt9OKUAy3DvM-APB-ZTWI4EqEmiZcgveyB52A7QLOaq17SwgNRoHeRT1JvXXlvuxxznkmFMhvPop0ALgFgXu09d4ILv2uNqHKEpXXXiVffvDzGm3VXhMiqhVivN8PidqxGX0/s320/Da_Sistemi_MT0124.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;span class=&quot;short_text&quot; id=&quot;result_box&quot; lang=&quot;en&quot;&gt;&lt;span class=&quot;hps&quot;&gt;Even if the GSM module is well documented and even if &lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;&quot; id=&quot;result_box&quot; lang=&quot;en&quot;&gt;&lt;span class=&quot;hps&quot;&gt;the&lt;/span&gt; &lt;span class=&quot;hps&quot;&gt;salesman&lt;/span&gt; &lt;span class=&quot;hps&quot;&gt;assured me that&lt;/span&gt; &lt;span class=&quot;hps&quot;&gt;I&#39;d find&lt;/span&gt; &lt;span class=&quot;hps&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;short_text&quot; id=&quot;result_box&quot; lang=&quot;en&quot;&gt;&lt;span class=&quot;hps&quot;&gt;the electric schema of circuit board&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;&quot; id=&quot;result_box&quot; lang=&quot;en&quot;&gt;&lt;span class=&quot;hps&quot;&gt; on the Internet&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;short_text&quot; id=&quot;result_box&quot; lang=&quot;en&quot;&gt;&lt;span class=&quot;hps&quot;&gt;, I not found it, and&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;short_text&quot; id=&quot;result_box&quot; lang=&quot;en&quot;&gt;&lt;span class=&quot;hps&quot;&gt; I had to&lt;/span&gt; &lt;span class=&quot;hps&quot;&gt;spend 10&lt;/span&gt; &lt;span class=&quot;hps&quot;&gt;hours to make&lt;/span&gt; &lt;span class=&quot;hps&quot;&gt;the&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;short_text&quot; id=&quot;result_box&quot; lang=&quot;en&quot;&gt;&lt;span class=&quot;hps&quot;&gt; reverse engineering of pin out.&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;short_text&quot; id=&quot;result_box&quot; lang=&quot;en&quot;&gt;&lt;span class=&quot;hps&quot;&gt;This are the pin functions:&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;short_text&quot; id=&quot;result_box&quot; lang=&quot;en&quot;&gt;&lt;span class=&quot;hps&quot;&gt;1. +Vcc (it works from 6 to 12 Volt)&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;short_text&quot; id=&quot;result_box&quot; lang=&quot;en&quot;&gt;&lt;span class=&quot;hps&quot;&gt;2. bypass to RJ45 connector&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;short_text&quot; id=&quot;result_box&quot; lang=&quot;en&quot;&gt;&lt;span class=&quot;hps&quot;&gt;3. Serial DCD (out from pcb) &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;short_text&quot; id=&quot;result_box&quot; lang=&quot;en&quot;&gt;&lt;span class=&quot;hps&quot;&gt;4. Serial DTR (in)&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;short_text&quot; id=&quot;result_box&quot; lang=&quot;en&quot;&gt;&lt;span class=&quot;hps&quot;&gt;5. Serial CTS (out)&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;short_text&quot; id=&quot;result_box&quot; lang=&quot;en&quot;&gt;&lt;span class=&quot;hps&quot;&gt;6. Serial RTS (in)&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;short_text&quot; id=&quot;result_box&quot; lang=&quot;en&quot;&gt;&lt;span class=&quot;hps&quot;&gt;7. Serial RX (out)&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;short_text&quot; id=&quot;result_box&quot; lang=&quot;en&quot;&gt;&lt;span class=&quot;hps&quot;&gt;8. Serial TX (in)&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;short_text&quot; id=&quot;result_box&quot; lang=&quot;en&quot;&gt;&lt;span class=&quot;hps&quot;&gt;9. Reset&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;short_text&quot; id=&quot;result_box&quot; lang=&quot;en&quot;&gt;&lt;span class=&quot;hps&quot;&gt;10. ON/OFF (pull up, 1 sec to GND to switch on/off the GSM module)&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;short_text&quot; id=&quot;result_box&quot; lang=&quot;en&quot;&gt;&lt;span class=&quot;hps&quot;&gt;11. bypass to RJ45 connector&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;short_text&quot; id=&quot;result_box&quot; lang=&quot;en&quot;&gt;&lt;span class=&quot;hps&quot;&gt;&lt;br /&gt;12. GND&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;short_text&quot; id=&quot;result_box&quot; lang=&quot;en&quot;&gt;&lt;span class=&quot;hps&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;short_text&quot; id=&quot;result_box&quot; lang=&quot;en&quot;&gt;&lt;span class=&quot;hps&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://tipsaboutmywork.blogspot.com/feeds/7142026656751265751/comments/default' title='Commenti sul post'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/978841978768050379/7142026656751265751?isPopup=true' title='8 Commenti'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/978841978768050379/posts/default/7142026656751265751'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/978841978768050379/posts/default/7142026656751265751'/><link rel='alternate' type='text/html' href='http://tipsaboutmywork.blogspot.com/2012/07/hardware-reverse-engineering-gsm-modem.html' title='Hardware reverse engineering - GSM Modem Da Sistemi MT0124'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/10337520217862613665</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhAeXK94LORt9OKUAy3DvM-APB-ZTWI4EqEmiZcgveyB52A7QLOaq17SwgNRoHeRT1JvXXlvuxxznkmFMhvPop0ALgFgXu09d4ILv2uNqHKEpXXXiVffvDzGm3VXhMiqhVivN8PidqxGX0/s72-c/Da_Sistemi_MT0124.jpg" height="72" width="72"/><thr:total>8</thr:total></entry><entry><id>tag:blogger.com,1999:blog-978841978768050379.post-5870419561911199228</id><published>2012-06-07T23:30:00.000+02:00</published><updated>2012-06-07T23:30:02.724+02:00</updated><title type='text'>Get the Realm (or LoginService) instance from a ServletConxtext in Tomcat 7 and Jetty 7.5</title><content type='html'>Container-Managed Authentication is not always the best choose for implement security in web application. A typical example is when an home page have to be personalized if the current user is logged or not. With Container Managed Security, if a page isn&#39;t protected by a security-constraint, also if the current user is logged, the &lt;a href=&quot;http://docs.oracle.com/javaee/5/api/javax/servlet/http/HttpServletRequest.html#getUserPrincipal%28%29&quot;&gt;request.getUserPrinipal()&lt;/a&gt; is null.&lt;br /&gt;
See &lt;a href=&quot;http://stackoverflow.com/questions/7795012/request-getuserprincipal-got-null&quot;&gt;http://stackoverflow.com/questions/7795012/request-getuserprincipal-got-null&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
A way to skip over the problem is to implement Application-Managed Authentication in web application. This means that web-app developer have to implements authentication/authorization.&lt;br /&gt;
&lt;br /&gt;
But not everything is lost! We can reuse the Realm configured within application server to authenticate/authorize application&#39;s users.&lt;br /&gt;
There are two snippet of code that retrieve the Realm authenticator from ServletContext.&lt;br /&gt;
&lt;br /&gt;
Get &lt;b&gt;Tomcat 7 &lt;/b&gt;Realm from ServletContext:&lt;br /&gt;
&lt;br /&gt;
&lt;pre style=&quot;background-image: URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhkEkqfom-xviS-R6LpBvbYIzMEfyHkCO2_HjOuwBc-4REF2rgZc8yZLlueL3VKv2czHoDkh4OdmH6ZlCHdoG2-kT1hMgP-Q1NCL34d4ezZMZ6Bi3Cltk_NlA0y2pvTkMiIIkptz_eEnLym/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt; ApplicationContextFacade acf = (ApplicationContextFacade) servletContext;  
 Field privateField = ApplicationContextFacade.class.getDeclaredField(&quot;context&quot;);  
 privateField.setAccessible(true);  
 ApplicationContext appContext = (ApplicationContext) privateField.get(acf);  
 Field privateField2 = ApplicationContext.class.getDeclaredField(&quot;context&quot;);  
 privateField2.setAccessible(true);  
 StandardContext stdContext = (StandardContext) privateField2.get(appContext);  
 realm = stdContext.getRealm();  
&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
The realm variable is an instance of org.apache.catalina.Realm, and you can call on this the &lt;a href=&quot;http://tomcat.apache.org/tomcat-7.0-doc/api/org/apache/catalina/Realm.html#authenticate%28java.lang.String,%20java.lang.String%29&quot;&gt;authenticate&lt;/a&gt; method to authenticate and get roles of users:&lt;br /&gt;
&lt;br /&gt;
&lt;pre style=&quot;background-image: URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhkEkqfom-xviS-R6LpBvbYIzMEfyHkCO2_HjOuwBc-4REF2rgZc8yZLlueL3VKv2czHoDkh4OdmH6ZlCHdoG2-kT1hMgP-Q1NCL34d4ezZMZ6Bi3Cltk_NlA0y2pvTkMiIIkptz_eEnLym/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt; Principal principal = realm.authenticate(user, password);  
 if (principal == null)  
    return null;  
 GenericPrincipal genericPrincipal = (GenericPrincipal) principal;  
 return new DemoPrincipal(principal, genericPrincipal.getRoles());  
&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
This is the counter part for &lt;b&gt;Jetty 7.5&lt;/b&gt;. Be ware that normally Jetty don&#39;t allow to reach the container classes from web application class loader, we need to disable this option, see &lt;a href=&quot;http://docs.codehaus.org/display/JETTY/Classloading&quot;&gt;http://docs.codehaus.org/display/JETTY/Classloading&lt;/a&gt;.
&lt;br /&gt;
&lt;pre style=&quot;background-image: URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhkEkqfom-xviS-R6LpBvbYIzMEfyHkCO2_HjOuwBc-4REF2rgZc8yZLlueL3VKv2czHoDkh4OdmH6ZlCHdoG2-kT1hMgP-Q1NCL34d4ezZMZ6Bi3Cltk_NlA0y2pvTkMiIIkptz_eEnLym/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt; WebAppContext.Context context = ((org.eclipse.jetty.webapp.WebAppContext.Context) servletContext);  
 ContextHandler contextHandler = context.getContextHandler();  
 ConstraintSecurityHandler securityHandler = contextHandler  
       .getChildHandlerByClass(org.eclipse.jetty.security.ConstraintSecurityHandler.class);  
 loginService = securityHandler.getLoginService();  
&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;pre style=&quot;background-image: URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhkEkqfom-xviS-R6LpBvbYIzMEfyHkCO2_HjOuwBc-4REF2rgZc8yZLlueL3VKv2czHoDkh4OdmH6ZlCHdoG2-kT1hMgP-Q1NCL34d4ezZMZ6Bi3Cltk_NlA0y2pvTkMiIIkptz_eEnLym/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt; UserIdentity login = loginService.login(user, password);  
 if (login == null)  
     return null;  
 Principal principal = login.getUserPrincipal();  
 Field privateField = DefaultUserIdentity.class.getDeclaredField(&quot;_roles&quot;);  
 privateField.setAccessible(true);  
 String[] roles = (String[]) privateField.get(login);    
 return new DemoPrincipal(principal, roles);
&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
I use Jetty with maven, this is may configuration:
&lt;br /&gt;
&lt;pre style=&quot;background-image: URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhkEkqfom-xviS-R6LpBvbYIzMEfyHkCO2_HjOuwBc-4REF2rgZc8yZLlueL3VKv2czHoDkh4OdmH6ZlCHdoG2-kT1hMgP-Q1NCL34d4ezZMZ6Bi3Cltk_NlA0y2pvTkMiIIkptz_eEnLym/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt; &amp;lt;plugin&amp;gt;  
      &amp;lt;groupId&amp;gt;org.mortbay.jetty&amp;lt;/groupId&amp;gt;  
      &amp;lt;artifactId&amp;gt;jetty-maven-plugin&amp;lt;/artifactId&amp;gt;  
      &amp;lt;version&amp;gt;${jetty.version}&amp;lt;/version&amp;gt;  
      &amp;lt;configuration&amp;gt;  
           &amp;lt;loginServices&amp;gt;  
                &amp;lt;loginService implementation=&quot;org.eclipse.jetty.security.HashLoginService&quot;&amp;gt;  
                     &amp;lt;name&amp;gt;MyRealm&amp;lt;/name&amp;gt;  
                     &amp;lt;config&amp;gt;${basedir}/src/main/resources/jetty-realm.properties&amp;lt;/config&amp;gt;  
                &amp;lt;/loginService&amp;gt;  
           &amp;lt;/loginServices&amp;gt;  
           &amp;lt;scanIntervalSeconds&amp;gt;1000&amp;lt;/scanIntervalSeconds&amp;gt;  
           &amp;lt;webAppConfig&amp;gt;  
                &amp;lt;serverClasses&amp;gt;  
                     &amp;lt;serverClass implementation=&quot;java.lang.String&quot;&amp;gt;  
                          -org.eclipse.jetty.  
                     &amp;lt;/serverClass&amp;gt;  
                &amp;lt;/serverClasses&amp;gt;  
           &amp;lt;/webAppConfig&amp;gt;  
      &amp;lt;/configuration&amp;gt;  
 &amp;lt;/plugin&amp;gt;  
&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://tipsaboutmywork.blogspot.com/feeds/5870419561911199228/comments/default' title='Commenti sul post'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/978841978768050379/5870419561911199228?isPopup=true' title='0 Commenti'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/978841978768050379/posts/default/5870419561911199228'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/978841978768050379/posts/default/5870419561911199228'/><link rel='alternate' type='text/html' href='http://tipsaboutmywork.blogspot.com/2012/06/get-realm-or-loginservice-instance-from.html' title='Get the Realm (or LoginService) instance from a ServletConxtext in Tomcat 7 and Jetty 7.5'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/10337520217862613665</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-978841978768050379.post-855698922521688520</id><published>2012-06-05T22:30:00.000+02:00</published><updated>2015-01-02T09:38:16.733+01:00</updated><title type='text'>Tell your browser to ask for save password in web AJAX login</title><content type='html'>Store password in browser is a useful functionality, the browser intercept the POST action of form and under a few condition (browser dependent) ask to store password. &lt;br /&gt;
&lt;br /&gt;
Unfortunately, this mechanism don&#39;t works well when you implement a RIA (Rich Internet Application) and use AJAX call for authenticate users because your submit through XHR and not by html form submit.&lt;br /&gt;
&lt;br /&gt;
I use a simple trick to show password store request from browser. After the AJAX login request complete, if the user is successful authenticate, submit the login form to a url that return a HTTP 204 status (204 NO CONTENT). The browser ask to save password but the user does not navigate anywhere else.&lt;br /&gt;
&lt;br /&gt;
This is an example:&lt;br /&gt;
&lt;br /&gt;
&lt;pre style=&quot;background-image: URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhkEkqfom-xviS-R6LpBvbYIzMEfyHkCO2_HjOuwBc-4REF2rgZc8yZLlueL3VKv2czHoDkh4OdmH6ZlCHdoG2-kT1hMgP-Q1NCL34d4ezZMZ6Bi3Cltk_NlA0y2pvTkMiIIkptz_eEnLym/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt;         &amp;lt;form method=&quot;post&quot; action=&quot;http://demo.utilities-online.info/backend/none&quot;&amp;gt;  
           Username: &amp;lt;input id=&quot;username&quot; type=&quot;text&quot; name=&quot;username&quot;&amp;gt;&amp;lt;br/&amp;gt;  
           Password: &amp;lt;input id=&quot;password&quot; type=&quot;password&quot; name=&quot;password&quot;&amp;gt;&amp;lt;br/&amp;gt;  
           &amp;lt;input type=&quot;button&quot; value=&quot;login&quot; onclick=&quot;sendRequest();&quot;&amp;gt;  
         &amp;lt;/form&amp;gt;  
&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
try now!&lt;br /&gt;
&lt;br /&gt;
&lt;form action=&quot;http://www.utilities-online.info/backend/none&quot; method=&quot;post&quot; style=&quot;border: black solid 1px; padding: 5px;&quot;&gt;
Username: &lt;input id=&quot;username&quot; name=&quot;username&quot; type=&quot;text&quot; /&gt;&lt;br /&gt;
Password: &lt;input id=&quot;password&quot; name=&quot;password&quot; type=&quot;password&quot; /&gt;&lt;br /&gt;
&lt;input type=&quot;submit&quot; /&gt;
&lt;/form&gt;
&lt;br /&gt;
&lt;br /&gt;
Enjoy with AJAX!</content><link rel='replies' type='application/atom+xml' href='http://tipsaboutmywork.blogspot.com/feeds/855698922521688520/comments/default' title='Commenti sul post'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/978841978768050379/855698922521688520?isPopup=true' title='0 Commenti'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/978841978768050379/posts/default/855698922521688520'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/978841978768050379/posts/default/855698922521688520'/><link rel='alternate' type='text/html' href='http://tipsaboutmywork.blogspot.com/2012/06/tell-your-browser-to-ask-for-save.html' title='Tell your browser to ask for save password in web AJAX login'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/10337520217862613665</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-978841978768050379.post-1941756885243239476</id><published>2012-03-08T20:06:00.001+01:00</published><updated>2012-03-08T20:06:05.402+01:00</updated><title type='text'>BIRT segmentation fault on linux</title><content type='html'>I&#39;m running BIRT in my box and experienced, several times, code dump of JVM with&amp;nbsp;segmentation fault.&lt;br /&gt;
A problem go away when I added some options of JVM:&lt;br /&gt;
&lt;b&gt;-Xss256k -XX:MaxPermSize=384m&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Software version:&lt;br /&gt;
Fedora 16&lt;br /&gt;
JVM 1.7.0_03&lt;br /&gt;
Tomcat 17.0.25&lt;br /&gt;
BIRT 3.7.1</content><link rel='replies' type='application/atom+xml' href='http://tipsaboutmywork.blogspot.com/feeds/1941756885243239476/comments/default' title='Commenti sul post'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/978841978768050379/1941756885243239476?isPopup=true' title='0 Commenti'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/978841978768050379/posts/default/1941756885243239476'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/978841978768050379/posts/default/1941756885243239476'/><link rel='alternate' type='text/html' href='http://tipsaboutmywork.blogspot.com/2012/03/birt-segmentation-fault-on-linux.html' title='BIRT segmentation fault on linux'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/10337520217862613665</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-978841978768050379.post-2802824208124334964</id><published>2012-03-04T18:25:00.000+01:00</published><updated>2012-03-04T18:37:29.830+01:00</updated><title type='text'>Non concurrent HTTP requests on Cluster with Infinispan</title><content type='html'>&lt;br /&gt;
On Server-Client Architecture there are two type of call, one that only retrieve information from server (Read-Only) and one that can also change server&#39;s status (R/W).&lt;br /&gt;
Tipically, the first one can run in concurrency, also with the same parameters, without problem (also maybe a performance increase by cache system).&lt;br /&gt;
The second one changes the internal server&#39;s status, create file, update database and so on. And, when several calls with same parametres reach the server simoultaneusly, problems often can occur.&lt;br /&gt;
When the client is a browser this problem can be mitigated with javascript, disabling button once clicked for example, but cannot be eliminated. Worse if your client isn&#39;t a browser.&lt;br /&gt;
There is my solution, adopted on a cluster of four machine using &lt;a href=&quot;http://www.jboss.org/infinispan&quot;&gt;JBoss Infinispan&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
In my webapp I use Jersey + Guice to serve request, this is a simple class that manage POST request:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;pre style=&quot;background-image: URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhkEkqfom-xviS-R6LpBvbYIzMEfyHkCO2_HjOuwBc-4REF2rgZc8yZLlueL3VKv2czHoDkh4OdmH6ZlCHdoG2-kT1hMgP-Q1NCL34d4ezZMZ6Bi3Cltk_NlA0y2pvTkMiIIkptz_eEnLym/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt;      @POST  
      @Path(&quot;mpay&quot;)  
      @Produces(MEDIATYPE_WEBPAGEUTF8)  
      public Object landMPay(@QueryParam(&quot;TransactionID&quot;) String transactionId, @QueryParam(&quot;ResultCode&quot;) String resultcode) {  
           logger.debug(&quot;Get user from token, {}.&quot;, transactionId);  
           .
           .
           .
&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
Now I want only one concurrent call with same TransactionId parameter. I created two annotation, one for Method (@UniqueCallOnCluster) and ane for Parameter (@KeyParameter).&lt;br /&gt;
I use first annotation as:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;pre style=&quot;background-image: URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhkEkqfom-xviS-R6LpBvbYIzMEfyHkCO2_HjOuwBc-4REF2rgZc8yZLlueL3VKv2czHoDkh4OdmH6ZlCHdoG2-kT1hMgP-Q1NCL34d4ezZMZ6Bi3Cltk_NlA0y2pvTkMiIIkptz_eEnLym/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt;      @POST  
      @Path(&quot;mpay&quot;)  
      @UniqueCallOnCluster
      @Produces(MEDIATYPE_WEBPAGEUTF8)  
      public Object landMPay(@QueryParam(&quot;TransactionID&quot;) String transactionId, @QueryParam(&quot;ResultCode&quot;) String resultcode) {  
           logger.debug(&quot;Get user from token, {}.&quot;, transactionId);  
           .
           .
           .
&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
to permit only one concurrent call with all same parameters. But I want to permit only one concurrent call with same TransactionId parameter, ignoring ResultCode values:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;pre style=&quot;background-image: URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhkEkqfom-xviS-R6LpBvbYIzMEfyHkCO2_HjOuwBc-4REF2rgZc8yZLlueL3VKv2czHoDkh4OdmH6ZlCHdoG2-kT1hMgP-Q1NCL34d4ezZMZ6Bi3Cltk_NlA0y2pvTkMiIIkptz_eEnLym/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt;      @POST  
      @Path(&quot;mpay&quot;)  
      @UniqueCallOnCluster
      @Produces(MEDIATYPE_WEBPAGEUTF8)  
      public Object landMPay(@KeyParameter @QueryParam(&quot;TransactionID&quot;) String transactionId, @QueryParam(&quot;ResultCode&quot;) String resultcode) {  
           logger.debug(&quot;Get user from token, {}.&quot;, transactionId);  
           .
           .
           .
&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
The interceptor that manage this annotations use Infinispan to tell other server that him is starting to serve this call with this parameter/s:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;pre style=&quot;background-image: URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhkEkqfom-xviS-R6LpBvbYIzMEfyHkCO2_HjOuwBc-4REF2rgZc8yZLlueL3VKv2czHoDkh4OdmH6ZlCHdoG2-kT1hMgP-Q1NCL34d4ezZMZ6Bi3Cltk_NlA0y2pvTkMiIIkptz_eEnLym/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt; 
 import java.lang.annotation.Annotation;  
 import java.util.ArrayList;  
 import java.util.List;  
 import javax.transaction.TransactionManager;  
 import javax.ws.rs.core.Response;  
 import javax.ws.rs.core.Response.Status;  
 import org.aopalliance.intercept.MethodInterceptor;  
 import org.aopalliance.intercept.MethodInvocation;  
 import com.google.common.base.Joiner;  
 import com.google.inject.Inject;  


 public class UniqueCallOnClusterInterceptor implements MethodInterceptor {  


      @Inject  
      private Constants constants;  


      @Inject  
      private KeyCallOnClusterService keyCallOnClusterService;  


      public Object invoke(MethodInvocation invocation) throws Throwable {  

  
           String classname = invocation.getMethod().getDeclaringClass().getSimpleName();  
           String methodName = invocation.getMethod().getName();  
           String key = classname + &quot;_&quot; + methodName + &quot;_&quot; + extractParameterValue(invocation);  
           TransactionManager tm = keyCallOnClusterService.getTransactionManager();  

      
           try {  
                if (tm != null) {  
                     tm.begin();  
                     boolean success = keyCallOnClusterService.lock(key);  
                     if (!success) {  
                          return Response.status(Status.CONFLICT).entity(&quot;Another call with same parameter is in progress.&quot;).build();  
                     }  
                }  
                String runningServer = (String) keyCallOnClusterService.get(key);  
                if (runningServer != null) {  
                     return Response.status(Status.CONFLICT).entity(&quot;Another call with same parameter is in progress.&quot;).build();  
                }  
                keyCallOnClusterService.put(key, constants.getHostname());  
           } finally {  
                if (tm != null)  
                     tm.commit();  
           }  


           try {  
                return invocation.proceed();  
           } finally {  
                keyCallOnClusterService.remove(key);  
           }  
      }  


      public String extractParameterValue(MethodInvocation invocation) {  
           List&amp;lt;String&amp;gt; list = new ArrayList&amp;lt;String&amp;gt;();  
           Annotation[][] parameterAnnotations = invocation.getMethod().getParameterAnnotations();  
           for (int i = 0; i &amp;lt; parameterAnnotations.length; i++) {  
                Annotation[] annotations = parameterAnnotations[i];  
                for (int j = 0; j &amp;lt; annotations.length; j++) {  
                     Annotation annotation = annotations[j];  
                     if (annotation instanceof KeyParameter) {  
                          list.add(String.valueOf(invocation.getArguments()[i]));  
                          break;  
                     }  
                }  
           }  
           if (list.size() == 0)  
                return Joiner.on(&quot;, &quot;).useForNull(&quot;null&quot;).join(invocation.getArguments());  
           return Joiner.on(&quot;, &quot;).useForNull(&quot;null&quot;).join(list);  
      }  
 }  
&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
The KeyCallOnClusterService class is a facility for the Infinispan&#39;s Cache Object.&lt;br /&gt;
Here the configuration of Infinispan:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;pre style=&quot;background-image: URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhkEkqfom-xviS-R6LpBvbYIzMEfyHkCO2_HjOuwBc-4REF2rgZc8yZLlueL3VKv2czHoDkh4OdmH6ZlCHdoG2-kT1hMgP-Q1NCL34d4ezZMZ6Bi3Cltk_NlA0y2pvTkMiIIkptz_eEnLym/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt; &amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&amp;gt;  
 &amp;lt;infinispan xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;  
      xsi:schemaLocation=&quot;urn:infinispan:config:5.1 http://www.infinispan.org/schemas/infinispan-config-5.1.xsd&quot;  
      xmlns=&quot;urn:infinispan:config:5.1&quot;&amp;gt;  
      &amp;lt;global&amp;gt;  
           &amp;lt;globalJmxStatistics enabled=&quot;true&quot;  
                allowDuplicateDomains=&quot;true&quot;&amp;gt;&amp;lt;/globalJmxStatistics&amp;gt;  
           &amp;lt;transport clusterName=&quot;cluster&quot;  
                distributedSyncTimeout=&quot;3000&quot;&amp;gt;  
                &amp;lt;properties&amp;gt;  
                     &amp;lt;property name=&quot;configurationFile&quot; value=&quot;infinispan-udp.cfg.xml&quot; /&amp;gt;  
                &amp;lt;/properties&amp;gt;  
           &amp;lt;/transport&amp;gt;  
           &amp;lt;shutdown hookBehavior=&quot;DONT_REGISTER&quot; /&amp;gt;  
      &amp;lt;/global&amp;gt;  
      &amp;lt;namedCache name=&quot;current-call-cache&quot;&amp;gt;  
           &amp;lt;jmxStatistics enabled=&quot;true&quot; /&amp;gt;  
           &amp;lt;transaction transactionMode=&quot;TRANSACTIONAL&quot; lockingMode=&quot;PESSIMISTIC&quot;  
                transactionManagerLookupClass=&quot;org.infinispan.transaction.lookup.GenericTransactionManagerLookup&quot;&amp;gt;&amp;lt;/transaction&amp;gt;  
           &amp;lt;locking isolationLevel=&quot;REPEATABLE_READ&quot; useLockStriping=&quot;false&quot; /&amp;gt;  
           &amp;lt;eviction strategy=&quot;LRU&quot; maxEntries=&quot;600&quot; /&amp;gt;  
           &amp;lt;!-- Due minuti --&amp;gt;  
           &amp;lt;expiration lifespan=&quot;120000&quot; /&amp;gt;  
           &amp;lt;storeAsBinary enabled=&quot;true&quot; /&amp;gt;  
           &amp;lt;clustering mode=&quot;replication&quot;&amp;gt;  
                &amp;lt;stateTransfer timeout=&quot;5000&quot; fetchInMemoryState=&quot;true&quot; /&amp;gt;  
                &amp;lt;sync replTimeout=&quot;5000&quot; /&amp;gt;  
           &amp;lt;/clustering&amp;gt;  
      &amp;lt;/namedCache&amp;gt;  
 &amp;lt;/infinispan&amp;gt;  
&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
The result is that when arrive concurrent request with same TransactionId, the first is served regularly, the other get a HTTP 409 Conflict.&lt;br /&gt;
You can use &lt;a href=&quot;http://httpd.apache.org/docs/2.0/programs/ab.html&quot;&gt;ab&lt;/a&gt; and &lt;a href=&quot;http://www.wireshark.org/&quot;&gt;wireshark&lt;/a&gt; to test this configuration.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Tools:&lt;br /&gt;
Jersey 1.6 + Guice 2.0&lt;br /&gt;
Google Guava 11.0.1&lt;br /&gt;
JBoss Infinispan 5.1.1&lt;br /&gt;
&lt;br /&gt;
Good clustering at all!&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://tipsaboutmywork.blogspot.com/feeds/2802824208124334964/comments/default' title='Commenti sul post'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/978841978768050379/2802824208124334964?isPopup=true' title='0 Commenti'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/978841978768050379/posts/default/2802824208124334964'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/978841978768050379/posts/default/2802824208124334964'/><link rel='alternate' type='text/html' href='http://tipsaboutmywork.blogspot.com/2012/03/non-concurrent-http-requests-on-cluster.html' title='Non concurrent HTTP requests on Cluster with Infinispan'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/10337520217862613665</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-978841978768050379.post-6729300140458045336</id><published>2012-02-06T23:30:00.000+01:00</published><updated>2012-02-07T14:39:24.147+01:00</updated><title type='text'>Port Knocking via web, Web Knocking!</title><content type='html'>Port knocking is an ingenious practice used when you want open firewall port through a predefined sequence of SYN packets to closed port. However listen to SYN packages to close port can be a weight process, specially if your system already expose a web server.&lt;br /&gt;
&lt;br /&gt;
What I made is to translate the concept behind port knocking to web, instead of knocking a sequence of &lt;u&gt;pre-shared&lt;/u&gt; port number, I send an HTTP POST with a MD5 hash of a &lt;u&gt;pre-shared&lt;/u&gt; password plus a timestamp. A flow diagram can make my idea more clearly.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEitR77jR2dAOY2bZYb5kuk6paUOTzHe_UycpmEynXUnKAGNwXo0e128BofrNdIpeyuPd1Ic9mudoTSGldxea83mppyrkIBzIw26_l_nGZ1QglZiQq-o4Pus8tnVQGAf8j2lLmJPzBiBeiw/s1600/webknocking.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEitR77jR2dAOY2bZYb5kuk6paUOTzHe_UycpmEynXUnKAGNwXo0e128BofrNdIpeyuPd1Ic9mudoTSGldxea83mppyrkIBzIw26_l_nGZ1QglZiQq-o4Pus8tnVQGAf8j2lLmJPzBiBeiw/s1600/webknocking.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
First, I have created a script to make the POST request, &lt;i&gt;open-firewall.sh&lt;/i&gt;:&lt;br /&gt;
&lt;br /&gt;
&lt;pre style=&quot;background-image: URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhkEkqfom-xviS-R6LpBvbYIzMEfyHkCO2_HjOuwBc-4REF2rgZc8yZLlueL3VKv2czHoDkh4OdmH6ZlCHdoG2-kT1hMgP-Q1NCL34d4ezZMZ6Bi3Cltk_NlA0y2pvTkMiIIkptz_eEnLym/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt; #!/bin/sh  
 KEY=`echo SharedKey$(date +%Y%m%d%H%M) | md5sum | awk &#39;{print $1}&#39;`  
 wget --post-data=&quot;key=$KEY&quot; http://SERVER/webknocking.php --delete-after  
&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
This file contains the per-shared password (MyKey in this case) and a wget to system.&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
On server side, I have a file named &lt;i&gt;webknocking.php&lt;/i&gt; that catch the key and request&#39;s source IP &amp;nbsp;and pass them to a script for verify and open firewall:&lt;/div&gt;
&lt;br /&gt;
&lt;pre style=&quot;background-image: URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhkEkqfom-xviS-R6LpBvbYIzMEfyHkCO2_HjOuwBc-4REF2rgZc8yZLlueL3VKv2czHoDkh4OdmH6ZlCHdoG2-kT1hMgP-Q1NCL34d4ezZMZ6Bi3Cltk_NlA0y2pvTkMiIIkptz_eEnLym/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt; &amp;lt;?php  
 $key = $_POST[&#39;key&#39;];  
 $ip = $_SERVER[&#39;REMOTE_ADDR&#39;];  
 $cmd = &#39;sudo /var/dev.zonablog.net/openfirewall-300min.sh &#39;.$key.&#39; &#39;.$ip.&#39; &amp;gt;&amp;gt; /var/log/knock.log &amp;amp;&#39;;  
 shell_exec($cmd);  
 ?&amp;gt;  
 Request forwarded.  
&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
Notice that I call the bash script with sudo because the user that run the PHP is apache, that doesn&#39;t have rigth to change firewall configuration (iptables).&lt;br /&gt;
Insert into sudoers the row:
&lt;br /&gt;
&lt;br /&gt;
&lt;pre style=&quot;background-image: URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhkEkqfom-xviS-R6LpBvbYIzMEfyHkCO2_HjOuwBc-4REF2rgZc8yZLlueL3VKv2czHoDkh4OdmH6ZlCHdoG2-kT1hMgP-Q1NCL34d4ezZMZ6Bi3Cltk_NlA0y2pvTkMiIIkptz_eEnLym/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt; apache     ALL=      NOPASSWD: /var/dev.zonablog.net/openfirewall-300min.sh  
&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
to give the rigth to apache to run the script below as root. The content of &lt;i&gt;openfirewall-300min.sh&lt;/i&gt; is:
&lt;br /&gt;
&lt;br /&gt;
&lt;pre style=&quot;background-image: URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhkEkqfom-xviS-R6LpBvbYIzMEfyHkCO2_HjOuwBc-4REF2rgZc8yZLlueL3VKv2czHoDkh4OdmH6ZlCHdoG2-kT1hMgP-Q1NCL34d4ezZMZ6Bi3Cltk_NlA0y2pvTkMiIIkptz_eEnLym/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt; #!/bin/bash  
 echo &quot; &quot;  
 echo $(date) &quot;Verifico Ip &quot;$2&quot;, Key &quot;$1  
 KEY=`echo SharedKey$(date +%Y%m%d%H%M) | md5sum | awk &#39;{print $1}&#39;`  
 KEY_1m=`echo SharedKey$(date --date=&#39;1 minute ago&#39; +%Y%m%d%H%M) | md5sum | awk &#39;{print $1}&#39;`  
 if [ $1 != $KEY -a $1 != $KEY_1m ]  
  then  
   echo $(date) &quot;Respingo Ip &quot;$2&quot;, Key &quot;$1  
   exit 1  
 fi  


 # open firewall  
 echo $(date) &quot;Ok, apro per 5 ore&quot;  
 /sbin/iptables -I INPUT -j ACCEPT -i eth0 -p tcp -s $2  
 sleep 180000  


 # deny incoming packets  
 echo $(date) &quot;Chiudo a Ip &quot;$2&quot;, Key &quot;$1  
 /sbin/iptables -D INPUT -j ACCEPT -i eth0 -p tcp -s $2  
&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
This file check the key of request and if it is valid, open firewall to that ip for 5 hours. The log of this operation are put in /var/log/knock.log, create this file and change the owner to apache:
&lt;br /&gt;
&lt;br /&gt;
&lt;pre style=&quot;background-image: URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhkEkqfom-xviS-R6LpBvbYIzMEfyHkCO2_HjOuwBc-4REF2rgZc8yZLlueL3VKv2czHoDkh4OdmH6ZlCHdoG2-kT1hMgP-Q1NCL34d4ezZMZ6Bi3Cltk_NlA0y2pvTkMiIIkptz_eEnLym/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt; # touch /var/log/knock.log  
 # chown apache.apache /var/log/knock.log  
&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
This is it, folks!</content><link rel='replies' type='application/atom+xml' href='http://tipsaboutmywork.blogspot.com/feeds/6729300140458045336/comments/default' title='Commenti sul post'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/978841978768050379/6729300140458045336?isPopup=true' title='0 Commenti'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/978841978768050379/posts/default/6729300140458045336'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/978841978768050379/posts/default/6729300140458045336'/><link rel='alternate' type='text/html' href='http://tipsaboutmywork.blogspot.com/2012/02/port-knocking-via-web-web-knocking.html' title='Port Knocking via web, Web Knocking!'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/10337520217862613665</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEitR77jR2dAOY2bZYb5kuk6paUOTzHe_UycpmEynXUnKAGNwXo0e128BofrNdIpeyuPd1Ic9mudoTSGldxea83mppyrkIBzIw26_l_nGZ1QglZiQq-o4Pus8tnVQGAf8j2lLmJPzBiBeiw/s72-c/webknocking.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-978841978768050379.post-43590974503441938</id><published>2011-10-02T20:25:00.000+02:00</published><updated>2011-10-02T20:25:18.069+02:00</updated><title type='text'>xfce4-cpugraph-plugin on Fedora 15</title><content type='html'>This plugin isn&#39;t in Fedora repositories. You can download it from source, compile and install it. I spent 1 hours to find the correct parameters to pass to configure script...

&lt;br /&gt;
&lt;br /&gt;
&lt;pre style=&quot;background-image: URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhkEkqfom-xviS-R6LpBvbYIzMEfyHkCO2_HjOuwBc-4REF2rgZc8yZLlueL3VKv2czHoDkh4OdmH6ZlCHdoG2-kT1hMgP-Q1NCL34d4ezZMZ6Bi3Cltk_NlA0y2pvTkMiIIkptz_eEnLym/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt; [root@precision2 ~]# ./configure --libexecdir=/usr/libexec/ --prefix=/usr/  
 [root@precision2 ~]# make  
 [root@precision2 ~]# make install  
&lt;/code&gt;&lt;/pre&gt;
</content><link rel='replies' type='application/atom+xml' href='http://tipsaboutmywork.blogspot.com/feeds/43590974503441938/comments/default' title='Commenti sul post'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/978841978768050379/43590974503441938?isPopup=true' title='0 Commenti'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/978841978768050379/posts/default/43590974503441938'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/978841978768050379/posts/default/43590974503441938'/><link rel='alternate' type='text/html' href='http://tipsaboutmywork.blogspot.com/2011/10/xfce4-cpugraph-plugin-on-fedora-15.html' title='xfce4-cpugraph-plugin on Fedora 15'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/10337520217862613665</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-978841978768050379.post-4187519767701710819</id><published>2011-06-23T23:48:00.001+02:00</published><updated>2012-03-04T18:37:14.039+01:00</updated><title type='text'>JGroups and slf4j</title><content type='html'>JGroups offers a mechanism to extend its logger implemented two interface, CustomLogFactory and Log. Here are the two implementations for use slf4j.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
JGroupsCustomLoggerFactory:&lt;br /&gt;
&lt;pre style=&quot;background-image: URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhkEkqfom-xviS-R6LpBvbYIzMEfyHkCO2_HjOuwBc-4REF2rgZc8yZLlueL3VKv2czHoDkh4OdmH6ZlCHdoG2-kT1hMgP-Q1NCL34d4ezZMZ6Bi3Cltk_NlA0y2pvTkMiIIkptz_eEnLym/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt; import org.jgroups.logging.CustomLogFactory;  
 import org.jgroups.logging.Log;  
 import org.slf4j.Logger;  
 import org.slf4j.LoggerFactory;  
 public class JGroupsCustomLoggerFactory implements CustomLogFactory {  
      @Override  
      @SuppressWarnings(&quot;rawtypes&quot;)  
      public Log getLog(Class clazz) {  
           Logger logger = LoggerFactory.getLogger(LogUtils.formatClassName(clazz));  
           return new JGroupsCustomLog(logger);  
      }  
      @Override  
      public Log getLog(String category) {  
           Logger logger = LoggerFactory.getLogger(category);  
           return new JGroupsCustomLog(logger);  
      }  
 }  
&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
JGroupsCustomLog.java:&lt;br /&gt;
&lt;br /&gt;
&lt;pre style=&quot;background-image: URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhkEkqfom-xviS-R6LpBvbYIzMEfyHkCO2_HjOuwBc-4REF2rgZc8yZLlueL3VKv2czHoDkh4OdmH6ZlCHdoG2-kT1hMgP-Q1NCL34d4ezZMZ6Bi3Cltk_NlA0y2pvTkMiIIkptz_eEnLym/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt;
 import org.jgroups.logging.Log;  
 import org.slf4j.Logger;  
 import org.slf4j.Marker;  
 public class JGroupsCustomLog implements Log {  
      private Logger logger;  
      public JGroupsCustomLog(Logger logger) {  
           this.logger = logger;  
      }  
      @Override  
      public boolean isFatalEnabled() {  
           return false;  
      }  
      @Override  
      public boolean isErrorEnabled() {  
           return logger.isErrorEnabled();  
      }  
      @Override  
      public boolean isWarnEnabled() {  
           return logger.isErrorEnabled();  
      }  
      @Override  
      public boolean isInfoEnabled() {  
           return logger.isInfoEnabled();  
      }  
      @Override  
      public boolean isDebugEnabled() {  
           return logger.isDebugEnabled();  
      }  
      @Override  
      public boolean isTraceEnabled() {  
           return logger.isTraceEnabled();  
      }  
      public String getName() {  
           return logger.getName();  
      }  
      public void trace(String msg) {  
           logger.trace(msg);  
      }  
      public void trace(String format, Object arg) {  
           logger.trace(format, arg);  
      }  
      public void trace(String format, Object arg1, Object arg2) {  
           logger.trace(format, arg1, arg2);  
      }  
      public void trace(String format, Object[] argArray) {  
           logger.trace(format, argArray);  
      }  
      public void trace(String msg, Throwable t) {  
           logger.trace(msg, t);  
      }  
      public boolean isTraceEnabled(Marker marker) {  
           return logger.isTraceEnabled(marker);  
      }  
      public void trace(Marker marker, String msg) {  
           logger.trace(marker, msg);  
      }  
      public void trace(Marker marker, String format, Object arg) {  
           logger.trace(marker, format, arg);  
      }  
      public void trace(Marker marker, String format, Object arg1, Object arg2) {  
           logger.trace(marker, format, arg1, arg2);  
      }  
      public void trace(Marker marker, String format, Object[] argArray) {  
           logger.trace(marker, format, argArray);  
      }  
      public void trace(Marker marker, String msg, Throwable t) {  
           logger.trace(marker, msg, t);  
      }  
      public void debug(String msg) {  
           logger.debug(msg);  
      }  
      public void debug(String format, Object arg) {  
           logger.debug(format, arg);  
      }  
      public void debug(String format, Object arg1, Object arg2) {  
           logger.debug(format, arg1, arg2);  
      }  
      public void debug(String format, Object[] argArray) {  
           logger.debug(format, argArray);  
      }  
      public void debug(String msg, Throwable t) {  
           logger.debug(msg, t);  
      }  
      public boolean isDebugEnabled(Marker marker) {  
           return logger.isDebugEnabled(marker);  
      }  
      public void debug(Marker marker, String msg) {  
           logger.debug(marker, msg);  
      }  
      public void debug(Marker marker, String format, Object arg) {  
           logger.debug(marker, format, arg);  
      }  
      public void debug(Marker marker, String format, Object arg1, Object arg2) {  
           logger.debug(marker, format, arg1, arg2);  
      }  
      public void debug(Marker marker, String format, Object[] argArray) {  
           logger.debug(marker, format, argArray);  
      }  
      public void debug(Marker marker, String msg, Throwable t) {  
           logger.debug(marker, msg, t);  
      }  
      public void info(String msg) {  
           logger.info(msg);  
      }  
      public void info(String format, Object arg) {  
           logger.info(format, arg);  
      }  
      public void info(String format, Object arg1, Object arg2) {  
           logger.info(format, arg1, arg2);  
      }  
      public void info(String format, Object[] argArray) {  
           logger.info(format, argArray);  
      }  
      public void info(String msg, Throwable t) {  
           logger.info(msg, t);  
      }  
      public boolean isInfoEnabled(Marker marker) {  
           return logger.isInfoEnabled(marker);  
      }  
      public void info(Marker marker, String msg) {  
           logger.info(marker, msg);  
      }  
      public void info(Marker marker, String format, Object arg) {  
           logger.info(marker, format, arg);  
      }  
      public void info(Marker marker, String format, Object arg1, Object arg2) {  
           logger.info(marker, format, arg1, arg2);  
      }  
      public void info(Marker marker, String format, Object[] argArray) {  
           logger.info(marker, format, argArray);  
      }  
      public void info(Marker marker, String msg, Throwable t) {  
           logger.info(marker, msg, t);  
      }  
      public void warn(String msg) {  
           logger.warn(msg);  
      }  
      public void warn(String format, Object arg) {  
           logger.warn(format, arg);  
      }  
      public void warn(String format, Object[] argArray) {  
           logger.warn(format, argArray);  
      }  
      public void warn(String format, Object arg1, Object arg2) {  
           logger.warn(format, arg1, arg2);  
      }  
      public void warn(String msg, Throwable t) {  
           logger.warn(msg, t);  
      }  
      public boolean isWarnEnabled(Marker marker) {  
           return logger.isWarnEnabled(marker);  
      }  
      public void warn(Marker marker, String msg) {  
           logger.warn(marker, msg);  
      }  
      public void warn(Marker marker, String format, Object arg) {  
           logger.warn(marker, format, arg);  
      }  
      public void warn(Marker marker, String format, Object arg1, Object arg2) {  
           logger.warn(marker, format, arg1, arg2);  
      }  
      public void warn(Marker marker, String format, Object[] argArray) {  
           logger.warn(marker, format, argArray);  
      }  
      public void warn(Marker marker, String msg, Throwable t) {  
           logger.warn(marker, msg, t);  
      }  
      public void error(String msg) {  
           logger.error(msg);  
      }  
      public void error(String format, Object arg) {  
           logger.error(format, arg);  
      }  
      public void error(String format, Object arg1, Object arg2) {  
           logger.error(format, arg1, arg2);  
      }  
      public void error(String format, Object[] argArray) {  
           logger.error(format, argArray);  
      }  
      public void error(String msg, Throwable t) {  
           logger.error(msg, t);  
      }  
      public boolean isErrorEnabled(Marker marker) {  
           return logger.isErrorEnabled(marker);  
      }  
      public void error(Marker marker, String msg) {  
           logger.error(marker, msg);  
      }  
      public void error(Marker marker, String format, Object arg) {  
           logger.error(marker, format, arg);  
      }  
      public void error(Marker marker, String format, Object arg1, Object arg2) {  
           logger.error(marker, format, arg1, arg2);  
      }  
      public void error(Marker marker, String format, Object[] argArray) {  
           logger.error(marker, format, argArray);  
      }  
      public void error(Marker marker, String msg, Throwable t) {  
           logger.error(marker, msg, t);  
      }  
      @Override  
      public void fatal(String msg) {  
           logger.error(msg);  
      }  
      @Override  
      public void fatal(String msg, Throwable throwable) {  
           logger.error(msg, throwable);  
      }  
      @Override  
      public void trace(Object msg) {  
           logger.trace(msg.toString());  
      }  
      @Override  
      public void trace(Object msg, Throwable throwable) {  
           logger.trace(msg.toString(), throwable);  
      }  
      @Override  
      public void setLevel(String level) {  
      }  
      @Override  
      public String getLevel() {  
           return &quot;INFO&quot;;  
      }  
 }  
&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
Just befor initialize JGroups, call:&lt;br /&gt;
&lt;br /&gt;
&lt;pre style=&quot;background-image: URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhkEkqfom-xviS-R6LpBvbYIzMEfyHkCO2_HjOuwBc-4REF2rgZc8yZLlueL3VKv2czHoDkh4OdmH6ZlCHdoG2-kT1hMgP-Q1NCL34d4ezZMZ6Bi3Cltk_NlA0y2pvTkMiIIkptz_eEnLym/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt;           try {  
                System.setProperty(Global.CUSTOM_LOG_FACTORY, &quot;package.JGroupsCustomLoggerFactory&quot;);  
                jChannel = new JChannel();  
                jChannel.connect(&quot;channel-ver-3.0&quot;);  
&lt;/code&gt;&lt;/pre&gt;</content><link rel='replies' type='application/atom+xml' href='http://tipsaboutmywork.blogspot.com/feeds/4187519767701710819/comments/default' title='Commenti sul post'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/978841978768050379/4187519767701710819?isPopup=true' title='0 Commenti'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/978841978768050379/posts/default/4187519767701710819'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/978841978768050379/posts/default/4187519767701710819'/><link rel='alternate' type='text/html' href='http://tipsaboutmywork.blogspot.com/2011/06/jgroups-and-slf4j.html' title='JGroups and slf4j'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/10337520217862613665</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-978841978768050379.post-1411062672464765</id><published>2011-05-10T20:58:00.000+02:00</published><updated>2012-05-14T21:35:06.345+02:00</updated><title type='text'>Hibernate with Guice and a little of AOP to manage transaction.</title><content type='html'>What do you think abount @Transactional annotation? I used it with spring framework on service class to manage transaction into and intra service call. &lt;br /&gt;
It&#39;s a very elegant and easy way to manage transactions.&lt;br /&gt;
&lt;br /&gt;
I&#39;ve started working on a new project and I decided to use Guice as Dependency Injection framework, IMHO more lite and easy than Spring, and Hibernate&lt;br /&gt;
but I would like to continue to use the @Transactional annotation on my service class. &lt;br /&gt;
I didn&#39;t found anything good to use and I decided to use a little of AOP to recreate this functionality.&lt;br /&gt;
&lt;br /&gt;
Let&#39;s started with order, I would like that:&lt;br /&gt;
1) When I call a method on a service class, the operations in this method belong to a single transaction.&lt;br /&gt;
2) If the caller of the method 1) has a transaction, the thansanction must is the parent (caller) transaction.&lt;br /&gt;
&lt;br /&gt;
In practice the &quot;Required&quot; attribute of EBJ&#39;s Transactional parameter, see &lt;a href=&quot;http://download.oracle.com/javaee/5/tutorial/doc/bncij.html#bncim&quot;&gt;Required Attribute&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
This is the first case:&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjr1-zO0CT8sFvwxVPX2JmlwP3gxtguwJ7771Tm1MGUAHvHQ9vcmXKncikN_lPpDCbgJVyZBwMQsFirRX6ZPD-8qyv6qQx1_xtkAoYhsgbmRTBlWsJF7EkKMoRtBLxgGTDywBI0yMVZf9s/s1600/Trans1.png&quot; imageanchor=&quot;1&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;284&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjr1-zO0CT8sFvwxVPX2JmlwP3gxtguwJ7771Tm1MGUAHvHQ9vcmXKncikN_lPpDCbgJVyZBwMQsFirRX6ZPD-8qyv6qQx1_xtkAoYhsgbmRTBlWsJF7EkKMoRtBLxgGTDywBI0yMVZf9s/s400/Trans1.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
And this the second one:&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjbHiq42t64wZFVcN4ILq9_E5mbo0UzFbhtL4LoHaPVEcWDWpQvl9bKRftmxuwufnaqDKC70Wr6IvT-2cB4o9heGO1jkL_B8oBU3fhBl9EuG_EIczIi1UbOFb-v8pl5eVa3F8AXBTOm2ac/s1600/Trans2.png&quot; imageanchor=&quot;1&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;209&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjbHiq42t64wZFVcN4ILq9_E5mbo0UzFbhtL4LoHaPVEcWDWpQvl9bKRftmxuwufnaqDKC70Wr6IvT-2cB4o9heGO1jkL_B8oBU3fhBl9EuG_EIczIi1UbOFb-v8pl5eVa3F8AXBTOm2ac/s400/Trans2.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
I&#39;m going to use AOP and Guice to set a Method Interceptor that check is the called method has a transaction, and in case of not, create a new one and link it to thread with ThreadLocal class. I create also an annotation that identify che class and method subject and not subject to this check:&lt;br /&gt;
&lt;br /&gt;
A) The Transactional Annotation:&lt;br /&gt;
&lt;div align=&quot;left&quot; class=&quot;code&quot;&gt;
&lt;table border=&quot;0&quot; cellpadding=&quot;3&quot; cellspacing=&quot;0&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td align=&quot;left&quot; nowrap=&quot;nowrap&quot; valign=&quot;top&quot;&gt;&lt;pre style=&quot;background-image: URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhkEkqfom-xviS-R6LpBvbYIzMEfyHkCO2_HjOuwBc-4REF2rgZc8yZLlueL3VKv2czHoDkh4OdmH6ZlCHdoG2-kT1hMgP-Q1NCL34d4ezZMZ6Bi3Cltk_NlA0y2pvTkMiIIkptz_eEnLym/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt;&lt;span style=&quot;color: grey;&quot;&gt;01&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;package&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;net.zonablog.persistence.aop;&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;02&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;03&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;import&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;java.lang.annotation.ElementType;&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;04&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;import&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;java.lang.annotation.Retention;&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;05&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;import&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;java.lang.annotation.RetentionPolicy;&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;06&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;import&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;java.lang.annotation.Target;&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;07&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;08&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #646464;&quot;&gt;@Retention&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;RetentionPolicy.RUNTIME&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;09&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #646464;&quot;&gt;@Target&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;({&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;ElementType.TYPE,&amp;nbsp;ElementType.METHOD&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;})&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;10&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;public&amp;nbsp;@interface&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;Transactional&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;{&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;11&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;12&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;&lt;/td&gt;    &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;br /&gt;
The NoTransactional annotation, that mark the non-transactional method on a class marked as transactional:&lt;br /&gt;
&lt;div align=&quot;left&quot; class=&quot;code&quot;&gt;
&lt;table border=&quot;0&quot; cellpadding=&quot;3&quot; cellspacing=&quot;0&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td align=&quot;left&quot; nowrap=&quot;nowrap&quot; valign=&quot;top&quot;&gt;&lt;pre style=&quot;background-image: URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhkEkqfom-xviS-R6LpBvbYIzMEfyHkCO2_HjOuwBc-4REF2rgZc8yZLlueL3VKv2czHoDkh4OdmH6ZlCHdoG2-kT1hMgP-Q1NCL34d4ezZMZ6Bi3Cltk_NlA0y2pvTkMiIIkptz_eEnLym/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt;&lt;span style=&quot;color: grey;&quot;&gt;01&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;package&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;net.zonablog.persistence.aop;&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;02&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;03&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;import&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;java.lang.annotation.ElementType;&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;04&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;import&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;java.lang.annotation.Retention;&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;05&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;import&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;java.lang.annotation.RetentionPolicy;&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;06&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;import&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;java.lang.annotation.Target;&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;07&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;08&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #646464;&quot;&gt;@Retention&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;RetentionPolicy.RUNTIME&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;09&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #646464;&quot;&gt;@Target&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;({&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;ElementType.METHOD&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;})&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;10&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;public&amp;nbsp;@interface&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;NoTransactional&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;{&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;11&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;12&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
The implementation of this interceptor:&lt;br /&gt;
&lt;div align=&quot;left&quot; class=&quot;code&quot;&gt;
&lt;table border=&quot;0&quot; cellpadding=&quot;3&quot; cellspacing=&quot;0&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td align=&quot;left&quot; nowrap=&quot;nowrap&quot; valign=&quot;top&quot;&gt;&lt;br /&gt;
&lt;pre style=&quot;background-image: URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhkEkqfom-xviS-R6LpBvbYIzMEfyHkCO2_HjOuwBc-4REF2rgZc8yZLlueL3VKv2czHoDkh4OdmH6ZlCHdoG2-kT1hMgP-Q1NCL34d4ezZMZ6Bi3Cltk_NlA0y2pvTkMiIIkptz_eEnLym/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt;&lt;span style=&quot;color: grey;&quot;&gt;01&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;package&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;net.zonablog.persistence.aop;&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;02&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;03&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;import&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;net.zonablog.service.persistence.BasePersistentService;&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;04&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;import&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;net.zonablog.service.persistence.HibernateSessionService;&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;05&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;06&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;import&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;org.aopalliance.intercept.MethodInterceptor;&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;07&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;import&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;org.aopalliance.intercept.MethodInvocation;&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;08&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;import&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;org.hibernate.Session;&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;09&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;import&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;org.hibernate.Transaction;&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;10&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;import&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;org.slf4j.Logger;&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;11&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;import&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;org.slf4j.LoggerFactory;&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;12&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;13&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;import&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;com.google.inject.Inject;&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;14&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;15&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;public&amp;nbsp;class&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;TransactionInterceptor&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;implements&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;MethodInterceptor&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;{&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;16&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;17&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;private&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;Logger&amp;nbsp;logger&amp;nbsp;=&amp;nbsp;LoggerFactory.getLogger&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;this&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;.getClass&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;())&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;18&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;private&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;ThreadLocal&amp;lt;Session&amp;gt;&amp;nbsp;threadLocal;&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;19&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;20&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #646464;&quot;&gt;@Inject&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;21&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;private&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;HibernateSessionService&amp;nbsp;hibernateSessionService;&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;22&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;23&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;public&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;TransactionInterceptor&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;()&amp;nbsp;{&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;24&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;logger.info&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;Inizializzation&amp;nbsp;of&amp;nbsp;&quot;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;+&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;this&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;.getClass&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;())&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;25&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;threadLocal&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;new&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;ThreadLocal&amp;lt;Session&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;26&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;27&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;28&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #646464;&quot;&gt;@SuppressWarnings&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;rawtypes&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;29&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;public&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;Object&amp;nbsp;invoke&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;MethodInvocation&amp;nbsp;invocation&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;throws&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;Throwable&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;{&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;30&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;31&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;logger.trace&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;Start&amp;nbsp;of&amp;nbsp;transactional&amp;nbsp;method&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;32&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;33&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;//&amp;nbsp;Verifico&amp;nbsp;se&amp;nbsp;vengo&amp;nbsp;chiamato&amp;nbsp;da&amp;nbsp;un&#39;altra&amp;nbsp;applicazione&amp;nbsp;che&amp;nbsp;ha&amp;nbsp;già&amp;nbsp;la&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;34&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;//&amp;nbsp;transazione&amp;nbsp;attiva&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;35&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;Transaction&amp;nbsp;transaction&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;null&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;36&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;Session&amp;nbsp;session&amp;nbsp;=&amp;nbsp;threadLocal.get&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;37&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;boolean&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;startNewTransaction&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;true&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;38&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;39&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;if&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;session&amp;nbsp;==&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;null&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&amp;nbsp;{&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;40&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;logger.trace&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;Start&amp;nbsp;new&amp;nbsp;transaction&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;41&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;session&amp;nbsp;=&amp;nbsp;hibernateSessionService.openSession&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;42&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;threadLocal.set&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;session&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;43&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;transaction&amp;nbsp;=&amp;nbsp;session.getTransaction&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;44&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;transaction.begin&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;45&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;else&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;{&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;46&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;logger.trace&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;Already&amp;nbsp;in&amp;nbsp;transaction&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;47&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;startNewTransaction&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;false&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;48&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;49&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;50&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;if&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;invocation.getThis&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;()&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;instanceof&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;BasePersistentService&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;51&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;((&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;BasePersistentService&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;invocation.getThis&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;())&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;.setSession&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;session&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;52&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;53&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;try&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;{&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;54&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;55&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;Object&amp;nbsp;result&amp;nbsp;=&amp;nbsp;invocation.proceed&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;56&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;57&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;if&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;transaction&amp;nbsp;!=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;null&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&amp;nbsp;{&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;58&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;logger.trace&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;Commit&amp;nbsp;transaction&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;59&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;transaction.commit&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;60&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;threadLocal.remove&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;61&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;62&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;63&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;return&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;result;&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;64&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;65&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;catch&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;Exception&amp;nbsp;e&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&amp;nbsp;{&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;66&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;67&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;if&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;transaction&amp;nbsp;!=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;null&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&amp;nbsp;{&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;68&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;logger.debug&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;Rollback&amp;nbsp;transaction&amp;nbsp;due&amp;nbsp;[&quot;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;+&amp;nbsp;e.getMessage&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;()&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;+&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;]&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;69&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;transaction.rollback&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;70&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;threadLocal.remove&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;71&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;72&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;73&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;throw&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;e;&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;74&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;finally&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;{&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;75&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;logger.trace&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;Exit&amp;nbsp;transactional&amp;nbsp;method&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;76&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;77&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;if&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;startNewTransaction&amp;nbsp;&amp;amp;&amp;amp;&amp;nbsp;session&amp;nbsp;!=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;null&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;78&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;session.close&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;79&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;80&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;81&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;82&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;83&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #646464;&quot;&gt;@Override&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;84&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;protected&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;void&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;finalize&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;()&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;throws&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;Throwable&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;{&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;85&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;threadLocal.remove&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;86&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;super&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;.finalize&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;87&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;88&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;89&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/td&gt; &lt;/tr&gt;
&lt;/tbody&gt; &lt;/table&gt;
&lt;/div&gt;
&lt;br /&gt;
I&#39;m using Jersey with Guice, and I use the @Transactional annotation also on webresources. Es:&lt;br /&gt;
&lt;div align=&quot;left&quot; class=&quot;code&quot;&gt;
&lt;table border=&quot;0&quot; cellpadding=&quot;3&quot; cellspacing=&quot;0&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;    &lt;td align=&quot;left&quot; nowrap=&quot;nowrap&quot; valign=&quot;top&quot;&gt;&lt;br /&gt;
&lt;code&gt;&lt;/code&gt;&lt;br /&gt;
&lt;pre style=&quot;background-image: URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhkEkqfom-xviS-R6LpBvbYIzMEfyHkCO2_HjOuwBc-4REF2rgZc8yZLlueL3VKv2czHoDkh4OdmH6ZlCHdoG2-kT1hMgP-Q1NCL34d4ezZMZ6Bi3Cltk_NlA0y2pvTkMiIIkptz_eEnLym/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt;&lt;span style=&quot;color: grey;&quot;&gt;01&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;package&amp;nbsp;&lt;/b&gt;&lt;span style=&quot;color: black;&quot;&gt;net.zonablog.rest.controller;&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;02&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;03&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #0033ff;&quot;&gt;&lt;b&gt;import&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;java.util.UUID;&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;04&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;05&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #0033ff;&quot;&gt;&lt;b&gt;import&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;javax.mail.internet.AddressException;&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;06&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #0033ff;&quot;&gt;&lt;b&gt;import&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;javax.mail.internet.InternetAddress;&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;07&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #0033ff;&quot;&gt;&lt;b&gt;import&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;javax.ws.rs.FormParam;&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;08&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #0033ff;&quot;&gt;&lt;b&gt;import&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;javax.ws.rs.GET;&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;09&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #0033ff;&quot;&gt;&lt;b&gt;import&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;javax.ws.rs.POST;&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;10&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #0033ff;&quot;&gt;&lt;b&gt;import&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;javax.ws.rs.Path;&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;11&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #0033ff;&quot;&gt;&lt;b&gt;import&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;javax.ws.rs.PathParam;&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;12&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #0033ff;&quot;&gt;&lt;b&gt;import&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;javax.ws.rs.Produces;&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;13&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #0033ff;&quot;&gt;&lt;b&gt;import&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;javax.ws.rs.core.MediaType;&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;14&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #0033ff;&quot;&gt;&lt;b&gt;import&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;javax.ws.rs.core.Response;&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;15&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #0033ff;&quot;&gt;&lt;b&gt;import&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;javax.ws.rs.core.Response.ResponseBuilder;&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;16&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #0033ff;&quot;&gt;&lt;b&gt;import&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;javax.ws.rs.core.Response.Status;&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;17&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;18&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #0033ff;&quot;&gt;&lt;b&gt;import&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;com.google.inject.Inject;&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;19&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #0033ff;&quot;&gt;&lt;b&gt;import&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;com.sun.jersey.spi.resource.PerRequest;&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;20&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;21&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #646464;&quot;&gt;@Transactional&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;22&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #646464;&quot;&gt;@Path&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;&lt;b&gt;&quot;services/register&quot;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;23&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #646464;&quot;&gt;@PerRequest&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;24&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #0033ff;&quot;&gt;&lt;b&gt;public&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: #9900cc;&quot;&gt;&lt;b&gt;class&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;RegisterController&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #0033ff;&quot;&gt;&lt;b&gt;extends&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;BaseController&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;{&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;25&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;26&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #646464;&quot;&gt;@Inject&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;27&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #0033ff;&quot;&gt;&lt;b&gt;private&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;MailService&amp;nbsp;mailService;&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;28&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;29&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #646464;&quot;&gt;@Inject&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;30&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #0033ff;&quot;&gt;&lt;b&gt;private&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;UserService&amp;nbsp;userService;&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;31&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;32&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #646464;&quot;&gt;@Inject&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;33&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #0033ff;&quot;&gt;&lt;b&gt;public&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;RegisterController&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;()&amp;nbsp;{&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;34&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;35&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;36&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #646464;&quot;&gt;@POST&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;37&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #646464;&quot;&gt;@Produces&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;MediaType.APPLICATION_XML&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;38&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #0033ff;&quot;&gt;&lt;b&gt;public&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;Object&amp;nbsp;register&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #646464;&quot;&gt;@FormParam&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;&lt;b&gt;&quot;registerDialogFormEmail&quot;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;String&amp;nbsp;email,&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;39&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #646464;&quot;&gt;@FormParam&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;&lt;b&gt;&quot;registerDialogFormPass&quot;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;String&amp;nbsp;password,&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #646464;&quot;&gt;@FormParam&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;&lt;b&gt;&quot;registerDialogFormRPass&quot;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;String&amp;nbsp;rpassword&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&amp;nbsp;{&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;40&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;41&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;...&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;42&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;43&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/td&gt; &lt;/tr&gt;
&lt;/tbody&gt; &lt;/table&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
Note that to let Guice istantiate the webresource, in addition to configuration needed by jersey-guice module, the @Inject must present on constructor&#39;s class.&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://tipsaboutmywork.blogspot.com/feeds/1411062672464765/comments/default' title='Commenti sul post'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/978841978768050379/1411062672464765?isPopup=true' title='0 Commenti'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/978841978768050379/posts/default/1411062672464765'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/978841978768050379/posts/default/1411062672464765'/><link rel='alternate' type='text/html' href='http://tipsaboutmywork.blogspot.com/2011/05/hibernate-with-guice-and-little-of-aop.html' title='Hibernate with Guice and a little of AOP to manage transaction.'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/10337520217862613665</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjr1-zO0CT8sFvwxVPX2JmlwP3gxtguwJ7771Tm1MGUAHvHQ9vcmXKncikN_lPpDCbgJVyZBwMQsFirRX6ZPD-8qyv6qQx1_xtkAoYhsgbmRTBlWsJF7EkKMoRtBLxgGTDywBI0yMVZf9s/s72-c/Trans1.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-978841978768050379.post-10137962589039636</id><published>2011-04-28T23:12:00.000+02:00</published><updated>2011-04-28T23:12:34.623+02:00</updated><title type='text'>Jersey, @RolesAllowed annotation and 403 Forbidden</title><content type='html'>I spent last three hours to understand why I always get 403 Forbidden from a secured JAX-RS resource with @RolesAllowed...&lt;br /&gt;
After checking the params of Jersey Servlet:&lt;br /&gt;
&lt;br /&gt;
&lt;pre  style=&quot;font-family:arial;font-size:12px;border:1px dashed #CCCCCC;width:99%;height:auto;overflow:auto;background:#f0f0f0;;background-image:URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhkEkqfom-xviS-R6LpBvbYIzMEfyHkCO2_HjOuwBc-4REF2rgZc8yZLlueL3VKv2czHoDkh4OdmH6ZlCHdoG2-kT1hMgP-Q1NCL34d4ezZMZ6Bi3Cltk_NlA0y2pvTkMiIIkptz_eEnLym/s320/codebg.gif);padding:0px;color:#000000;text-align:left;line-height:20px;&quot;&gt;&lt;code style=&quot;color:#000000;word-wrap:normal;&quot;&gt; &amp;lt;init-param&amp;gt;  
  &amp;lt;param-name&amp;gt;com.sun.jersey.spi.container.ResourceFilters&amp;lt;/param-name&amp;gt;  
  &amp;lt;param-value&amp;gt;com.sun.jersey.api.container.filter.RolesAllowedResourceFilterFactory&amp;lt;/param-value&amp;gt;  
 &amp;lt;/init-param&amp;gt;  
&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;
I proceeded to debug the filter under the hood, RolesAllowedResourceFilterFactory, and I noticed that UserPrincipal was null!&lt;br /&gt;
What I&#39;d forgotten was to secured the resources with security-constraint:&lt;br /&gt;
&lt;br /&gt;
&lt;pre  style=&quot;font-family:arial;font-size:12px;border:1px dashed #CCCCCC;width:99%;height:auto;overflow:auto;background:#f0f0f0;;background-image:URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhkEkqfom-xviS-R6LpBvbYIzMEfyHkCO2_HjOuwBc-4REF2rgZc8yZLlueL3VKv2czHoDkh4OdmH6ZlCHdoG2-kT1hMgP-Q1NCL34d4ezZMZ6Bi3Cltk_NlA0y2pvTkMiIIkptz_eEnLym/s320/codebg.gif);padding:0px;color:#000000;text-align:left;line-height:20px;&quot;&gt;&lt;code style=&quot;color:#000000;word-wrap:normal;&quot;&gt; &amp;lt;security-constraint&amp;gt;  
  &amp;lt;web-resource-collection&amp;gt;  
   &amp;lt;web-resource-name&amp;gt;Protected Area&amp;lt;/web-resource-name&amp;gt;  
   &amp;lt;url-pattern&amp;gt;/resources/*&amp;lt;/url-pattern&amp;gt;  
  &amp;lt;/web-resource-collection&amp;gt;  
  &amp;lt;auth-constraint&amp;gt;  
   &amp;lt;role-name&amp;gt;admin&amp;lt;/role-name&amp;gt;  
   &amp;lt;role-name&amp;gt;user&amp;lt;/role-name&amp;gt;  
  &amp;lt;/auth-constraint&amp;gt;  
 &amp;lt;/security-constraint&amp;gt;  
&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;
In role-name you&#39;ve to insert all the roles that you&#39;re going to use in @RolesAllowed.&lt;br /&gt;
&lt;br /&gt;
Good night!</content><link rel='replies' type='application/atom+xml' href='http://tipsaboutmywork.blogspot.com/feeds/10137962589039636/comments/default' title='Commenti sul post'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/978841978768050379/10137962589039636?isPopup=true' title='0 Commenti'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/978841978768050379/posts/default/10137962589039636'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/978841978768050379/posts/default/10137962589039636'/><link rel='alternate' type='text/html' href='http://tipsaboutmywork.blogspot.com/2011/04/jersey-rolesallowed-annotation-and-403.html' title='Jersey, @RolesAllowed annotation and 403 Forbidden'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/10337520217862613665</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-978841978768050379.post-6644309855064603954</id><published>2011-02-20T12:41:00.004+01:00</published><updated>2011-03-02T10:20:14.266+01:00</updated><title type='text'>Expose Apache Tomcat statistics on Cacti</title><content type='html'>Cacti is an extremly usefully tool to plot any parameters on a system.&lt;br /&gt;
This came out with defaults sensors for SO and Networking in general, I tried to use cacti to plot some interesting parameters about JVM and Tomcat.&lt;br /&gt;
&lt;br /&gt;
I use the jmxProxy servlet came with manager webapp from tomcat&#39;s distribution to get the value of some attributes from the MBean Server.&lt;br /&gt;
&lt;br /&gt;
Let we start with trace the Request Count, Error Count and Processing Time on AJP port, I do it on a Fedora 13 machine:&lt;br /&gt;
&lt;br /&gt;
&lt;ol start=&quot;0&quot;&gt;&lt;li&gt;Requirements&lt;/li&gt;
&lt;ol type=&quot;A&quot;&gt;&lt;li&gt;Default Tomcat installation with manager webapp.&lt;/li&gt;
&lt;li&gt;Default Cacti installation.&lt;/li&gt;
&lt;li&gt;Set the user with manager role in tomcat-users.xml:&lt;/li&gt;
&lt;ol type=&quot;I&quot; &gt;&lt;li&gt;This is a piece of my &lt;b&gt;TOMCAT_HOME/conf/tomcat-users.xml:&lt;/b&gt;&lt;br /&gt;
&lt;pre  style=&quot;font-family:arial;font-size:12px;border:1px dashed #CCCCCC;width:99%;height:auto;overflow:auto;background:#f0f0f0;;background-image:URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhkEkqfom-xviS-R6LpBvbYIzMEfyHkCO2_HjOuwBc-4REF2rgZc8yZLlueL3VKv2czHoDkh4OdmH6ZlCHdoG2-kT1hMgP-Q1NCL34d4ezZMZ6Bi3Cltk_NlA0y2pvTkMiIIkptz_eEnLym/s320/codebg.gif);padding:0px;color:#000000;text-align:left;line-height:20px;&quot;&gt;&lt;code style=&quot;color:#000000;word-wrap:normal;&quot;&gt; &amp;lt;tomcat-users&amp;gt;  
  &amp;lt;role rolename=&quot;manager&quot;/&amp;gt;  
  &amp;lt;user username=&quot;manager&quot; password=&quot;changethispassword&quot; roles=&quot;manager&quot;/&amp;gt;  
  ....  
 &amp;lt;/tomcat-users&amp;gt;  
&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;li&gt;Check the jmxProxy servlet, point your browser to &lt;a href=&quot;http://localhost:8080/manager/jmxproxy/?qry=Catalina:type=GlobalRequestProcessor,name=http-8080&quot;&gt;http://localhost:8080/manager/jmxproxy/?qry=Catalina:type=GlobalRequestProcessor,name=http-8080&lt;/a&gt; and check the result page, this is an example:&lt;br /&gt;
&lt;pre  style=&quot;font-family:arial;font-size:12px;border:1px dashed #CCCCCC;width:99%;height:auto;overflow:auto;background:#f0f0f0;;background-image:URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhkEkqfom-xviS-R6LpBvbYIzMEfyHkCO2_HjOuwBc-4REF2rgZc8yZLlueL3VKv2czHoDkh4OdmH6ZlCHdoG2-kT1hMgP-Q1NCL34d4ezZMZ6Bi3Cltk_NlA0y2pvTkMiIIkptz_eEnLym/s320/codebg.gif);padding:0px;color:#000000;text-align:left;line-height:20px;&quot;&gt;&lt;code style=&quot;color:#000000;word-wrap:normal;&quot;&gt; OK - Number of results: 1  
 Name: Catalina:type=GlobalRequestProcessor,name=http-8080  
 modelerType: org.apache.tomcat.util.modeler.BaseModelMBean  
 bytesSent: 168065  
 bytesReceived: 340  
 processingTime: 5310  
 errorCount: 0  
 maxTime: 3214  
 requestCount: 16  
&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;/ol&gt;&lt;li&gt;Create the script to get the output of jmxProxy servlet as input for Cacti:&lt;br /&gt;
&lt;ol type=&quot;A&quot;&gt;&lt;li&gt;Log on the machine as cacti user and create the file &lt;b&gt;CACTI_HOME/scripts/get_tomcat_globalrequestprocessor.sh&lt;/b&gt;:&lt;br /&gt;
&lt;pre  style=&quot;font-family:arial;font-size:12px;border:1px dashed #CCCCCC;width:99%;height:auto;overflow:auto;background:#f0f0f0;;background-image:URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhkEkqfom-xviS-R6LpBvbYIzMEfyHkCO2_HjOuwBc-4REF2rgZc8yZLlueL3VKv2czHoDkh4OdmH6ZlCHdoG2-kT1hMgP-Q1NCL34d4ezZMZ6Bi3Cltk_NlA0y2pvTkMiIIkptz_eEnLym/s320/codebg.gif);padding:0px;color:#000000;text-align:left;line-height:20px;&quot;&gt;&lt;code style=&quot;color:#000000;word-wrap:normal;&quot;&gt; #!/bin/bash   
 OPTTIONS=&quot;--user $3:$4 -f -S http://$1:$2/manager/jmxproxy/?qry=Catalina:type=GlobalRequestProcessor,name=$5&quot;  
 OUTPUT=$(curl $OPTTIONS 2&amp;gt;/dev/null)  
 PT=$(printf &quot;$OUTPUT&quot; | grep -e &quot;^processingTime: &quot; | grep -oEi &#39;processingTime: ([0-9]*)&#39; | sed &quot;s/processingTime: /processingtime:/g&quot;)  
 EC=$(printf &quot;$OUTPUT&quot; | grep -e &quot;^errorCount: &quot; | grep -oEi &#39;errorCount: ([0-9]*)&#39; | sed &quot;s/errorCount: /errorcount:/g&quot;)  
 RC=$(printf &quot;$OUTPUT&quot; | grep -e &quot;^requestCount: &quot; | grep -oEi &#39;requestCount: ([0-9]*)&#39; | sed &quot;s/requestCount: /requestcount:/g&quot;)  
 echo $PT $EC $RC  
&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;li&gt;Change it&#39;s permission: chmod 775 scripts/get_tomcat_globalrequestprocessor.sh&lt;/li&gt;
&lt;li&gt;Check the script: ./scripts/get_tomcat_globalrequestprocessor.sh localhost 8080 manager changethispassword http-8080&lt;br /&gt;
&lt;pre  style=&quot;font-family:arial;font-size:12px;border:1px dashed #CCCCCC;width:99%;height:auto;overflow:auto;background:#f0f0f0;;background-image:URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhkEkqfom-xviS-R6LpBvbYIzMEfyHkCO2_HjOuwBc-4REF2rgZc8yZLlueL3VKv2czHoDkh4OdmH6ZlCHdoG2-kT1hMgP-Q1NCL34d4ezZMZ6Bi3Cltk_NlA0y2pvTkMiIIkptz_eEnLym/s320/codebg.gif);padding:0px;color:#000000;text-align:left;line-height:20px;&quot;&gt;&lt;code style=&quot;color:#000000;word-wrap:normal;&quot;&gt; -bash-4.1$ ./get_tomcat_globalrequestprocessor.sh localhost 8080 manager changethispassword http-8080  
 processingtime:73631 errorcount:2 requestcount:18253  
 -bash-4.1$   
&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;/li&gt;
&lt;li&gt;Configure Cacti to plot this value:&lt;br /&gt;
&lt;br /&gt;
&lt;ol type=&quot;A&quot;&gt;&lt;li&gt;Open Cacti and create a new Data Input Method. Type in the name field &lt;i&gt;Tomcat GlobalRequestProcessor&lt;/i&gt;, &lt;br /&gt;
select &lt;i&gt;Script/Command&lt;/i&gt; as Input Type and cut&amp;paste the script call in Input String &lt;i&gt;&amp;lt;path_cacti&amp;gt;/scripts/get_tomcat_globalrequestprocessor.sh &amp;lt;host&amp;gt; &amp;lt;port&amp;gt; &amp;lt;username&amp;gt; &amp;lt;password&amp;gt; &amp;lt;name&amp;gt;&lt;/i&gt;. &lt;br /&gt;
The name in the script wrapped between &amp;lt; and &amp;gt; are parameters that are replaced with the values came from Data Sources view (see later). Click create. &lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgqzezmR5DsdgSuG_u8s9oB94peuq1y1Wiz5zdcE9VFW8ER67WTBDvyjlvYFS7YQW825hWpeqzECTvAObXCDkvTHzYKOv8UrMCIg8mpSHtlxR8NRqjwLWBYBiY1QDcGJOl3O0P2et2c3us/s1600/cacti_tomcat_01.png&quot; imageanchor=&quot;1&quot; style=&quot;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;261&quot; width=&quot;400&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgqzezmR5DsdgSuG_u8s9oB94peuq1y1Wiz5zdcE9VFW8ER67WTBDvyjlvYFS7YQW825hWpeqzECTvAObXCDkvTHzYKOv8UrMCIg8mpSHtlxR8NRqjwLWBYBiY1QDcGJOl3O0P2et2c3us/s400/cacti_tomcat_01.png&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;Complete the Data Input Method specifying the input and output of script. Add in input field the five descriptions of input defined for the script and add in output fields list the four output value of the script (with a short description and leave check the &lt;i&gt;field Update RRD File&lt;/i&gt;):&lt;br /&gt;
&lt;ol type=&quot;I&quot;&gt;&lt;li&gt;errorcount&lt;/li&gt;
&lt;li&gt;processingtime&lt;/li&gt;
&lt;li&gt;requestcount&lt;/li&gt;
&lt;/ol&gt;And save.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgtlET3n-m9eRFm7gaUCWFkbfP7ezdTR0zP9qpUu53o_owBikZn_RxvVNraiDeAWvftP_VdALPHVuPuBPJCfS-e4hJ4YYpZrRclmVC9c7o3p8cd3qPwGuALTgWXdwMoEG15D-Z2Lb0wvhQ/s1600/cacti_tomcat_02.png&quot; imageanchor=&quot;1&quot; style=&quot;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;300&quot; width=&quot;400&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgtlET3n-m9eRFm7gaUCWFkbfP7ezdTR0zP9qpUu53o_owBikZn_RxvVNraiDeAWvftP_VdALPHVuPuBPJCfS-e4hJ4YYpZrRclmVC9c7o3p8cd3qPwGuALTgWXdwMoEG15D-Z2Lb0wvhQ/s400/cacti_tomcat_02.png&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;/div&gt;&lt;br /&gt;
&lt;/li&gt;
&lt;li&gt;Add a new Data Source. Select &lt;i&gt;None&lt;/i&gt; in the &quot;Selected Data Template&quot; field and an host. I&#39;ve created previously a devices called Java Virtual Machine to attach all my jvm&#39;s graph, but isn&#39;t necessary, is only for ordering graph.   &lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiPGNwbVIftUkb3HZiHLpoSO9Fh3eODqZKPt3Of5_IsHLfad0iiHd8e4_TKnIUd-Fw_Xl2Zj7qmaEeTX6IQ-XYD9O6ltabfltfRZBUcuzdyBjQtddbiFOmgX4QxxJsklsJrpqKQoDHEPPs/s1600/cacti_tomcat_03.png&quot; imageanchor=&quot;1&quot; style=&quot;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;222&quot; width=&quot;400&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiPGNwbVIftUkb3HZiHLpoSO9Fh3eODqZKPt3Of5_IsHLfad0iiHd8e4_TKnIUd-Fw_Xl2Zj7qmaEeTX6IQ-XYD9O6ltabfltfRZBUcuzdyBjQtddbiFOmgX4QxxJsklsJrpqKQoDHEPPs/s400/cacti_tomcat_03.png&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;/div&gt;&lt;br /&gt;
Click Create and complete the Data Source with a name (&lt;i&gt;Tomcat http-8080 Global Request Processor&lt;/i&gt;) a Data Source Path (&lt;i&gt;&lt;path_rra&gt;/localhost_tomcat_globalrequestprocessor_91.rrd&lt;/i&gt;) and select the just created Data Input Metod (&lt;i&gt;Tomcat Global Request Processor&lt;/i&gt;). Leave Associated RRS&#39;s, Step and Data Source Active with default value and click Create.&lt;br /&gt;
Cacti has saved the DataSource and now ask for Data Source Item. In this section we have to define all data parameters that come out with Data Input Methods and specify its type (&lt;a href=&quot;http://www.cacti.net/downloads/docs/html/templates.html&quot;&gt;http://www.cacti.net/downloads/docs/html/templates.html&lt;/a&gt; Table 13-2). Start with processingtime, that is a COUNTER &lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiNLnaNrNpfNJ3HAjNTRDYM5FXR1afnJ5GW6ECumQQJDVHMH3pDAFHfUaMQe36DIZAr8Cd5COOyXXaJN-pKAlAy16kphSP5n0IVTfix_fWGy6yHY0U65YQMTMz2BcTnstEaJUWeQcWcGzM/s1600/cacti_tomcat_04.png&quot; imageanchor=&quot;1&quot; style=&quot;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;280&quot; width=&quot;400&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiNLnaNrNpfNJ3HAjNTRDYM5FXR1afnJ5GW6ECumQQJDVHMH3pDAFHfUaMQe36DIZAr8Cd5COOyXXaJN-pKAlAy16kphSP5n0IVTfix_fWGy6yHY0U65YQMTMz2BcTnstEaJUWeQcWcGzM/s400/cacti_tomcat_04.png&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;/div&gt;&lt;br /&gt;
Complete the Data Source Item with other two Data Source Item, all as COUNTER type and Maximum Value 0. Complete also the Custom Data section with input value that script needs.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEid6DHw1HnOcxTDpSxSdLLyj1sODKRgGSeNN7JvL10jdjgp_OmAcFEHNVllNvFVuQvvIjTpTfI5G7a0bt1Ee2fK8wLs4HnJmqlJaWq7BwtRThZiJYL0q_uLPpyedfNXlkbcgI8Cc4wjKyE/s1600/cacti_tomcat_05.png&quot; imageanchor=&quot;1&quot; style=&quot;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;273&quot; width=&quot;400&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEid6DHw1HnOcxTDpSxSdLLyj1sODKRgGSeNN7JvL10jdjgp_OmAcFEHNVllNvFVuQvvIjTpTfI5G7a0bt1Ee2fK8wLs4HnJmqlJaWq7BwtRThZiJYL0q_uLPpyedfNXlkbcgI8Cc4wjKyE/s400/cacti_tomcat_05.png&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;/div&gt;&lt;br /&gt;
&lt;/li&gt;
&lt;li&gt;Create the Graph. Click on Add in Graph Management and select None as Template and an host. Click Create and insert the graph name, leaving all fields with default value. Click on Create.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjWhYFpGZ7FU5roFMJimc3WFmCFylSkRC4ub-MWYvICmiAbQIrJJhQkMoHYIS7NJR3JgGEUHq_lm8QAgeazKtijWvfMZYPvA6aqsPznjkWMHUqd2bHRBwSVV4AhuR244TpQyYviFVV4TFE/s1600/cacti_tomcat_06.png&quot; imageanchor=&quot;1&quot; style=&quot;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;280&quot; width=&quot;400&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjWhYFpGZ7FU5roFMJimc3WFmCFylSkRC4ub-MWYvICmiAbQIrJJhQkMoHYIS7NJR3JgGEUHq_lm8QAgeazKtijWvfMZYPvA6aqsPznjkWMHUqd2bHRBwSVV4AhuR244TpQyYviFVV4TFE/s400/cacti_tomcat_06.png&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;/div&gt;&lt;br /&gt;
Add the three Graph Items. Click Add on Graph Items, select the first our data source (Tomcat Global Request Processor (errorcount)), select a color, AREA as Graph Item Type and MAX as Consolidation Function.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgLWNn2wVb9DZOM9VWhvEtR_APof_hZRy8qwYTROfUNCHhP65AtqV9rjLuPUYpl0KxoQAhXq5ik_EsxKNYxTL6ZIIkuBTFSlbwDfU3Pfb1LGmWpODDUGllsA7TVJRKF_VooRtCWaQIDlag/s1600/cacti_tomcat_07.png&quot; imageanchor=&quot;1&quot; style=&quot;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;286&quot; width=&quot;400&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgLWNn2wVb9DZOM9VWhvEtR_APof_hZRy8qwYTROfUNCHhP65AtqV9rjLuPUYpl0KxoQAhXq5ik_EsxKNYxTL6ZIIkuBTFSlbwDfU3Pfb1LGmWpODDUGllsA7TVJRKF_VooRtCWaQIDlag/s400/cacti_tomcat_07.png&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;/div&gt;&lt;br /&gt;
You can also add Items that display the average/max/min/last value of sensors. I added Avg and Last values for each items.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg_-ZSmiC6aP9mQks5FByVCvegCbFZ2AK2Cbr5XLa2XCAuSTJueZrPF4YgEQnpG5QOaqUjyBUD39IWPNWP4KbsmgEQiXRMhiaRs8z7N710zIIzryozx7fWtN9mzpYNlUcuC246Jgezj3Io/s1600/cacti_tomcat_08.png&quot; imageanchor=&quot;1&quot; style=&quot;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;278&quot; width=&quot;400&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg_-ZSmiC6aP9mQks5FByVCvegCbFZ2AK2Cbr5XLa2XCAuSTJueZrPF4YgEQnpG5QOaqUjyBUD39IWPNWP4KbsmgEQiXRMhiaRs8z7N710zIIzryozx7fWtN9mzpYNlUcuC246Jgezj3Io/s400/cacti_tomcat_08.png&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;/div&gt;&lt;br /&gt;
&lt;/li&gt;
&lt;li&gt;The result&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEivdtjeH3kZRYk6bkV0us7hP1b0GRDRfcIt3OSUQFLXsT9pL_pdv2_6SxyY6r2YKub9Wu1pcKyhl556x5zhyUlE2pM2j8__L-VVes8cT3JBpxq_ugbw1puXucLEUvfUp99lUhEhUg9nQxo/s1600/cacti_tomcat_09.png&quot; imageanchor=&quot;1&quot; style=&quot;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;281&quot; width=&quot;400&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEivdtjeH3kZRYk6bkV0us7hP1b0GRDRfcIt3OSUQFLXsT9pL_pdv2_6SxyY6r2YKub9Wu1pcKyhl556x5zhyUlE2pM2j8__L-VVes8cT3JBpxq_ugbw1puXucLEUvfUp99lUhEhUg9nQxo/s400/cacti_tomcat_09.png&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;br /&gt;
&lt;li&gt;&lt;br /&gt;
&lt;b&gt;Troubleshooting&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
When your graph don&#39;t appear try to do all the step that cacti do to display the graph:&lt;br /&gt;
&lt;ol type=&quot;I&quot;&gt;&lt;li&gt;Check the script&#39;s paramenters that cacti use. Go in System Utility -&gt; View Poller Cache and write down the Script call in Details Field. Check the parameters order and try to execute the script on the shell. Check the output.&lt;/li&gt;
&lt;li&gt;Check data samples in RRD file. Use the rddtool dump command to see the file content and check if your samples are out of range (if MIN or MAX aren&#39;t zero):&lt;br /&gt;
&lt;pre  style=&quot;font-family:arial;font-size:12px;border:1px dashed #CCCCCC;width:99%;height:auto;overflow:auto;background:#f0f0f0;;background-image:URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhkEkqfom-xviS-R6LpBvbYIzMEfyHkCO2_HjOuwBc-4REF2rgZc8yZLlueL3VKv2czHoDkh4OdmH6ZlCHdoG2-kT1hMgP-Q1NCL34d4ezZMZ6Bi3Cltk_NlA0y2pvTkMiIIkptz_eEnLym/s320/codebg.gif);padding:0px;color:#000000;text-align:left;line-height:20px;&quot;&gt;&lt;code style=&quot;color:#000000;word-wrap:normal;&quot;&gt; -bash-4.1$ rrdtool dump /usr/share/cacti/rra/localhost_tomcat_globalrequestprocessor_91.rrd | less  
&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;li&gt;&lt;i&gt;Check the ERROR: the RRD does not contain an RRA matching the chosen CF&lt;/i&gt; This error means that the statistics collected from rrd don&#39;t match the type of Consolidation Function selected on Graph Items (Console -&gt; Graph Management -&gt; (Edit) -&gt; Graph Items). To see which statistics are collected by rrd, open the rrd file with rrdtool dump (as above) and see the cf element of rra node.&lt;br /&gt;
&lt;/li&gt;
&lt;/ol&gt;&lt;/li&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;li&gt;&lt;b&gt;Enhancement&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
In this graph I don&#39;t use the template for Data Source/Graph, but if you have to create the same graph for multiple machines, creating template is the right choose. &lt;br /&gt;
&lt;/li&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;/ol&gt;&lt;br /&gt;
&lt;br /&gt;
I hope this help to learn cacti, which hasn&#39;t a very flat learning curve.</content><link rel='replies' type='application/atom+xml' href='http://tipsaboutmywork.blogspot.com/feeds/6644309855064603954/comments/default' title='Commenti sul post'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/978841978768050379/6644309855064603954?isPopup=true' title='0 Commenti'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/978841978768050379/posts/default/6644309855064603954'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/978841978768050379/posts/default/6644309855064603954'/><link rel='alternate' type='text/html' href='http://tipsaboutmywork.blogspot.com/2011/02/expose-apache-tomcat-statistics-on.html' title='Expose Apache Tomcat statistics on Cacti'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/10337520217862613665</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgqzezmR5DsdgSuG_u8s9oB94peuq1y1Wiz5zdcE9VFW8ER67WTBDvyjlvYFS7YQW825hWpeqzECTvAObXCDkvTHzYKOv8UrMCIg8mpSHtlxR8NRqjwLWBYBiY1QDcGJOl3O0P2et2c3us/s72-c/cacti_tomcat_01.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-978841978768050379.post-3288960512608098071</id><published>2010-12-15T22:37:00.000+01:00</published><updated>2010-12-15T22:37:29.532+01:00</updated><title type='text'>FreeMarker and custom parameters on templates</title><content type='html'>Sometime it&#39;s usefull to get some parameters from templates, for example, I use a parameter in an email template to store the subject of this mail. &lt;br/&gt;&lt;br /&gt;
FreeMarker has a specific directive to do this: &lt;a href=&quot;http://freemarker.sourceforge.net/docs/ref_directive_ftl.html&quot;&gt;ref_directive_ftl&lt;/a&gt; but the section about custom parameters don&#39;t show how to use this. Here is an example:&lt;br /&gt;
Template:&lt;br /&gt;
&lt;pre  style=&quot;font-family:arial;font-size:12px;border:1px dashed #CCCCCC;width:99%;height:auto;overflow:auto;background:#f0f0f0;;background-image:URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhkEkqfom-xviS-R6LpBvbYIzMEfyHkCO2_HjOuwBc-4REF2rgZc8yZLlueL3VKv2czHoDkh4OdmH6ZlCHdoG2-kT1hMgP-Q1NCL34d4ezZMZ6Bi3Cltk_NlA0y2pvTkMiIIkptz_eEnLym/s320/codebg.gif);padding:0px;color:#000000;text-align:left;line-height:20px;&quot;&gt;&lt;code style=&quot;color:#000000;word-wrap:normal;&quot;&gt; &amp;lt;#ftl attributes={ &quot;subject&quot;: &quot;Registrazione&quot;}&amp;gt;  
 &amp;lt;html&amp;gt;  
      &amp;lt;body&amp;gt;  
           Gentile utente  
.....
&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;
This is the java code to read the parameter:&lt;br /&gt;
&lt;pre  style=&quot;font-family:arial;font-size:12px;border:1px dashed #CCCCCC;width:99%;height:auto;overflow:auto;background:#f0f0f0;;background-image:URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhkEkqfom-xviS-R6LpBvbYIzMEfyHkCO2_HjOuwBc-4REF2rgZc8yZLlueL3VKv2czHoDkh4OdmH6ZlCHdoG2-kT1hMgP-Q1NCL34d4ezZMZ6Bi3Cltk_NlA0y2pvTkMiIIkptz_eEnLym/s320/codebg.gif);padding:0px;color:#000000;text-align:left;line-height:20px;&quot;&gt;&lt;code style=&quot;color:#000000;word-wrap:normal;&quot;&gt; Template template = cfg.getTemplate(stemplate);  
 String subject = template.getCustomAttribute(&quot;subject&quot;);  
&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;
I spent the last 3 hours to find the correct form of ftl&#39;s attributes. I used attributes={ subject: Registrazione} and attributes=&quot;{subject: Registrazione}&quot; and I get ris respectively this error:&lt;br /&gt;
&lt;br /&gt;
&lt;pre  style=&quot;font-family:arial;font-size:12px;border:1px dashed #CCCCCC;width:99%;height:auto;overflow:auto;background:#f0f0f0;;background-image:URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhkEkqfom-xviS-R6LpBvbYIzMEfyHkCO2_HjOuwBc-4REF2rgZc8yZLlueL3VKv2czHoDkh4OdmH6ZlCHdoG2-kT1hMgP-Q1NCL34d4ezZMZ6Bi3Cltk_NlA0y2pvTkMiIIkptz_eEnLym/s320/codebg.gif);padding:0px;color:#000000;text-align:left;line-height:20px;&quot;&gt;&lt;code style=&quot;color:#000000;word-wrap:normal;&quot;&gt; freemarker.core.ParseException: Could not evaluate expression: {subject : Registrazione} on line 1, column 18 in it/mail/Registration.html  
 Underlying cause: Variables are not available (certainly you are in a parse-time executed directive). The name of the variable you tried to read: subject in it/mail/Registration.html  
      at freemarker.core.FMParser.HeaderElement(FMParser.java:2831)  
      at freemarker.core.FMParser.Root(FMParser.java:2954)  
      at freemarker.template.Template.&amp;lt;init&amp;gt;(Template.java:149)  
&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;
and&lt;br /&gt;
&lt;br /&gt;
&lt;pre  style=&quot;font-family:arial;font-size:12px;border:1px dashed #CCCCCC;width:99%;height:auto;overflow:auto;background:#f0f0f0;;background-image:URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhkEkqfom-xviS-R6LpBvbYIzMEfyHkCO2_HjOuwBc-4REF2rgZc8yZLlueL3VKv2czHoDkh4OdmH6ZlCHdoG2-kT1hMgP-Q1NCL34d4ezZMZ6Bi3Cltk_NlA0y2pvTkMiIIkptz_eEnLym/s320/codebg.gif);padding:0px;color:#000000;text-align:left;line-height:20px;&quot;&gt;&lt;code style=&quot;color:#000000;word-wrap:normal;&quot;&gt; freemarker.core.ParseException: Expecting a hash of attribute names to values here. on line 1, column 18 in it/mail/Registration.html in it/mail/Registration.html  
      at freemarker.core.FMParser.HeaderElement(FMParser.java:2888)  
      at freemarker.core.FMParser.Root(FMParser.java:2954)  
      at freemarker.template.Template.&amp;lt;init&amp;gt;(Template.java:149)  
      at freemarker.cache.TemplateCache.loadTemplate(TemplateCache.java:448)  
      at freemarker.cache.TemplateCache.getTemplate(TemplateCache.java:361)  
      at freemarker.cache.TemplateCache.getTemplate(TemplateCache.java:235)  
&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;
Nice FreeMarker!</content><link rel='replies' type='application/atom+xml' href='http://tipsaboutmywork.blogspot.com/feeds/3288960512608098071/comments/default' title='Commenti sul post'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/978841978768050379/3288960512608098071?isPopup=true' title='0 Commenti'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/978841978768050379/posts/default/3288960512608098071'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/978841978768050379/posts/default/3288960512608098071'/><link rel='alternate' type='text/html' href='http://tipsaboutmywork.blogspot.com/2010/12/freemarker-and-custom-parameters-on.html' title='FreeMarker and custom parameters on templates'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/10337520217862613665</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-978841978768050379.post-889144858061320751</id><published>2010-11-10T22:44:00.001+01:00</published><updated>2010-11-10T22:46:06.712+01:00</updated><title type='text'>Accept all SSL certificate (self signed certificate) in Java applications</title><content type='html'>When a java application tries to connect to a https service, the jvm check the server&#39;s certificate in order to test its validity. If you are using a self-signed certificate this maybe a problem. There are at least three way to go beyond this problem but, IMHO, I think the use of this class is the easiest way:&lt;br /&gt;
&lt;br /&gt;
&lt;pre  style=&quot;font-family:arial;font-size:12px;border:1px dashed #CCCCCC;width:99%;height:auto;overflow:auto;background:#f0f0f0;;background-image:URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhkEkqfom-xviS-R6LpBvbYIzMEfyHkCO2_HjOuwBc-4REF2rgZc8yZLlueL3VKv2czHoDkh4OdmH6ZlCHdoG2-kT1hMgP-Q1NCL34d4ezZMZ6Bi3Cltk_NlA0y2pvTkMiIIkptz_eEnLym/s320/codebg.gif);padding:0px;color:#000000;text-align:left;line-height:20px;&quot;&gt;&lt;code style=&quot;color:#000000;word-wrap:normal;&quot;&gt; import java.security.KeyManagementException;  
 import java.security.NoSuchAlgorithmException;  
 import java.security.cert.X509Certificate;  
 import javax.net.ssl.HostnameVerifier;  
 import javax.net.ssl.HttpsURLConnection;  
 import javax.net.ssl.SSLContext;  
 import javax.net.ssl.SSLSession;  
 import javax.net.ssl.TrustManager;  
 import javax.net.ssl.X509TrustManager;  
 public class UnTrustManager {  
      public static void acceptAllCertificates() throws NoSuchAlgorithmException, KeyManagementException {  
           TrustManager[] trustAllCerts = new TrustManager[1];  
           trustAllCerts[0] = new innerUnTrustManager();  
           SSLContext sc = SSLContext.getInstance(&quot;SSL&quot;);  
           sc.init(null, trustAllCerts, null);  
           HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());  
           HttpsURLConnection.setDefaultHostnameVerifier(new HostnameVerifier() {  
                public boolean verify(String hostname, SSLSession session) {  
                     return true;  
                }  
           });  
      }  
      public static class innerUnTrustManager implements TrustManager, X509TrustManager {  
           public X509Certificate[] getAcceptedIssuers() {  
                return null;  
           }  
           public void checkServerTrusted(X509Certificate[] certs, String authType)  
                     throws java.security.cert.CertificateException {  
           }  
           public void checkClientTrusted(X509Certificate[] certs, String authType)  
                     throws java.security.cert.CertificateException {  
           }  
      }  
 }  
&lt;/code&gt;&lt;/pre&gt;</content><link rel='replies' type='application/atom+xml' href='http://tipsaboutmywork.blogspot.com/feeds/889144858061320751/comments/default' title='Commenti sul post'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/978841978768050379/889144858061320751?isPopup=true' title='0 Commenti'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/978841978768050379/posts/default/889144858061320751'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/978841978768050379/posts/default/889144858061320751'/><link rel='alternate' type='text/html' href='http://tipsaboutmywork.blogspot.com/2010/11/accept-all-ssl-certificate-self-signed.html' title='Accept all SSL certificate (self signed certificate) in Java applications'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/10337520217862613665</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-978841978768050379.post-7340726461142393139</id><published>2010-10-09T18:28:00.000+02:00</published><updated>2010-10-09T18:28:59.703+02:00</updated><title type='text'>Charset in Content-Type Header and Tomcat/Apache couple</title><content type='html'>When a resourse is served by Apache httpd via Tomcat, the Content-Type header is filled with the value defined in mime-mapping tag. You can found this value in the default web.xml under TOMCAT_HOME/conf.&lt;br /&gt;
For resource like html page the Content-Type header is text/html, regardless of charset encoding that the page was written. &lt;br /&gt;
You Apache, by default, is configured with AddDefaultCharset directive (In my Fedora 13 is UTF-8, but may vary between version and distribution you use) that add the charset declaration into Content-Type HTTP Header, if it hasn&#39;t one.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;The problem:&lt;/b&gt;&lt;br /&gt;
If you write an HTML page with ISO-8859-1 and set correctly the meta tag into page as:&lt;br /&gt;
&amp;lt;meta http-equiv=&quot;Content-type&quot; content=&quot;text/html; charset=iso-8859-1&quot;&amp;gt;&lt;br /&gt;
you obtain two different behaviours if your browser get this page directly from Tomcat, or from Apache via mod_jk:&lt;br /&gt;
1) If your browser talk directly with Tomcat, it can detect the encoding by meta tag into html page. &lt;br /&gt;
2) If you get the page from Apache, this one add the charset declaration into Content-Type HTTP Header with his default value from httpd.conf, then you are serving a iso-8859-1 page but your server declare it ad UTF-8.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;To fix this mismatch you can follow two ways:&lt;/b&gt;&lt;br /&gt;
1) Modity the Tomcat&#39;s mime-mapping declaration (in default web.xml or overraid the default mapping in you web.xml):&lt;br /&gt;
&lt;pre  style=&quot;font-family:arial;font-size:12px;border:1px dashed #CCCCCC;width:99%;height:auto;overflow:auto;background:#f0f0f0;;background-image:URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhkEkqfom-xviS-R6LpBvbYIzMEfyHkCO2_HjOuwBc-4REF2rgZc8yZLlueL3VKv2czHoDkh4OdmH6ZlCHdoG2-kT1hMgP-Q1NCL34d4ezZMZ6Bi3Cltk_NlA0y2pvTkMiIIkptz_eEnLym/s320/codebg.gif);padding:0px;color:#000000;text-align:left;line-height:20px;&quot;&gt;&lt;code style=&quot;color:#000000;word-wrap:normal;&quot;&gt;   &amp;lt;mime-mapping&amp;gt;  
    &amp;lt;extension&amp;gt;html&amp;lt;/extension&amp;gt;  
    &amp;lt;mime-type&amp;gt;text/html; charset=utf-8&amp;lt;/mime-type&amp;gt;  
   &amp;lt;/mime-mapping&amp;gt;  
   &amp;lt;mime-mapping&amp;gt;  &lt;br/&gt;
    &amp;lt;extension&amp;gt;css&amp;lt;/extension&amp;gt;  
    &amp;lt;mime-type&amp;gt;text/css; charset=utf-8&amp;lt;/mime-type&amp;gt;  
   &amp;lt;/mime-mapping&amp;gt;  
   &amp;lt;mime-mapping&amp;gt;  &lt;br/&gt;
    &amp;lt;extension&amp;gt;js&amp;lt;/extension&amp;gt;  
    &amp;lt;mime-type&amp;gt;text/javascript; charset=utf-8&amp;lt;/mime-type&amp;gt;  
   &amp;lt;/mime-mapping&amp;gt;  
&lt;/code&gt;&lt;/pre&gt;2) Change default charset in Apache httpd. Note that this work only for content-type either text/plain or text/html, and AddCharset and AddType directives to force this value in other file type (say .js or .css) don&#39;t work for resourses came from mod_jk (from tomcat).&lt;br /&gt;
&lt;br /&gt;
I prefer the first way for two reasones: the know limitation explained on second point and the major liberty of personalization of web.xml configuration (you can serve, as example, from the same virtual host html page from two different webapps with different charser).&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Reference:&lt;/b&gt;&lt;br /&gt;
&lt;a href=&quot;http://httpd.apache.org/docs/2.0/mod/core.html#adddefaultcharset&quot;&gt;AddDefaultCharset&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://httpd.apache.org/docs/2.0/mod/mod_mime.html#addcharset&quot;&gt;AddCharset&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://tipsaboutmywork.blogspot.com/feeds/7340726461142393139/comments/default' title='Commenti sul post'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/978841978768050379/7340726461142393139?isPopup=true' title='0 Commenti'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/978841978768050379/posts/default/7340726461142393139'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/978841978768050379/posts/default/7340726461142393139'/><link rel='alternate' type='text/html' href='http://tipsaboutmywork.blogspot.com/2010/10/charset-in-content-type-header-and.html' title='Charset in Content-Type Header and Tomcat/Apache couple'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/10337520217862613665</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-978841978768050379.post-6189298388413432536</id><published>2010-09-17T19:57:00.001+02:00</published><updated>2010-09-18T22:06:43.963+02:00</updated><title type='text'>openXReports broken on OpenX v.2.8.5</title><content type='html'>If you get this error generating Campaign Delivery Report on OpenX:&lt;br /&gt;
&lt;br /&gt;
&lt;pre  style=&quot;font-family:arial;font-size:12px;border:1px dashed #CCCCCC;width:99%;height:auto;overflow:auto;background:#f0f0f0;;background-image:URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhkEkqfom-xviS-R6LpBvbYIzMEfyHkCO2_HjOuwBc-4REF2rgZc8yZLlueL3VKv2czHoDkh4OdmH6ZlCHdoG2-kT1hMgP-Q1NCL34d4ezZMZ6Bi3Cltk_NlA0y2pvTkMiIIkptz_eEnLym/s320/codebg.gif);padding:0px;color:#000000;text-align:left;line-height:20px;&quot;&gt;&lt;code style=&quot;color:#000000;word-wrap:normal;&quot;&gt; Fatal error: Class &#39;DataObjects_Campaigns&#39; not found in /var/www/openx/plugins/reports/oxReportsStandard/liveCampaignDeliveryReport.class.php on line 251  
&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;
You can repair it adding the red line below on &lt;i&gt;OPENX_PATH&lt;/i&gt;/plugins/reports/oxReportsStandard/liveCampaignDeliveryReport.class.php:&lt;br /&gt;
&lt;br /&gt;
&lt;pre  style=&quot;font-family:arial;font-size:12px;border:1px dashed #CCCCCC;width:99%;height:auto;overflow:auto;background:#f0f0f0;;background-image:URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhkEkqfom-xviS-R6LpBvbYIzMEfyHkCO2_HjOuwBc-4REF2rgZc8yZLlueL3VKv2czHoDkh4OdmH6ZlCHdoG2-kT1hMgP-Q1NCL34d4ezZMZ6Bi3Cltk_NlA0y2pvTkMiIIkptz_eEnLym/s320/codebg.gif);padding:0px;color:#000000;text-align:left;line-height:20px;&quot;&gt;&lt;code style=&quot;color:#000000;word-wrap:normal;&quot;&gt; .  
 .  
 .  
 require_once LIB_PATH . &#39;/Extension/reports/ReportsScope.php&#39;;  
 require_once MAX_PATH . &#39;/lib/OA/Dll.php&#39;;  
 &lt;span style=&quot;color: red;&quot;&gt;require_once MAX_PATH . &#39;/lib/max/Dal/DataObjects/Campaigns.php&#39;;  &lt;/span&gt;
 /**  
  * A plugin to generate a report showing conversion tracking information,  
  * for the supplied date range. The report contains a single worksheet:  
  *  
 .  
 .  
 .  
&lt;/code&gt;&lt;/pre&gt;</content><link rel='replies' type='application/atom+xml' href='http://tipsaboutmywork.blogspot.com/feeds/6189298388413432536/comments/default' title='Commenti sul post'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/978841978768050379/6189298388413432536?isPopup=true' title='1 Commenti'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/978841978768050379/posts/default/6189298388413432536'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/978841978768050379/posts/default/6189298388413432536'/><link rel='alternate' type='text/html' href='http://tipsaboutmywork.blogspot.com/2010/09/openxreports-broken-on-openx-v285.html' title='openXReports broken on OpenX v.2.8.5'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/10337520217862613665</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry></feed>