<?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-7935838433371795797</id><updated>2026-04-13T04:08:54.544-07:00</updated><category term="Troubleshooting"/><category term="JSF"/><category term="JPA"/><category term="Java"/><category term="PrimeFaces"/><category term="Eclipse"/><category term="Spring"/><category term="VirtualBox"/><category term="MySQL"/><category term="Tomcat"/><category term="javascript"/><category term="Maven"/><category term="android"/><category term="Hibernate"/><category term="Latex"/><category term="Linux"/><category term="Bash"/><category term="jQuery"/><category term="Networking"/><category term="Games"/><category term="GlassFish"/><category term="Servlet"/><category term="Ubuntu"/><category term="css"/><category term="git"/><category term="html"/><category term="Apache"/><category term="Gnome"/><category term="Javadoc"/><category term="Pitfalls"/><category term="encoding"/><category term="phpMyAdmin"/><category term="sed"/><category term="AmaterasUML"/><category term="Apache cxf"/><category term="EL"/><category term="JBoss 5.1"/><category term="JUnit"/><category term="Maven_dependencies"/><category term="Ogre"/><category term="PostgreSQL"/><category term="Security"/><category term="log4j"/><category term="ssh"/><category term="sudo"/><category term="svn"/><category term="wget"/><category term="A500"/><category term="Activiti"/><category term="Ant"/><category term="Aspose"/><category term="BIRT"/><category term="BOM"/><category term="Blogspot"/><category term="Bullet"/><category term="C"/><category term="Dell Inspiron 17R"/><category term="Drivers"/><category term="Economics"/><category term="Firebug"/><category term="Gimp"/><category term="Gnome Shell"/><category term="Grails"/><category term="HandBreak"/><category term="Hudson"/><category term="Irrlicht"/><category term="JAXB"/><category term="Jar"/><category term="List of sw"/><category term="Localization"/><category term="MoinMoin"/><category term="Ogre3d"/><category term="Open Issues"/><category term="Optimization"/><category term="Photoshop"/><category term="Programmin"/><category term="Prototype"/><category term="R"/><category term="REST"/><category term="Radio"/><category term="SQL"/><category term="Servers"/><category term="Spring Data"/><category term="Spring Security"/><category term="Squirrel"/><category term="System Administration"/><category term="Testing"/><category term="Tora"/><category term="Trou"/><category term="UML"/><category term="VLC"/><category term="Velocity"/><category term="Web Development"/><category term="androi"/><category term="aspell"/><category term="avahi"/><category term="awt"/><category term="book"/><category term="camel"/><category term="curl"/><category term="ffmpeg"/><category term="flash"/><category term="free"/><category term="gnuplot"/><category term="graphviz"/><category term="html5"/><category term="iPhone"/><category term="imagemagick"/><category term="jBPM"/><category term="jtable"/><category term="ldd"/><category term="libreoffice"/><category term="mav"/><category term="mongodb"/><category term="mv"/><category term="nagios"/><category term="nethogs"/><category term="nslookup"/><category term="openoffice"/><category term="oracle database"/><category term="perl"/><category term="php"/><category term="phpPgAdmin"/><category term="port"/><category term="review"/><category term="swing"/><category term="thread local"/><category term="tr"/><category term="vnc"/><category term="web analytics"/><category term="webcheck"/><category term="xstream"/><title type='text'>micharg</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://micharg.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7935838433371795797/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://micharg.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/7935838433371795797/posts/default?start-index=26&amp;max-results=25&amp;redirect=false'/><author><name>micharg</name><uri>http://www.blogger.com/profile/12733531629600432067</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>353</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-7935838433371795797.post-3446666566964730239</id><published>2019-05-11T13:40:00.002-07:00</published><updated>2019-05-11T13:40:59.166-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="nagios"/><title type='text'>Patched Nagios scripts to monitor top 5 processes using CPU / memory</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
Overview&lt;/h2&gt;
Unfortunately the Nagios scripts (plugins) provided in&amp;nbsp;&lt;a href=&quot;https://exchange.nagios.org/directory/Plugins/System-Metrics/CPU-Usage-and-Load/CPU-Stats-2FMemory-Used-Plugin--2D-Top-5-CPU-2FMemory-Consuming-Processes-for-Unix-Servers/details&quot;&gt;https://exchange.nagios.org/directory/Plugins/System-Metrics/CPU-Usage-and-Load/CPU-Stats-2FMemory-Used-Plugin--2D-Top-5-CPU-2FMemory-Consuming-Processes-for-Unix-Servers/details&lt;/a&gt;&amp;nbsp;are not maintained since 2012 and do not work in Linux (tried with CentOS 7.x). I provide later on this page their patched versions for Linux (tried with CentOS 7.x but it should be OK for any Linux version - please confirm / or not).&lt;br /&gt;
&lt;br /&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
Prerequisites&lt;/h2&gt;
Install the following:&lt;br /&gt;
# yum install bc ksh sysstat&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
Patched Nagios scripts&lt;/h2&gt;
Patched files working on CentOS 7.x:&lt;br /&gt;
&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;&lt;a href=&quot;https://drive.google.com/open?id=1jqlOBOJALGujUWsZ1j_UhbQWY9iXfYm5&quot;&gt;check_cpu_stats.sh&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://drive.google.com/open?id=1xpfFUcBZw3XG-39XwRTJjJAQhtzQ0W4K&quot;&gt;check_mem_hpux_custom&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://micharg.blogspot.com/feeds/3446666566964730239/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://micharg.blogspot.com/2019/05/patched-nagios-scripts-to-monitor-top-5.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7935838433371795797/posts/default/3446666566964730239'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7935838433371795797/posts/default/3446666566964730239'/><link rel='alternate' type='text/html' href='http://micharg.blogspot.com/2019/05/patched-nagios-scripts-to-monitor-top-5.html' title='Patched Nagios scripts to monitor top 5 processes using CPU / memory'/><author><name>micharg</name><uri>http://www.blogger.com/profile/12733531629600432067</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-7935838433371795797.post-4226750807518457411</id><published>2015-11-26T01:56:00.003-08:00</published><updated>2015-11-26T02:25:12.334-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="awt"/><category scheme="http://www.blogger.com/atom/ns#" term="jtable"/><category scheme="http://www.blogger.com/atom/ns#" term="swing"/><title type='text'>JTable: overriding default behaviours</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;/div&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
JTable and Tab/Shift-Tab&lt;/h3&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
By default when the focus in in a JTable then Tab changes focus to the next cell. If the cell is the last one then the 1st cell is focused. Shift-Tab does the opposite.&lt;/div&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
disable Tab/Shift-Tab&lt;/h4&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
myJTable.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0), &quot;none&quot;);&lt;br /&gt;
myJTable.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; KeyStroke.getKeyStroke(KeyEvent.VK_TAB, InputEvent.SHIFT_DOWN_MASK), &quot;none&quot;);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/div&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
moving to next component&lt;/h4&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
Assuming we want to move out of the JTable to the next/prev UI component (instead of the next/prev cell) we can do the following to modify the default behaviour:&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;Set&amp;lt;AWTKeyStroke&amp;gt; forward = new HashSet&amp;lt;AWTKeyStroke&amp;gt;(&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; myJTable.getFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS));&lt;br /&gt;
forward.add(KeyStroke.getKeyStroke(&quot;TAB&quot;));&lt;br /&gt;
myJTable.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, forward);&lt;br /&gt;
Set&amp;lt;AWTKeyStroke&amp;gt; backward = new HashSet&amp;lt;AWTKeyStroke&amp;gt;(&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; myJTable.getFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS));&lt;br /&gt;
backward.add(KeyStroke.getKeyStroke(&quot;shift TAB&quot;));&lt;br /&gt;
myJTable.setFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, backward);&lt;br /&gt;
&lt;br /&gt;
// create the policy which determines what will be the next/prev UI component on Tab/Shift-Tab &amp;nbsp;&amp;nbsp; &lt;br /&gt;
class TabFocusTraversalPolicy extends DefaultFocusTraversalPolicy&amp;nbsp; {&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; private static final long serialVersionUID = 1L;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @Override&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; public Component getComponentAfter(Container container, Component component) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; Component nextComponent = null;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; if(...) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; nextComponent = ...;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; } else if(component == ...) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; nextComponent = ...;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; }&amp;nbsp; else {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; nextComponent = super.getComponentAfter(container, component);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; return nextComponent;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; }&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @Override&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; public Component getComponentBefore(Container container, Component component) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; Component nextComponent = null;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; if(...) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; nextComponent = ...;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; } else if(...) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; nextComponent = ...;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&amp;nbsp; else {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; nextComponent = super.getComponentBefore(container, component);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; return nextComponent;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; }&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; @Override&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; public Component getDefaultComponent(Container container) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return super.getDefaultComponent(container);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; @Override&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; public Component getFirstComponent(Container container) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return super.getFirstComponent(container);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; @Override&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; public Component getLastComponent(Container container) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return super.getLastComponent(container);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &lt;br /&gt;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&lt;br /&gt;
// install the policy to the JTable &lt;br /&gt;
&amp;nbsp;myTable.setFocusCycleRoot(true); // if not true then the policy is not triggered&lt;br /&gt;
&amp;nbsp;myTable..setFocusTraversalPolicy(newPolicy);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
references:&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;&lt;a href=&quot;http://stackoverflow.com/questions/12154734/change-focus-to-next-component-in-jtable-using-tab/12157344#12157344&quot;&gt;StackOverflow&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
JTable and Enter&lt;/h3&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;/div&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
Enter: selects next row&lt;/h4&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
By default when we click Enter in a JTable where a row is selected then the next row gets the focus.&lt;br /&gt;
&lt;br /&gt;
In order to disable this do the following:&lt;br /&gt;
myJTable.getActionMap().put(&quot;Enter&quot;, new AbstractAction() {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; private static final long serialVersionUID = 1L;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; @Override&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; public void actionPerformed(ActionEvent ae) {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; // override default behaviour which selects the next row&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
});&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://micharg.blogspot.com/feeds/4226750807518457411/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://micharg.blogspot.com/2015/11/jtable-overriding-default-behaviours.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7935838433371795797/posts/default/4226750807518457411'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7935838433371795797/posts/default/4226750807518457411'/><link rel='alternate' type='text/html' href='http://micharg.blogspot.com/2015/11/jtable-overriding-default-behaviours.html' title='JTable: overriding default behaviours'/><author><name>micharg</name><uri>http://www.blogger.com/profile/12733531629600432067</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-7935838433371795797.post-2316850547270137289</id><published>2015-09-12T10:48:00.001-07:00</published><updated>2015-09-12T10:48:29.438-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Java"/><category scheme="http://www.blogger.com/atom/ns#" term="Pitfalls"/><title type='text'>How to sort an Array of Strings</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
This is a silly mistake I did..&lt;br /&gt;
&lt;br /&gt;
Don&#39;t use&lt;br /&gt;
&lt;i&gt;Arrays.sort(strs.toArray(new String[0]));&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;
&lt;br /&gt;
Instead use the following:&lt;br /&gt;
&lt;i&gt;Collections.sort(strs);&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://micharg.blogspot.com/feeds/2316850547270137289/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://micharg.blogspot.com/2015/09/how-to-sort-array-of-strings.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7935838433371795797/posts/default/2316850547270137289'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7935838433371795797/posts/default/2316850547270137289'/><link rel='alternate' type='text/html' href='http://micharg.blogspot.com/2015/09/how-to-sort-array-of-strings.html' title='How to sort an Array of Strings'/><author><name>micharg</name><uri>http://www.blogger.com/profile/12733531629600432067</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-7935838433371795797.post-1491037102494331042</id><published>2015-09-09T00:20:00.003-07:00</published><updated>2015-09-09T05:53:14.196-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="mongodb"/><category scheme="http://www.blogger.com/atom/ns#" term="Pitfalls"/><title type='text'>MongoDB: The ugly things</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Here is a list of all the ugly things that I have found so far regarding MongoDB:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
Writes that return errors to the client due to &lt;i&gt;wtimeout &lt;/i&gt;may in fact succeed (&lt;a href=&quot;http://docs.mongodb.org/manual/reference/write-concern/#wc-wtimeout&quot;&gt;link&lt;/a&gt;)&lt;/h3&gt;
&lt;div&gt;
Regarding the option &lt;i&gt;wtimeout&lt;/i&gt;:&lt;/div&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
This option specifies a time limit, in milliseconds, for the write
concern. &lt;tt class=&quot;docutils literal&quot;&gt;wtimeout&lt;/tt&gt; is only applicable for &lt;tt class=&quot;docutils literal&quot;&gt;w&lt;/tt&gt; values greater than
&lt;tt class=&quot;docutils literal&quot;&gt;1&lt;/tt&gt;.&lt;br /&gt;
&lt;b&gt;&lt;tt class=&quot;docutils literal&quot;&gt;wtimeout&lt;/tt&gt; causes write operations to return with an error
after the specified limit, even if the required write concern will
eventually succeed. When these write operations return,
&lt;u&gt;MongoDB does not undo successful data modifications&lt;/u&gt; performed
before the write concern exceeded the &lt;tt class=&quot;docutils literal&quot;&gt;wtimeout&lt;/tt&gt; time limit.&lt;/b&gt;&lt;br /&gt;
If you do not specify the &lt;tt class=&quot;docutils literal&quot;&gt;&lt;span class=&quot;pre&quot;&gt;wtimeout&lt;/span&gt;&lt;/tt&gt; option and the level of write
concern is unachievable, the write operation will block indefinitely.
Specifying a &lt;tt class=&quot;docutils literal&quot;&gt;&lt;span class=&quot;pre&quot;&gt;wtimeout&lt;/span&gt;&lt;/tt&gt; value of &lt;tt class=&quot;docutils literal&quot;&gt;&lt;span class=&quot;pre&quot;&gt;0&lt;/span&gt;&lt;/tt&gt; is equivalent to a write
concern without the &lt;tt class=&quot;docutils literal&quot;&gt;&lt;span class=&quot;pre&quot;&gt;wtimeout&lt;/span&gt;&lt;/tt&gt; option.&lt;/blockquote&gt;
&lt;br /&gt;
WTF?&lt;br /&gt;
&lt;br /&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
Maximum document size is 16MB (&lt;a href=&quot;http://docs.mongodb.org/master/reference/limits/&quot;&gt;link&lt;/a&gt;)&lt;/h3&gt;
&lt;div&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
The maximum BSON document size is 16 megabytes.&lt;/blockquote&gt;
&lt;br /&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
A client may think that a write was successful but it wasn&#39;t!&lt;/h3&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
Even with (w=1 or w=&#39;majority&#39;) and (j=1), it is possible to wind up rolling back a committed write to the primary on failover (link) and the client may think that the write was successful but it wasn&#39;t!&lt;br /&gt;
&lt;br /&gt;
&lt;u&gt;Examples&lt;/u&gt;&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;The
 network TCP connection between the application and the server was reset
 after the server received a write but before a response could be sent.&lt;/li&gt;
&lt;li&gt;The MongoDB server terminates between receiving the write and responding to it.&lt;/li&gt;
&lt;li&gt;The network fails between the time of the write and the time the client receives a response to the write.&amp;nbsp;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;br /&gt;
w=&#39;majority&#39; doesn&#39;t resolve the problem because the parameter j doesn&#39;t affect the replicas (&lt;a href=&quot;http://docs.mongodb.org/manual/reference/write-concern/&quot;&gt;link&lt;/a&gt;):&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
Requiring journaled write concern in a replica set only requires a journal commit of the write operation to the primary of the set regardless of the level of replica acknowledged write concern.&lt;/blockquote&gt;
&amp;nbsp;You can find more information on the &lt;a href=&quot;http://docs.mongodb.org/master/core/replica-set-rollbacks/&quot;&gt;official MongoDB docs&lt;/a&gt; and a relative &lt;a href=&quot;http://stackoverflow.com/questions/22410831/can-rollback-still-occur-on-a-mongodb-replica-set-with-j-1-and-w-majority&quot;&gt;StackOverflow post&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
A client doesn&#39;t get a response after a write and thinks that the write didn&#39;t happen but happened!&lt;/h3&gt;
&lt;div&gt;
Usually the MongoDB client (e.g. Java driver) tackles the following problems transparently to the developer:&lt;/div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;&lt;b&gt;insert&lt;/b&gt; isn&#39;t acknowledged --&amp;gt; re-execute it (provided the _id was set by the client and is the same on both executions)&lt;/li&gt;
&lt;li&gt;&lt;b&gt;update&lt;/b&gt;&amp;nbsp;isn&#39;t acknowledged&amp;nbsp;--&amp;gt;&amp;nbsp;treat it as deletion and insertion&amp;nbsp;&lt;/li&gt;
&lt;li&gt;&lt;b&gt;deletion&amp;nbsp;&lt;/b&gt;isn&#39;t acknowledged&amp;nbsp;--&amp;gt;&amp;nbsp;idempotent; re-execute it&lt;/li&gt;
&lt;li&gt;&lt;b&gt;find&amp;nbsp;&lt;/b&gt;isn&#39;t acknowledged&amp;nbsp;--&amp;gt;&amp;nbsp;idempotent; re-execute it&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
During failover writes cannot occur (i.e. they fail)&lt;/h3&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
When the primary node fails, another is elected from its replica set. During the election the client cannot write. This is because in MongoDB only the primary node can accept writes.&lt;/div&gt;
&lt;br /&gt;
Therefore you may have to guard your code and try to re-execute the failed write.&lt;br /&gt;
By the way can the MongoDB driver do anything about it?&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://micharg.blogspot.com/feeds/1491037102494331042/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://micharg.blogspot.com/2015/09/mongodb-ugly-things.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7935838433371795797/posts/default/1491037102494331042'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7935838433371795797/posts/default/1491037102494331042'/><link rel='alternate' type='text/html' href='http://micharg.blogspot.com/2015/09/mongodb-ugly-things.html' title='MongoDB: The ugly things'/><author><name>micharg</name><uri>http://www.blogger.com/profile/12733531629600432067</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-7935838433371795797.post-3030004629588650915</id><published>2014-12-20T06:55:00.003-08:00</published><updated>2014-12-20T06:55:29.620-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Gnome Shell"/><category scheme="http://www.blogger.com/atom/ns#" term="Hibernate"/><title type='text'>How to hibernate Gnome Shell</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Install the relative plugin found on https://extensions.gnome.org/extension/755/hibernate-status-button/&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://micharg.blogspot.com/feeds/3030004629588650915/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://micharg.blogspot.com/2014/12/how-to-hibernate-gnome-shell.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7935838433371795797/posts/default/3030004629588650915'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7935838433371795797/posts/default/3030004629588650915'/><link rel='alternate' type='text/html' href='http://micharg.blogspot.com/2014/12/how-to-hibernate-gnome-shell.html' title='How to hibernate Gnome Shell'/><author><name>micharg</name><uri>http://www.blogger.com/profile/12733531629600432067</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-7935838433371795797.post-6958101035933399796</id><published>2014-11-07T00:18:00.001-08:00</published><updated>2014-11-07T00:18:06.367-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="oracle database"/><title type='text'>Oracle Database error: ORA-01109: database not open</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Oracle db installed on VM / my host computer powered off =&amp;gt; VM halted&lt;br /&gt;When trying to run a SQL script I got &quot;ORA-01109: database not open&quot;&lt;br /&gt;&lt;br /&gt;More info.. starting SQLPLUS:&lt;br /&gt;SQL&amp;gt; shutdown normal;&lt;br /&gt;ORA-01109: database not open&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; startup;&lt;br /&gt;ORACLE instance started.&lt;br /&gt;Database mounted.&lt;br /&gt;ORA-00600: internal error code, arguments: [kcratr_scan_lastbwr], [], [], [],&lt;br /&gt;[], [], [], [], [], [], [], []&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; recover database;&lt;br /&gt;Media recovery complete.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; shutdown normal;&lt;br /&gt;ORA-01109: database not open&lt;br /&gt;Database dismounted.&lt;br /&gt;ORACLE instance shut down.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; startup;&lt;br /&gt;Database opened.&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://micharg.blogspot.com/feeds/6958101035933399796/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://micharg.blogspot.com/2014/11/oracle-database-error-ora-01109.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7935838433371795797/posts/default/6958101035933399796'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7935838433371795797/posts/default/6958101035933399796'/><link rel='alternate' type='text/html' href='http://micharg.blogspot.com/2014/11/oracle-database-error-ora-01109.html' title='Oracle Database error: ORA-01109: database not open'/><author><name>micharg</name><uri>http://www.blogger.com/profile/12733531629600432067</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-7935838433371795797.post-5464332330849479004</id><published>2014-11-06T04:44:00.000-08:00</published><updated>2014-11-06T04:44:11.578-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="VirtualBox"/><title type='text'>Virtualbox: How to mount shared folder</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
create shared folder on host:&lt;br /&gt;Settings / Shared Folders / Adds a new shared folder definition. / &lt;br /&gt;&amp;nbsp; Folder Path: C:/shared&lt;br /&gt;&amp;nbsp; Folder Name: shared&lt;br /&gt;&amp;nbsp; mark: &quot;Auto-mount&quot; and &quot;Make Permanent&quot;&lt;br /&gt;&lt;u&gt;&amp;nbsp;&lt;/u&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;u&gt;Manually mount shared folder:&lt;/u&gt;&lt;br /&gt;mount shared folder on guest os (linux):&lt;br /&gt;&lt;br /&gt;# mkir /mnt/shared&lt;br /&gt;# usermod -G vboxsf -a oracle&lt;br /&gt;# mount.vboxsf shared /mnt/shared&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;u&gt;Auto-mount shared folder on start-up:&lt;/u&gt;&lt;br /&gt;# mkir /mnt/shared&lt;br /&gt;/etc/fstab:&lt;br /&gt;shared&amp;nbsp;&amp;nbsp; /mnt/shared&amp;nbsp;&amp;nbsp; vboxsf&amp;nbsp;&amp;nbsp; defaults&amp;nbsp; 0&amp;nbsp;&amp;nbsp; 0&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://micharg.blogspot.com/feeds/5464332330849479004/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://micharg.blogspot.com/2014/11/virtualbox-how-to-mount-shared-folder.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7935838433371795797/posts/default/5464332330849479004'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7935838433371795797/posts/default/5464332330849479004'/><link rel='alternate' type='text/html' href='http://micharg.blogspot.com/2014/11/virtualbox-how-to-mount-shared-folder.html' title='Virtualbox: How to mount shared folder'/><author><name>micharg</name><uri>http://www.blogger.com/profile/12733531629600432067</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-7935838433371795797.post-5413415997442643045</id><published>2014-11-06T03:38:00.002-08:00</published><updated>2014-11-06T03:38:07.801-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="sudo"/><title type='text'>add user xxx to sudo</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Add user micharg to sudo:&lt;br /&gt;$ sudo -i&lt;br /&gt;# visudo&lt;br /&gt;&amp;nbsp; micharg ALL=(ALL)&amp;nbsp;&amp;nbsp;&amp;nbsp; ALL&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://micharg.blogspot.com/feeds/5413415997442643045/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://micharg.blogspot.com/2014/11/add-user-xxx-to-sudo.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7935838433371795797/posts/default/5413415997442643045'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7935838433371795797/posts/default/5413415997442643045'/><link rel='alternate' type='text/html' href='http://micharg.blogspot.com/2014/11/add-user-xxx-to-sudo.html' title='add user xxx to sudo'/><author><name>micharg</name><uri>http://www.blogger.com/profile/12733531629600432067</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-7935838433371795797.post-7294970342321700474</id><published>2014-11-06T03:36:00.002-08:00</published><updated>2014-11-06T03:36:32.636-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Troubleshooting"/><category scheme="http://www.blogger.com/atom/ns#" term="VirtualBox"/><title type='text'>Virtualbox: copy/paste between host-guest doesn&#39;t work (solved)</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;a href=&quot;https://forums.virtualbox.org/viewtopic.php?f=6&amp;amp;t=50330&quot;&gt;Solution (doesn&#39;t work)&lt;/a&gt;&lt;u&gt;:&lt;/u&gt;&lt;br /&gt;&lt;br /&gt;Virtualbox copy/paste between host-guest doesn&#39;t work:&lt;br /&gt;Settings--&amp;gt;Storage--&amp;gt;SATA Controller and 2. &#39;Solid-state drive&#39; is checked &lt;br /&gt;&lt;br /&gt;DIDN&#39;T WORK&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;u&gt;Solution #2:&lt;/u&gt;&lt;br /&gt;&lt;br /&gt;Settings / General / Advanced:&lt;br /&gt;&amp;nbsp;&amp;nbsp; Shared Clipboard: Bidirectional&lt;br /&gt;&amp;nbsp;&amp;nbsp; Drag&#39;n&#39;Drop: Bidirectional&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://micharg.blogspot.com/feeds/7294970342321700474/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://micharg.blogspot.com/2014/11/virtualbox-copypaste-between-host-guest.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7935838433371795797/posts/default/7294970342321700474'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7935838433371795797/posts/default/7294970342321700474'/><link rel='alternate' type='text/html' href='http://micharg.blogspot.com/2014/11/virtualbox-copypaste-between-host-guest.html' title='Virtualbox: copy/paste between host-guest doesn&#39;t work (solved)'/><author><name>micharg</name><uri>http://www.blogger.com/profile/12733531629600432067</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-7935838433371795797.post-156851848452540859</id><published>2014-11-05T07:07:00.000-08:00</published><updated>2014-11-05T07:07:45.080-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="libreoffice"/><category scheme="http://www.blogger.com/atom/ns#" term="openoffice"/><category scheme="http://www.blogger.com/atom/ns#" term="Troubleshooting"/><title type='text'>Java 64bit not supported by LibreOffice nor OpenOffice</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Install Java 32bit&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://micharg.blogspot.com/feeds/156851848452540859/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://micharg.blogspot.com/2014/11/java-64bit-not-supported-by-libreoffice.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7935838433371795797/posts/default/156851848452540859'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7935838433371795797/posts/default/156851848452540859'/><link rel='alternate' type='text/html' href='http://micharg.blogspot.com/2014/11/java-64bit-not-supported-by-libreoffice.html' title='Java 64bit not supported by LibreOffice nor OpenOffice'/><author><name>micharg</name><uri>http://www.blogger.com/profile/12733531629600432067</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-7935838433371795797.post-6500850893993252614</id><published>2014-10-11T07:28:00.002-07:00</published><updated>2014-10-11T07:29:39.305-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Spring Data"/><title type='text'>Spring Data: How to call a stored procedure</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
&lt;a href=&quot;http://docs.spring.io/spring-data/jpa/docs/1.6.4.RELEASE/reference/html/jpa.repositories.html&quot;&gt;Spring data reference&lt;/a&gt; supports calling stored procedure (from JPA 2.1) but didn&#39;t work for me. Therefore I called the stored procedure with a native query:&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;@Repository&lt;br /&gt;public interface MyEntityRepository extends PagingAndSortingRepository&amp;lt;MyEntity, Long&amp;gt; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; @Query(nativeQuery=true, value=&quot;{call GetFoo()}&quot;)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Object[] callMyStoredProcedure();&lt;br /&gt;}&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
Details:&lt;br /&gt;
&lt;br /&gt;
1) We are obliged to write the call in an entity repository. Therefore choose an entity in random (e.g. I used MyEntity) and place there your stored procedure call.&lt;br /&gt;
&lt;br /&gt;
2) The stored procedure with name GetFoo() joins some tables, etc, and returns a row. Its columns are stored in the returned Object[].&lt;br /&gt;
&lt;br /&gt;
PS: For Spring Data and Stored Procedures check the following sites:&lt;br /&gt;
- http://blogs.isostech.com/database/jpa-spring-data-awesomeness/&lt;br /&gt;
&amp;nbsp;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://micharg.blogspot.com/feeds/6500850893993252614/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://micharg.blogspot.com/2014/10/spring-data-how-to-call-stored-procedure.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7935838433371795797/posts/default/6500850893993252614'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7935838433371795797/posts/default/6500850893993252614'/><link rel='alternate' type='text/html' href='http://micharg.blogspot.com/2014/10/spring-data-how-to-call-stored-procedure.html' title='Spring Data: How to call a stored procedure'/><author><name>micharg</name><uri>http://www.blogger.com/profile/12733531629600432067</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-7935838433371795797.post-9028903864237470205</id><published>2014-10-05T23:56:00.000-07:00</published><updated>2014-10-06T00:00:24.593-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="book"/><category scheme="http://www.blogger.com/atom/ns#" term="camel"/><category scheme="http://www.blogger.com/atom/ns#" term="review"/><title type='text'>Review of book &quot;Apache Camel Developer&#39;s Cookbook&quot;</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
      &lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
Spoiler: I have been assigned &lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&lt;/span&gt;to review this &quot;Apache Camel        Developer&#39;s Cookbook&quot; since I won a free copy in        a contest on LinkedIn.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
This book should be read by developers already        familiar with        Camel existence (e.g. read first &quot;Camel in Action&quot; - you will        learn        how Camel works). It references the most Valuable EIPs with a good        discussion        and examples (and code maven managed!) about each one. It presents        EIPs like        Content Based Router, Filter, Wire Tap, Multicast, Content        Enricher, Recipient        List, Throttler, Load Balancer, Routing Slip, Enricher, Splitter,        etc. Its        follows the common PACKT&#39;s presentation format &quot;Getting ready&quot; /        &quot;How to do it...&quot; / &quot;How it works...&quot; / &quot;There&#39;s        more...&quot; / &quot;See also&quot;. It felt like reading Camel&#39;s official        Documentation        but from a user guide&#39;s approach and not a detailed reference        approach.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
What I liked most was a whole a chapter on        testing.        Integration with Spring (a common usage scenario) is also        presented throughout        the book. I really liked &quot;Chapter 8: Transactions and Idempotency&quot;        where more advanced issues are presented about transactions on a        single-resource        and on how to implement distributed transactions without XA (hint:        using        Idempotent EIP).&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
To sum up:&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
- Don&#39;t read it if this is your first contact        with Camel.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
- Read it if you want good examples on how to        use Camel&#39;s        patterns and official documentation is not enough for you. Source        code provides        hands-on experience on all the EIPs presented on the book.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp; &lt;/span&gt;&lt;/div&gt;
&lt;link href=&quot;file:///C:%5CUsers%5CArgyriou%5CAppData%5CLocal%5CTemp%5Cmsohtml1%5C01%5Cclip_filelist.xml&quot; rel=&quot;File-List&quot;&gt;&lt;/link&gt;      &lt;!--[if gte mso 9]&gt;&lt;xml&gt;   &lt;w:WordDocument&gt;    &lt;w:View&gt;Normal&lt;/w:View&gt;    &lt;w:Zoom&gt;0&lt;/w:Zoom&gt;    &lt;w:PunctuationKerning/&gt;    &lt;w:ValidateAgainstSchemas/&gt;    &lt;w:SaveIfXMLInvalid&gt;false&lt;/w:SaveIfXMLInvalid&gt;    &lt;w:IgnoreMixedContent&gt;false&lt;/w:IgnoreMixedContent&gt;    &lt;w:AlwaysShowPlaceholderText&gt;false&lt;/w:AlwaysShowPlaceholderText&gt;    &lt;w:Compatibility&gt;     &lt;w:BreakWrappedTables/&gt;     &lt;w:SnapToGridInCell/&gt;     &lt;w:WrapTextWithPunct/&gt;     &lt;w:UseAsianBreakRules/&gt;     &lt;w:DontGrowAutofit/&gt;    &lt;/w:Compatibility&gt;    &lt;w:BrowserLevel&gt;MicrosoftInternetExplorer4&lt;/w:BrowserLevel&gt;   &lt;/w:WordDocument&gt;  &lt;/xml&gt;&lt;![endif]--&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;   &lt;w:LatentStyles DefLockedState=&quot;false&quot; LatentStyleCount=&quot;156&quot;&gt;   &lt;/w:LatentStyles&gt;  &lt;/xml&gt;&lt;![endif]--&gt;      &lt;style&gt;  &lt;!--   /* Style Definitions */   p.MsoNormal, li.MsoNormal, div.MsoNormal   {mso-style-parent:&quot;&quot;;   margin:0cm;   margin-bottom:.0001pt;   mso-pagination:widow-orphan;   font-size:12.0pt;   font-family:&quot;Times New Roman&quot;;   mso-fareast-font-family:&quot;Times New Roman&quot;;}  @page Section1   {size:595.3pt 841.9pt;   margin:72.0pt 90.0pt 72.0pt 90.0pt;   mso-header-margin:35.4pt;   mso-footer-margin:35.4pt;   mso-paper-source:0;}  div.Section1   {page:Section1;}  --&gt;  &lt;/style&gt;&lt;!--[if gte mso 10]&gt;  &lt;style&gt;   /* Style Definitions */   table.MsoNormalTable   {mso-style-name:&quot;Table Normal&quot;;   mso-tstyle-rowband-size:0;   mso-tstyle-colband-size:0;   mso-style-noshow:yes;   mso-style-parent:&quot;&quot;;   mso-padding-alt:0cm 5.4pt 0cm 5.4pt;   mso-para-margin:0cm;   mso-para-margin-bottom:.0001pt;   mso-pagination:widow-orphan;   font-size:10.0pt;   font-family:&quot;Times New Roman&quot;;   mso-ansi-language:#0400;   mso-fareast-language:#0400;   mso-bidi-language:#0400;}  &lt;/style&gt;  &lt;![endif]--&gt;    &lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://micharg.blogspot.com/feeds/9028903864237470205/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://micharg.blogspot.com/2014/10/review-of-book-apache-camel-developers.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7935838433371795797/posts/default/9028903864237470205'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7935838433371795797/posts/default/9028903864237470205'/><link rel='alternate' type='text/html' href='http://micharg.blogspot.com/2014/10/review-of-book-apache-camel-developers.html' title='Review of book &quot;Apache Camel Developer&#39;s Cookbook&quot;'/><author><name>micharg</name><uri>http://www.blogger.com/profile/12733531629600432067</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-7935838433371795797.post-4281045014468524053</id><published>2014-09-23T07:19:00.000-07:00</published><updated>2014-09-23T07:28:12.877-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="svn"/><title type='text'>SVN: delete all .svn (recursively)</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;a href=&quot;http://stackoverflow.com/questions/4889619/command-to-recursively-remove-all-svn-directories-on-windows&quot;&gt;Windows&lt;/a&gt;:&lt;br /&gt;
FOR /F &quot;tokens=*&quot; %G IN (&#39;DIR /B /AD /S *.svn*&#39;) DO RMDIR /S /Q &quot;%G&quot;&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;https://www.blogger.com/blogger.g?blogID=7935838433371795797#editor/target=post;postID=4281045014468524053&quot;&gt;Linux&lt;/a&gt;:&lt;br /&gt;
find . -type d -name &#39;.svn&#39; -print -exec rm -rf {} \;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://micharg.blogspot.com/feeds/4281045014468524053/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://micharg.blogspot.com/2014/09/svn-delete-all-svn-recursively.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7935838433371795797/posts/default/4281045014468524053'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7935838433371795797/posts/default/4281045014468524053'/><link rel='alternate' type='text/html' href='http://micharg.blogspot.com/2014/09/svn-delete-all-svn-recursively.html' title='SVN: delete all .svn (recursively)'/><author><name>micharg</name><uri>http://www.blogger.com/profile/12733531629600432067</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-7935838433371795797.post-8892136782183569650</id><published>2014-09-18T05:23:00.000-07:00</published><updated>2014-09-18T05:28:12.141-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Spring"/><category scheme="http://www.blogger.com/atom/ns#" term="Spring Security"/><category scheme="http://www.blogger.com/atom/ns#" term="thread local"/><category scheme="http://www.blogger.com/atom/ns#" term="Troubleshooting"/><title type='text'>Spring Security + @Async problem: (SecurityContextHolder is empty)</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
&lt;b&gt;Problem: &lt;/b&gt;I annotated a method with &lt;i&gt;@Async&lt;/i&gt; and &lt;i&gt;@PreAuthorize&lt;/i&gt;      so that is executed asynchronously and be secured.&lt;br /&gt;
But it seems the security context (&lt;i&gt;SecurityContextHolder&lt;/i&gt;) is      not populated (althouth user has authenticated).&lt;br /&gt;
This happens only if the method is annotated with &lt;i&gt;@Async&lt;/i&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Solution:&lt;/b&gt; From &lt;i&gt;SecurityContextHolder &lt;/i&gt;we can get e.g.      the logged in username (e.g. check &lt;a href=&quot;http://www.mkyong.com/spring-security/get-current-logged-in-username-in-spring-security/&quot;&gt;this&lt;/a&gt;).      &lt;i&gt;SecurityContextHolder &lt;/i&gt;is saved in &lt;br /&gt;
current thread [1]. When we spawn a new thread the current thread&#39;s      &lt;i&gt;&lt;i&gt;SecurityContextHolder&amp;nbsp;&lt;/i&gt;&lt;/i&gt; (which is a&lt;i&gt;&lt;i&gt; &lt;/i&gt;ThreadLocal&lt;/i&gt;s)      &lt;br /&gt;
is not copied/inherited. &lt;br /&gt;
&lt;br /&gt;
In order to inherit it do the following:&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;i&gt;&amp;lt;bean  class=&quot;org.springframework.beans.factory.config.MethodInvokingFactoryBean&quot;&amp;gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;property name=&quot;targetClass&quot;      value=&quot;org.springframework.security.core.context.SecurityContextHolder&quot;      /&amp;gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;property name=&quot;targetMethod&quot; value=&quot;setStrategyName&quot;      /&amp;gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;property name=&quot;arguments&quot;&amp;gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;list&amp;gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&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; &amp;lt;value&amp;gt;&lt;b&gt;MODE_INHERITABLETHREADLOCAL&lt;/b&gt;&amp;lt;/value&amp;gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/list&amp;gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/property&amp;gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/bean&amp;gt;&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
All possible modes:&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;MODE_THREADLOCAL (default strategy)&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://docs.spring.io/autorepo/docs/spring-security/3.1.7.RELEASE/apidocs/org/springframework/security/core/context/SecurityContextHolder.html#MODE_INHERITABLETHREADLOCAL&quot;&gt;MODE_INHERITABLETHREADLOCAL&lt;/a&gt;:          spawned threads inherit SecurityContext of the parent thread&lt;/li&gt;
&lt;li&gt;MODE_THREADLOCAL &lt;/li&gt;
&lt;li&gt;SYSTEM_PROPERTY &lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
[1] From the Spring &lt;a href=&quot;http://docs.spring.io/spring-security/site/docs/3.0.x/reference/technical-overview.html&quot;&gt;Reference&lt;/a&gt;:      &quot;By default the SecurityContextHolder uses a ThreadLocal to store      these details, which means that the security context is always available to      methods in the same thread of execution ...&quot;&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://micharg.blogspot.com/feeds/8892136782183569650/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://micharg.blogspot.com/2014/09/spring-security-async-problem.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7935838433371795797/posts/default/8892136782183569650'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7935838433371795797/posts/default/8892136782183569650'/><link rel='alternate' type='text/html' href='http://micharg.blogspot.com/2014/09/spring-security-async-problem.html' title='Spring Security + @Async problem: (SecurityContextHolder is empty)'/><author><name>micharg</name><uri>http://www.blogger.com/profile/12733531629600432067</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-7935838433371795797.post-8743034102012792478</id><published>2014-09-18T04:58:00.000-07:00</published><updated>2014-09-18T05:10:52.361-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Apache cxf"/><category scheme="http://www.blogger.com/atom/ns#" term="Spring"/><title type='text'>Apache CXF+Spring: How to add authentication (dynamic credentials: from db, AD, etc)</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;i&gt;&amp;nbsp;&lt;/i&gt;&lt;b&gt;Server exposing Web Service&lt;/b&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;@WebService&lt;br /&gt;public interface MyWebService {&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;... &lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;}&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;@WebService(endpointInterface = &quot;com.micharg.MyWebService&quot;)&lt;br /&gt;public class MyWebServiceImpl implements MyWebService {&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;...&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;} &lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;br /&gt;      &lt;/i&gt;&lt;i&gt;public interface WebServiceAuthenticationService {&lt;/i&gt;&lt;i&gt;&lt;br /&gt;      &lt;/i&gt;&lt;i&gt;&lt;br /&gt;      &lt;/i&gt;&lt;i&gt;}&lt;/i&gt;&lt;i&gt;&lt;br /&gt;      &lt;/i&gt;&lt;i&gt;&lt;/i&gt;&lt;i&gt;&lt;br /&gt;      &lt;/i&gt;&lt;i&gt;&lt;br /&gt;      &lt;/i&gt;&lt;i&gt;&lt;br /&gt;      &lt;/i&gt;&lt;i&gt;@Service(&quot;webServiceAuthenticationService&quot;)&lt;/i&gt;&lt;i&gt;&lt;br /&gt;      &lt;/i&gt;&lt;i&gt;public class WebServiceAuthenticationServiceImpl implements        Validator, WebServiceAuthenticationService {&lt;/i&gt;&lt;i&gt;&lt;br /&gt;      &lt;/i&gt;&lt;i&gt;&lt;br /&gt;      &lt;/i&gt;&lt;i&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; @Autowired&lt;/i&gt;&lt;i&gt;&lt;br /&gt;      &lt;/i&gt;&lt;i&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; private AuthenticationService authenticationService;&lt;/i&gt;&lt;i&gt;&lt;br /&gt;      &lt;/i&gt;&lt;i&gt;&amp;nbsp;&amp;nbsp; &lt;/i&gt;&lt;i&gt;&lt;br /&gt;      &lt;/i&gt;&lt;i&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/i&gt;&lt;i&gt;&lt;br /&gt;      &lt;/i&gt;&lt;i&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; @Override&lt;/i&gt;&lt;i&gt;&lt;br /&gt;      &lt;/i&gt;&lt;i&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public Credential validate(Credential credential,        RequestData data) throws WSSecurityException {&lt;/i&gt;&lt;i&gt;&lt;br /&gt;      &lt;/i&gt;&lt;i&gt;&lt;br /&gt;      &lt;/i&gt;&lt;i&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;String candidateUsername =        credential.getUsernametoken().getName();&lt;/i&gt;&lt;i&gt;&lt;br /&gt;      &lt;/i&gt;&lt;i&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;String candidatePassword =        credential.getUsernametoken().getPassword();&lt;/i&gt;&lt;i&gt;&lt;br /&gt;      &lt;/i&gt;&lt;i&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/i&gt;&lt;i&gt;&lt;br /&gt;      &lt;/i&gt;&lt;i&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; boolean isUserAuthenticated =        authenticationService.authenticate(candidateUsername,        candidatePassword)&lt;/i&gt;&lt;i&gt;;&lt;/i&gt;&lt;i&gt;&lt;br /&gt;      &lt;/i&gt;&lt;i&gt;&amp;nbsp;&amp;nbsp; &lt;/i&gt;&lt;i&gt;&lt;br /&gt;      &lt;/i&gt;&lt;i&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(!isUserAuthenticated ) {&lt;/i&gt;&lt;i&gt;&lt;br /&gt;      &lt;/i&gt;&lt;i&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;throw new WSSecurityException(&quot;Wrong credentials        (&quot; + candidateUsername + &quot;, &quot; + candidatePassword + &quot;); can not        execute web service&quot;);&lt;/i&gt;&lt;i&gt;&lt;br /&gt;      &lt;/i&gt;&lt;i&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;/i&gt;&lt;i&gt;&lt;br /&gt;      &lt;/i&gt;&lt;i&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/i&gt;&lt;i&gt;&lt;br /&gt;      &lt;/i&gt;&lt;i&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; return credential;&lt;/i&gt;&lt;i&gt;&lt;br /&gt;      &lt;/i&gt;&lt;i&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/i&gt;&lt;i&gt;&lt;br /&gt;      &lt;/i&gt;&lt;i&gt;&lt;br /&gt;      &lt;/i&gt;&lt;i&gt;}&lt;/i&gt;&lt;i&gt;&lt;br /&gt;      &lt;/i&gt;&lt;i&gt;&lt;br /&gt;      &lt;/i&gt;&lt;i&gt;&amp;lt;bean id=&quot;inbound-security&quot;        class=&quot;org.apache.cxf.ws.security.wss4j.WSS4JInInterceptor&quot;&amp;gt;&lt;/i&gt;&lt;i&gt;&lt;br /&gt;      &lt;/i&gt;&lt;i&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;constructor-arg&amp;gt;&lt;/i&gt;&lt;i&gt;&lt;br /&gt;      &lt;/i&gt;&lt;i&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;map&amp;gt;&lt;/i&gt;&lt;i&gt;&lt;br /&gt;      &lt;/i&gt;&lt;i&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; &amp;lt;entry key=&quot;action&quot; value=&quot;UsernameToken&quot;        /&amp;gt;&lt;/i&gt;&lt;i&gt;&lt;br /&gt;      &lt;/i&gt;&lt;i&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; &amp;lt;entry key=&quot;passwordType&quot;        value=&quot;PasswordText&quot; /&amp;gt;&lt;/i&gt;&lt;i&gt;&lt;br /&gt;      &lt;/i&gt;&lt;i&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/map&amp;gt;&lt;/i&gt;&lt;i&gt;&lt;br /&gt;      &lt;/i&gt;&lt;i&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/constructor-arg&amp;gt;&lt;/i&gt;&lt;i&gt;&lt;br /&gt;      &lt;/i&gt;&lt;i&gt;&amp;nbsp;&amp;lt;/bean&amp;gt;&lt;/i&gt;&lt;i&gt;&lt;br /&gt;      &lt;/i&gt;&lt;i&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;        &amp;lt;!-- Add authentication to the web service that listens to endpoint &lt;a class=&quot;moz-txt-link-freetext&quot; href=&quot;http://mydomain/myendpoint&quot;&gt;http://mydomain/myendpoint;&lt;/a&gt;        --&amp;gt;&lt;br /&gt;      &lt;/i&gt;&lt;i&gt;&amp;lt;jaxws:endpoint id=&quot;myWebService&quot;        implementor=&quot;#myWebServiceImpl&quot; address=&quot;/myendpoint&quot;&amp;gt;&lt;/i&gt;&lt;i&gt;&lt;br /&gt;      &lt;/i&gt;&lt;i&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/i&gt;&lt;i&gt;&lt;br /&gt;      &lt;/i&gt;&lt;i&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;jaxws:properties&amp;gt;&lt;/i&gt;&lt;i&gt;&lt;br /&gt;      &lt;/i&gt;&lt;i&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;entry key=&quot;ws-security.ut.validator&quot;        value-ref=&quot;webServiceAuthenticationService&quot; /&amp;gt;&lt;/i&gt;&lt;i&gt;&lt;br /&gt;      &lt;/i&gt;&lt;i&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/jaxws:properties&amp;gt;&lt;/i&gt;&lt;i&gt;&lt;br /&gt;      &lt;/i&gt;&lt;i&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/i&gt;&lt;i&gt;&lt;br /&gt;      &lt;/i&gt;&lt;i&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;jaxws:inInterceptors&amp;gt;&lt;/i&gt;&lt;i&gt;&lt;br /&gt;      &lt;/i&gt;&lt;i&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;ref bean=&quot;inbound-security&quot; /&amp;gt;&lt;/i&gt;&lt;i&gt;&lt;br /&gt;      &lt;/i&gt;&lt;i&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/jaxws:inInterceptors&amp;gt;&lt;/i&gt;&lt;i&gt;&lt;br /&gt;      &lt;/i&gt;&lt;i&gt;&amp;lt;/jaxws:endpoint&amp;gt;&lt;/i&gt;&lt;i&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;br /&gt;      &lt;/i&gt;    &lt;br /&gt;
&lt;i&gt;&lt;br /&gt;      &lt;/i&gt;    &lt;br /&gt;
&lt;b&gt;Client consuming Web Service&lt;/b&gt;&lt;i&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;br /&gt;      &lt;/i&gt;    &lt;br /&gt;
&lt;i&gt;&amp;lt;!-- consume web service located on http://foo.com/myendpoint&lt;br /&gt;      &lt;/i&gt;    &lt;br /&gt;
&lt;i&gt;&amp;lt;jaxws:client id=&quot;myWebServicesClient&quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; serviceClass=&quot;com.micharg.MyWebService&quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; address=&quot;http://foo.com/myendpoint&quot;&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;jaxws:outInterceptors&amp;gt;&lt;br /&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; &amp;lt;ref bean=&quot;outbound-security&quot; /&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/jaxws:outInterceptors&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/jaxws:client&amp;gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;br /&gt;      &lt;/i&gt;    &lt;br /&gt;
&lt;i&gt;&lt;br /&gt;      &lt;/i&gt;    &lt;br /&gt;
&lt;i&gt;&amp;lt;bean class=&quot;eu.europa.europarl.apapeople.people.web.ws.WebServicesCallbackHandler&quot; id=&quot;webServicesCallbackHandler&quot; /&amp;gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;br /&gt;      &lt;/i&gt;    &lt;br /&gt;
&lt;i&gt;&amp;lt;bean class=&quot;org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor&quot; id=&quot;outbound-security&quot;&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;constructor-arg&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;map&amp;gt;&lt;br /&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;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;entry key=&quot;action&quot; value=&quot;UsernameToken&quot;/&amp;gt;&amp;nbsp; &lt;br /&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;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;entry key=&quot;user&quot; value=&quot;dummy password - passwordCallbackClass overrides it&quot;/&amp;gt;&amp;nbsp; &lt;br /&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;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;entry key=&quot;passwordType&quot; value=&quot;PasswordText&quot;/&amp;gt;&lt;br /&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;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;entry key=&quot;passwordCallbackRef&quot; value-ref=&quot;webServicesCallbackHandler&quot;/&amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/map&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/constructor-arg&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/bean&amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;public class WebServicesCallbackHandler implements CallbackHandler {&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; private String username = &quot;...&quot;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; private String password = &quot;...&quot;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; @Override&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; WSPasswordCallback c = (WSPasswordCallback) callbacks[0];&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; c.setIdentifier(username);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; c.setPassword(password);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;      &lt;/i&gt;    &lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://micharg.blogspot.com/feeds/8743034102012792478/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://micharg.blogspot.com/2014/09/apache-cxfspring-how-to-add.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7935838433371795797/posts/default/8743034102012792478'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7935838433371795797/posts/default/8743034102012792478'/><link rel='alternate' type='text/html' href='http://micharg.blogspot.com/2014/09/apache-cxfspring-how-to-add.html' title='Apache CXF+Spring: How to add authentication (dynamic credentials: from db, AD, etc)'/><author><name>micharg</name><uri>http://www.blogger.com/profile/12733531629600432067</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-7935838433371795797.post-1063104955014508363</id><published>2014-09-18T04:48:00.000-07:00</published><updated>2014-09-18T05:04:50.126-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Apache cxf"/><category scheme="http://www.blogger.com/atom/ns#" term="Spring"/><title type='text'>Spring+Apache CXF: How to disable XML payload limits</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;b&gt;Error:&lt;/b&gt; &quot;org.apache.cxf.staxutils.DepthExceededStaxException:      reach the innerElementCountThreshold:50000&quot;&lt;br /&gt;
&lt;b&gt;Solution&lt;/b&gt;: Disable XML payload limits&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &lt;i&gt;&amp;lt;&lt;/i&gt;&lt;i&gt;!-- disable XML payload limits&lt;/i&gt;&lt;i&gt; --&amp;gt;&lt;/i&gt;&lt;i&gt;&lt;br /&gt;      &lt;/i&gt;&lt;i&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;bean  class=&quot;org.springframework.beans.factory.config.MethodInvokingFactoryBean&quot;&amp;gt;&lt;/i&gt;&lt;i&gt;&lt;br /&gt;      &lt;/i&gt;&lt;i&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;property name=&quot;targetClass&quot;        value=&quot;java.lang.System&quot; /&amp;gt;&lt;/i&gt;&lt;i&gt;&lt;br /&gt;      &lt;/i&gt;&lt;i&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;property name=&quot;targetMethod&quot; value=&quot;setProperty&quot;        /&amp;gt;&lt;/i&gt;&lt;i&gt;&lt;br /&gt;      &lt;/i&gt;&lt;i&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;property name=&quot;arguments&quot;&amp;gt;&lt;/i&gt;&lt;i&gt;&lt;br /&gt;      &lt;/i&gt;&lt;i&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;list&amp;gt;&lt;/i&gt;&lt;i&gt;&lt;br /&gt;      &lt;/i&gt;&lt;i&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;        &amp;lt;value&amp;gt;org.apache.cxf.stax.maxChildElements&amp;lt;/value&amp;gt;&lt;/i&gt;&lt;i&gt;&lt;br /&gt;      &lt;/i&gt;&lt;i&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; &amp;lt;value&amp;gt;1000000&amp;lt;/value&amp;gt;&lt;/i&gt;&lt;i&gt;&lt;br /&gt;      &lt;/i&gt;&lt;i&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/list&amp;gt;&lt;/i&gt;&lt;i&gt;&lt;br /&gt;      &lt;/i&gt;&lt;i&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/property&amp;gt;&lt;/i&gt;&lt;i&gt;&lt;br /&gt;      &lt;/i&gt;&lt;i&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/bean&amp;gt;&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
PS:      org.apache.cxf.interceptor.security.DepthRestrictingStreamInterceptor      seem not to work&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://micharg.blogspot.com/feeds/1063104955014508363/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://micharg.blogspot.com/2014/09/springapache-cxf-how-to-disable-xml.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7935838433371795797/posts/default/1063104955014508363'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7935838433371795797/posts/default/1063104955014508363'/><link rel='alternate' type='text/html' href='http://micharg.blogspot.com/2014/09/springapache-cxf-how-to-disable-xml.html' title='Spring+Apache CXF: How to disable XML payload limits'/><author><name>micharg</name><uri>http://www.blogger.com/profile/12733531629600432067</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><entry><id>tag:blogger.com,1999:blog-7935838433371795797.post-2388601267401557330</id><published>2014-09-12T10:00:00.002-07:00</published><updated>2014-09-12T10:00:42.073-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="mav"/><title type='text'>Maven: How to execute main-class</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
mvn compile exec:java -Dexec.mainClass=micharg.Main&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://micharg.blogspot.com/feeds/2388601267401557330/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://micharg.blogspot.com/2014/09/maven-how-to-execute-main-class.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7935838433371795797/posts/default/2388601267401557330'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7935838433371795797/posts/default/2388601267401557330'/><link rel='alternate' type='text/html' href='http://micharg.blogspot.com/2014/09/maven-how-to-execute-main-class.html' title='Maven: How to execute main-class'/><author><name>micharg</name><uri>http://www.blogger.com/profile/12733531629600432067</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-7935838433371795797.post-8474543199260892177</id><published>2014-08-25T02:34:00.000-07:00</published><updated>2014-08-25T03:13:31.466-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="BOM"/><category scheme="http://www.blogger.com/atom/ns#" term="encoding"/><category scheme="http://www.blogger.com/atom/ns#" term="Java"/><category scheme="http://www.blogger.com/atom/ns#" term="Troubleshooting"/><title type='text'>Excel doesn&#39;t render correctly UTF-8 characters when it opens CSVs</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
&lt;b&gt;Scenario #1&lt;/b&gt;: I create a CSV in UTF-8 encoding with Java, save the character &#39;è&#39; &lt;br /&gt;
but Excel doesn&#39;t render it well.&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/AVvXsEiQDkKmNXB21WAKCJxgkl6ncK3dxruK7F-nheoLFZK2wi9B7Une2EBVFNUmPj-sCMRuPeFWZFRQun-uQFrKTDZk7ui0qs9hcdrnMDAb7z7s1L25Xa3HdI32j_ucqxgQZTBU30V8F8tVu2FU/s1600/csv+open+with+xls+-+problem.PNG&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiQDkKmNXB21WAKCJxgkl6ncK3dxruK7F-nheoLFZK2wi9B7Une2EBVFNUmPj-sCMRuPeFWZFRQun-uQFrKTDZk7ui0qs9hcdrnMDAb7z7s1L25Xa3HdI32j_ucqxgQZTBU30V8F8tVu2FU/s1600/csv+open+with+xls+-+problem.PNG&quot; height=&quot;172&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&amp;nbsp; &lt;/b&gt;&lt;br /&gt;
&lt;b&gt;Scenario #2&lt;/b&gt;: I create a CSV in UTF-8 encoding with Notepad, save the character &#39;è&#39; &lt;br /&gt;
and Excel renders it well.&lt;br /&gt;
&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/AVvXsEhNtcaR40XOYTXPaJpQRdFX5vYtLmSucvPhT43UN7hrSiPMR2je5Q4clcAzaFucjP_C6F6cARvv2IlF3tt40O8HE4aftEknP_g97UWGd2iyR6Os5vfLqd18_KyaGRu_Fhn9w_9_rLThQIec/s1600/notepad+save+-+open+with+excel+-+correct.PNG&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhNtcaR40XOYTXPaJpQRdFX5vYtLmSucvPhT43UN7hrSiPMR2je5Q4clcAzaFucjP_C6F6cARvv2IlF3tt40O8HE4aftEknP_g97UWGd2iyR6Os5vfLqd18_KyaGRu_Fhn9w_9_rLThQIec/s1600/notepad+save+-+open+with+excel+-+correct.PNG&quot; height=&quot;416&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;u&gt;Explanation (from &lt;a href=&quot;http://en.wikipedia.org/wiki/FEFF&quot;&gt;Wikipedia&lt;/a&gt;)&lt;/u&gt;&lt;br /&gt;
&lt;blockquote&gt;
&quot;BOM use is optional, and, if used, should appear at the start of the text stream. &lt;br /&gt;
... the BOM character may also indicate which of the several Unicode representations &lt;br /&gt;
the text is encoded in.&quot;&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&quot;In UTF-16, a BOM (&lt;b&gt;U+FEFF&lt;/b&gt;) may be placed as the first character of a file ... &quot;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (Java is UTF-16) &lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&amp;nbsp;&quot;The UTF-8 representation of the BOM is the byte sequence &lt;b&gt;0xEF,0xBB,0xBF&lt;/b&gt;.&quot; (Windows is UTF-8)&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&amp;nbsp;&quot;many pieces of software on Microsoft Windows such as Notepad will not correctly &lt;br /&gt;
&amp;nbsp;read UTF-8 text unless it has only ASCII characters or it starts with the BOM, &lt;br /&gt;
&amp;nbsp;and will add a BOM to the start when saving text as UTF-8&quot;&lt;/blockquote&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;u&gt;&amp;nbsp;Therefore: &lt;/u&gt;&lt;br /&gt;
&amp;nbsp;=&amp;gt; Scenario #1: notepad saves a CSV UTF-8 with the BOM U+EFBBBF therefore Excel opens it correctly&lt;br /&gt;
&amp;nbsp;=&amp;gt; Scenario #2: but when the CSV UTF-8 is created with Java the Excel doesn&#39;t open it correctly &lt;br /&gt;
&lt;br /&gt;
&lt;u&gt;Demo on how to solve the problem on Scenario #1:&lt;/u&gt;&lt;br /&gt;
&amp;nbsp; Adding the prefix BOM U+EFBBBF on the CSV created programmatically&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/AVvXsEiHYaal09w0ppYkSpm81ObdG5urHPRGT-blCyZlM-y_BTVF30_dVsBP91xgKO2L7dXDwMffbamqDwF1_FZsQCx1AlHTK8z5iSLUb5A-CY-4RUprGMeLMZV_2r8H-aQw0KXmDoTRTSIjobS1/s1600/hex+editor+-+BOM+EFBBBF.PNG&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiHYaal09w0ppYkSpm81ObdG5urHPRGT-blCyZlM-y_BTVF30_dVsBP91xgKO2L7dXDwMffbamqDwF1_FZsQCx1AlHTK8z5iSLUb5A-CY-4RUprGMeLMZV_2r8H-aQw0KXmDoTRTSIjobS1/s1600/hex+editor+-+BOM+EFBBBF.PNG&quot; height=&quot;364&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
and now opening the CSV with excel&amp;nbsp; and it is correct!&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/AVvXsEgw9HcuVoK4oR2dpU-bi_ZRgBbfw3w4StpfFGuu2es8KXkSkWAxrw9VPitF_OI4zWuLT4V0qAnbY7ZUs9ppeBmcPbWIvSRlQ3uFtGhV_v0-GJYSc0pW9MW4sPZ1u-zrOMHOd1rFosRAf7CI/s1600/csv+open+with+xls+-+correct.PNG&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgw9HcuVoK4oR2dpU-bi_ZRgBbfw3w4StpfFGuu2es8KXkSkWAxrw9VPitF_OI4zWuLT4V0qAnbY7ZUs9ppeBmcPbWIvSRlQ3uFtGhV_v0-GJYSc0pW9MW4sPZ1u-zrOMHOd1rFosRAf7CI/s1600/csv+open+with+xls+-+correct.PNG&quot; height=&quot;190&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;u&gt;Code solution for scenario #1 (creating CSV programmatically)&lt;/u&gt;: add to generated CSV the &lt;br /&gt;
BOM suffix U+EFBBBF (for UTF-8 Operating Systems like Windows)&lt;br /&gt;
&lt;br /&gt;
&lt;u&gt;How to do it in Java&lt;/u&gt;&lt;br /&gt;
Java is UTF-16; therefore you have to write the UTF-16 BOM &lt;b&gt;U+FEFF&lt;/b&gt;&lt;i&gt;:&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;// BOM prefix U+FEFF for exported CSVs so that if the csv is openned with&lt;br /&gt;// excel in UTF-8 OS (e.g. Windows) encoding is ok (e.g. char è)&lt;br /&gt;char CSV_BOM = &#39;\uFEFF&#39;;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;writer.write(CSV_BOM); // writer is e.g. a BufferedWriter&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Note: if you open the exported file with a hex editor like I did on the last image you will see the BOM &lt;b&gt;U+EFBBBF&lt;/b&gt;.&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://micharg.blogspot.com/feeds/8474543199260892177/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://micharg.blogspot.com/2014/08/excel-doesnt-render-correctly-utf-8.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7935838433371795797/posts/default/8474543199260892177'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7935838433371795797/posts/default/8474543199260892177'/><link rel='alternate' type='text/html' href='http://micharg.blogspot.com/2014/08/excel-doesnt-render-correctly-utf-8.html' title='Excel doesn&#39;t render correctly UTF-8 characters when it opens CSVs'/><author><name>micharg</name><uri>http://www.blogger.com/profile/12733531629600432067</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/AVvXsEiQDkKmNXB21WAKCJxgkl6ncK3dxruK7F-nheoLFZK2wi9B7Une2EBVFNUmPj-sCMRuPeFWZFRQun-uQFrKTDZk7ui0qs9hcdrnMDAb7z7s1L25Xa3HdI32j_ucqxgQZTBU30V8F8tVu2FU/s72-c/csv+open+with+xls+-+problem.PNG" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7935838433371795797.post-5458156878620587440</id><published>2014-08-01T02:32:00.003-07:00</published><updated>2014-08-01T02:32:59.712-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="android"/><title type='text'>Android: How to fake GPS</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;b&gt;How to fake GPS on Android; e.g. when you use the emulator&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
String mockLocationProvider = LocationManager.GPS_PROVIDER;&lt;br /&gt;
Location mockLocation = new Location(mocLocationProvider);&lt;br /&gt;
mockLocation.setLatitude(1d);&lt;br /&gt;
mockLocation.setLongitude(1d);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://micharg.blogspot.com/feeds/5458156878620587440/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://micharg.blogspot.com/2014/08/android-how-to-fake-gps.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7935838433371795797/posts/default/5458156878620587440'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7935838433371795797/posts/default/5458156878620587440'/><link rel='alternate' type='text/html' href='http://micharg.blogspot.com/2014/08/android-how-to-fake-gps.html' title='Android: How to fake GPS'/><author><name>micharg</name><uri>http://www.blogger.com/profile/12733531629600432067</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-7935838433371795797.post-8576927682359581921</id><published>2014-07-30T13:32:00.002-07:00</published><updated>2014-07-31T02:34:54.528-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="MySQL"/><title type='text'>MySQL: How to insert blob in table</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
In order to insert a blob (image, txt, etc) in table FOO in MySQL you should execute the LOAD_FILE [1] statement:&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: red;&quot;&gt;&lt;i&gt;mysql&amp;gt; insert into FOO(data) values(LOAD_FILE(&#39;/path/to/file.txt&#39;));&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
But in my case NULLs were inserted in column data. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Troubleshooting &lt;/b&gt;[2]:&lt;br /&gt;
&lt;i&gt;mysql&amp;gt; select load_file(&#39;/path/to/file.txt&#39;); -- returns NULL&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
Solution: file.txt should be owned by mysql user/group (although its permissions are -rw-rw-r--; i.e. granted read access to others)&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: red;&quot;&gt;&lt;i&gt;$ sudo chown mysql:mysql &lt;/i&gt;&lt;i&gt;/path/to/file.txt&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;References&lt;/b&gt;&lt;i&gt; &lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_load-file&quot;&gt;[1] From the manual&lt;/a&gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; LOAD_FILE(file_name)&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; Reads the file and returns the file contents as a string. To use this function, the file must be located on the server host, you must specify the full path name to the file, and you must have the FILE privilege. The file must be readable by all and its size less than max_allowed_packet bytes. If the secure_file_priv system variable is set to a nonempty directory name, the file to be loaded must be located in that directory.&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; If the file does not exist or cannot be read because one of the preceding conditions is not satisfied, the function returns NULL.&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; As of MySQL 5.0.19, the character_set_filesystem system variable controls interpretation of file names that are given as literal strings.&lt;br /&gt;
&lt;br /&gt;
[2] Thanks &lt;a href=&quot;http://stackoverflow.com/questions/8229951/load-file-doesnt-work&quot;&gt;StackOverflow&lt;/a&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://micharg.blogspot.com/feeds/8576927682359581921/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://micharg.blogspot.com/2014/07/mysql-how-to-insert-blob-in-table.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7935838433371795797/posts/default/8576927682359581921'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7935838433371795797/posts/default/8576927682359581921'/><link rel='alternate' type='text/html' href='http://micharg.blogspot.com/2014/07/mysql-how-to-insert-blob-in-table.html' title='MySQL: How to insert blob in table'/><author><name>micharg</name><uri>http://www.blogger.com/profile/12733531629600432067</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-7935838433371795797.post-1605433085419889503</id><published>2014-07-29T13:34:00.000-07:00</published><updated>2014-07-29T13:34:12.952-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="MySQL"/><category scheme="http://www.blogger.com/atom/ns#" term="Troubleshooting"/><title type='text'>MySQL error: Cannot delete or update a parent row: a foreign key constraint fails&quot;</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
When trying to delete table foo(&lt;i&gt;DROP TABLE &lt;b&gt;foo1&lt;/b&gt;;&lt;/i&gt;) I got the following error:&lt;br /&gt;&lt;br /&gt;Cannot delete or update a parent row: a foreign key constraint fails&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;As root execute the following to see what in what state is the db:&lt;br /&gt;
&lt;br /&gt;&lt;i&gt;SHOW ENGINE INNODB STATUS;&lt;/i&gt;&lt;br /&gt;------------------------&lt;br /&gt;LATEST FOREIGN KEY ERROR&lt;br /&gt;------------------------&lt;br /&gt;140729 23:16:08&amp;nbsp; Cannot drop table `mydb`.`&lt;b&gt;foo1&lt;/b&gt;`&lt;br /&gt;because it is referenced by `mydb`.`&lt;b&gt;foo2&lt;/b&gt;`&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This tells us that table foo2 has fk to foo1. So remove the fk in foo2 (set it to null) or drop foo2 (this was the case for me since foo2 was empty -- db was in an inconsistent state).&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://micharg.blogspot.com/feeds/1605433085419889503/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://micharg.blogspot.com/2014/07/mysql-error-cannot-delete-or-update.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7935838433371795797/posts/default/1605433085419889503'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7935838433371795797/posts/default/1605433085419889503'/><link rel='alternate' type='text/html' href='http://micharg.blogspot.com/2014/07/mysql-error-cannot-delete-or-update.html' title='MySQL error: Cannot delete or update a parent row: a foreign key constraint fails&quot;'/><author><name>micharg</name><uri>http://www.blogger.com/profile/12733531629600432067</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-7935838433371795797.post-265442014373328986</id><published>2014-07-29T12:50:00.001-07:00</published><updated>2014-07-29T12:50:52.227-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Squirrel"/><title type='text'>Squirrel: doesn&#39;t support DELIMITER</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Note to myself: don&#39;t use DELIMITER in Squirrel; just remove it&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://micharg.blogspot.com/feeds/265442014373328986/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://micharg.blogspot.com/2014/07/squirrel-doesnt-support-delimiter.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7935838433371795797/posts/default/265442014373328986'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7935838433371795797/posts/default/265442014373328986'/><link rel='alternate' type='text/html' href='http://micharg.blogspot.com/2014/07/squirrel-doesnt-support-delimiter.html' title='Squirrel: doesn&#39;t support DELIMITER'/><author><name>micharg</name><uri>http://www.blogger.com/profile/12733531629600432067</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-7935838433371795797.post-8404408850731910390</id><published>2014-07-29T11:42:00.005-07:00</published><updated>2014-07-29T11:42:52.886-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Maven"/><title type='text'>Install jar with maven in local repository</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
$ ls&lt;br /&gt;
foo.jar &lt;br /&gt;
$ mvn install:install-file -Dfile=foo.jar -DgroupId=foo-group -DartifactId=foo-artifact -Dversion=1 -Dpackaging=jar &lt;br /&gt;
&lt;br /&gt;
pom.xml:&lt;br /&gt;
&amp;lt;dependency&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;lt;groupId&amp;gt;foo-group&amp;lt;/groupId&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;lt;artifactId&amp;gt;foo-artifact&amp;lt;/artifactId&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;lt;version&amp;gt;1&amp;lt;/version&amp;gt;&lt;br /&gt;
&amp;lt;/dependency&amp;gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://micharg.blogspot.com/feeds/8404408850731910390/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://micharg.blogspot.com/2014/07/install-jar-with-maven-in-local.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7935838433371795797/posts/default/8404408850731910390'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7935838433371795797/posts/default/8404408850731910390'/><link rel='alternate' type='text/html' href='http://micharg.blogspot.com/2014/07/install-jar-with-maven-in-local.html' title='Install jar with maven in local repository'/><author><name>micharg</name><uri>http://www.blogger.com/profile/12733531629600432067</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-7935838433371795797.post-6646971798020650364</id><published>2014-07-29T01:26:00.001-07:00</published><updated>2014-07-29T01:40:53.466-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Aspose"/><category scheme="http://www.blogger.com/atom/ns#" term="Troubleshooting"/><title type='text'>Aspose.Words problem with fonts (encoding)</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;b&gt;Summary&lt;/b&gt; &lt;br /&gt;
When using Aspose.Words in order to produce a pdf I had problem with some characters not renderer properly (e.g. &lt;b&gt;ȗ&lt;/b&gt;) --&amp;nbsp; see the attached image where the created PDF does not render properly the character &lt;b&gt;ȗ &lt;/b&gt;and it&lt;b&gt; &lt;/b&gt;has embedded the Gentium fonts. The problem was that fonts were missing from my Operating System and the default fronts that Aspose.Words uses in this case don&#39;t support all the characters.&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/AVvXsEjdMq3bwvKOaXZJZNIv2-lU1IkGtFjqNJXcW3Cs5tAgOE1Wxl3Av_PAFyHpLEW7B3mQ7-SHkp2G3pYpcWwKHXJeeq01l1a07t4C_IfBjHMcWgdafhQrpLAx5Wzq-U4aU7u2IPSCl2sU4KzT/s1600/pdf_fonts.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/AVvXsEjdMq3bwvKOaXZJZNIv2-lU1IkGtFjqNJXcW3Cs5tAgOE1Wxl3Av_PAFyHpLEW7B3mQ7-SHkp2G3pYpcWwKHXJeeq01l1a07t4C_IfBjHMcWgdafhQrpLAx5Wzq-U4aU7u2IPSCl2sU4KzT/s1600/pdf_fonts.png&quot; height=&quot;175&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;More Info&lt;/b&gt;&lt;br /&gt;
Aspose.Words when creates PDF uses &lt;a href=&quot;http://www.aspose.com/docs/display/wordsnet/How+Aspose.Words+Uses+True+Type+Fonts&quot;&gt;True Type fonts&lt;/a&gt;. If it doesn&#39;t find True Type fonts it uses &lt;a href=&quot;http://www.aspose.com/docs/display/wordsnet/How+to++Specify+True+Type+Fonts+Location&quot;&gt;Gentium font&lt;/a&gt;; actually it embeds the fonts in the PDF (see the attached image). Gentium font &lt;a href=&quot;http://www.google.com/fonts/specimen/Gentium+Basic&quot;&gt;doesn&#39;t support ȗ&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
Therefore make sure that you have intalled on your Operating system True Type fonts. The algorithm that Aspose looks for fonts is the following (from &lt;a href=&quot;http://www.aspose.com/docs/display/wordsnet/How+Aspose.Words+Uses+True+Type+Fonts&quot;&gt;here&lt;/a&gt;):&lt;br /&gt;
&lt;ol&gt;
&lt;li&gt;&lt;i&gt;Aspose.Words tries to find a font on the file system with an exact font name match.&lt;/i&gt;&lt;/li&gt;
&lt;li&gt;&lt;i&gt;Next, Aspose.Words tries to find the required font among the fonts 
embedded in the original document. Some document formats such as DOCX 
can contain embedded fonts&lt;/i&gt;&lt;/li&gt;
&lt;li&gt;&lt;i&gt;If Aspose.Words cannot find a font with the exact name match, it will attempt to to use the default font specified under &lt;a href=&quot;http://www.aspose.com/docs/display/wordsnet/DefaultFontName+Property&quot; title=&quot;DefaultFontName Property&quot;&gt;FontSettings.DefaultFontName&lt;/a&gt;. If the user has not chosen their own default font then &quot;Times New Roman&quot; is the selected default font that is used. See the &lt;a href=&quot;http://www.aspose.com/docs/display/wordsnet/How+to+Specify+the+Default+Font+to+use+when+Rendering&quot; title=&quot;How to Specify the Default Font to use when Rendering&quot;&gt;How to Set the Default Font used when Rendering&lt;/a&gt; topic for further information on setting default font.&lt;/i&gt;&lt;/li&gt;
&lt;li&gt;&lt;i&gt;If Aspose.Words is unable to locate the font defined under &lt;a href=&quot;http://www.aspose.com/docs/display/wordsnet/DefaultFontName+Property&quot; title=&quot;DefaultFontName Property&quot;&gt;FontSettings.DefaultFontName&lt;/a&gt;, it attempts to select the most suitable font from all of the available fonts.&lt;/i&gt;&lt;/li&gt;
&lt;li&gt;&lt;i&gt;Finally, if Aspose.Words cannot find any fonts on the file system, 
it renders the document using the free Gentium font that is embedded 
into the Aspose.Words assembly.&lt;/i&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;br /&gt;
&lt;br /&gt;
Programmatically setting the fonts path has worked for me:&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;br /&gt;import com.aspose.words.FolderFontSource; &lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;final String pathToFonts = &quot;PATH TO TRUE TYPE FONTS&quot;;&lt;/span&gt; &lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;FolderFontSource folderFontSource = new FolderFontSource(pathToFonts, true);&lt;br /&gt;fontSources.add(folderFontSource);&lt;br /&gt;FontSourceBase[] f&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;ontSourceBase &lt;/span&gt;= (FontSourceBase[])fontSources.toArray(new FontSourceBase[fontSources.size()]);&lt;br /&gt;FontSettings.setFontsSources(&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;f&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;ontSourceBase&lt;/span&gt;&lt;/span&gt;);&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: small;&quot;&gt;Default font locations for various Operating Systems&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;u&gt;Unix (Linux, Solaris)&lt;/u&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;/usr/share/fonts&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;/usr/local/share/fonts&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;/usr/X11R6/lib/X11/fonts&amp;nbsp; &lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;u&gt;Windows&lt;/u&gt;&lt;br /&gt;
Start | Run --&amp;gt; Fonts &lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://micharg.blogspot.com/feeds/6646971798020650364/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://micharg.blogspot.com/2014/07/aspose-problem-with-fonts-encoding.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7935838433371795797/posts/default/6646971798020650364'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7935838433371795797/posts/default/6646971798020650364'/><link rel='alternate' type='text/html' href='http://micharg.blogspot.com/2014/07/aspose-problem-with-fonts-encoding.html' title='Aspose.Words problem with fonts (encoding)'/><author><name>micharg</name><uri>http://www.blogger.com/profile/12733531629600432067</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/AVvXsEjdMq3bwvKOaXZJZNIv2-lU1IkGtFjqNJXcW3Cs5tAgOE1Wxl3Av_PAFyHpLEW7B3mQ7-SHkp2G3pYpcWwKHXJeeq01l1a07t4C_IfBjHMcWgdafhQrpLAx5Wzq-U4aU7u2IPSCl2sU4KzT/s72-c/pdf_fonts.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7935838433371795797.post-3553004109246340153</id><published>2014-07-10T07:45:00.000-07:00</published><updated>2014-07-10T07:47:46.993-07:00</updated><title type='text'>Java: How to remove accents</title><content type='html'>&lt;u&gt;How to remove accents&lt;/u&gt;&lt;u&gt; in strings&lt;/u&gt; [1]&lt;br&gt;      &lt;br&gt;      attempt 1 (remove accents) -- with problems:&lt;br&gt;        Normalizer.normalize(str,      Form.NFD).replaceAll(&quot;\\p{InCombiningDiacriticalMarks}+&quot;, &quot;&quot;)&lt;br&gt;        ç gives c&lt;br&gt;        &#39; gives &#39;&lt;br&gt;        ê gives e&lt;br&gt;        Ö gives O&lt;br&gt;        ü gives u.&lt;br&gt;       &lt;b&gt; ´ gives ´&lt;/b&gt;&lt;br&gt;        &lt;b&gt;but Ø gives Ø&lt;/b&gt;&lt;b&gt; &lt;br&gt;        &lt;br&gt;      &lt;/b&gt;Accents are removed! But letters (non-ascii) are not removed. &lt;br&gt;      &lt;b&gt;&lt;br&gt;      &lt;/b&gt;attempt 2 (Remove non-ascii chars) -- successfully!&lt;br&gt;        Normalizer.normalize(str, Form.NFD).replaceAll(&quot;[^\\p{ASCII}]&quot;,      &quot;&quot;)&lt;br&gt;        ç gives c&lt;br&gt;        &#39; gives &#39;&lt;br&gt;        ê gives e&lt;br&gt;        Ö gives O&lt;br&gt;        ü gives u.&lt;br&gt;       &lt;b&gt; ´ gives nothing&lt;/b&gt;&lt;br&gt;        &lt;b&gt;Ø gives nothing&lt;/b&gt;&lt;b&gt;&lt;br&gt;        &lt;br&gt;      &lt;/b&gt;[1] This may be useful e.g. if you want to give filenames in      non-unicode filesystem.&lt;b&gt;&lt;br&gt;      &lt;/b&gt;    </content><link rel='replies' type='application/atom+xml' href='http://micharg.blogspot.com/feeds/3553004109246340153/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://micharg.blogspot.com/2014/07/java-how-to-remove-accents.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7935838433371795797/posts/default/3553004109246340153'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7935838433371795797/posts/default/3553004109246340153'/><link rel='alternate' type='text/html' href='http://micharg.blogspot.com/2014/07/java-how-to-remove-accents.html' title='Java: How to remove accents'/><author><name>micharg</name><uri>http://www.blogger.com/profile/12733531629600432067</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></feed>