<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Misterdom's World &#187; Uncategorized</title>
	<atom:link href="http://www.guinard.org/~misterdom/category/uncategorized/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.guinard.org/~misterdom</link>
	<description>My Computing Logbook</description>
	<lastBuildDate>Sat, 24 Dec 2011 09:31:38 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>How to Take a Timed Screenshot with Linux</title>
		<link>http://www.guinard.org/~misterdom/2011/06/30/timed-screenshot-with-linux/</link>
		<comments>http://www.guinard.org/~misterdom/2011/06/30/timed-screenshot-with-linux/#comments</comments>
		<pubDate>Thu, 30 Jun 2011 15:41:50 +0000</pubDate>
		<dc:creator>misterdom</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[screenshot]]></category>

		<guid isPermaLink="false">http://www.guinard.org/~misterdom/?p=190</guid>
		<description><![CDATA[sleep 3s; import -window root screenshot.png
Source: http://www.linux-noob.com/forums/index.php?/topic/339-how-to-take-a-screenshot-in-linux/
]]></description>
			<content:encoded><![CDATA[<blockquote><p><code>sleep 3s; import -window root screenshot.png</code></p></blockquote>
<p>Source: <a href="http://www.linux-noob.com/forums/index.php?/topic/339-how-to-take-a-screenshot-in-linux/">http://www.linux-noob.com/forums/index.php?/topic/339-how-to-take-a-screenshot-in-linux/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.guinard.org/~misterdom/2011/06/30/timed-screenshot-with-linux/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Embedding Databases in a WAR File</title>
		<link>http://www.guinard.org/~misterdom/2010/10/22/embedding-db-war-file/</link>
		<comments>http://www.guinard.org/~misterdom/2010/10/22/embedding-db-war-file/#comments</comments>
		<pubDate>Thu, 21 Oct 2010 22:38:58 +0000</pubDate>
		<dc:creator>misterdom</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[derby]]></category>
		<category><![CDATA[glassfish]]></category>
		<category><![CDATA[sqlite]]></category>
		<category><![CDATA[tomcat]]></category>

		<guid isPermaLink="false">http://www.guinard.org/~misterdom/?p=180</guid>
		<description><![CDATA[Lately I needed a Java Web Application to have its own small database. I know the common/good practice is to have Web apps connect to a DB through a database pool but this requires some user configuration (at least copying the DB driver to the lib folder of the app server) when deploying the app. [...]]]></description>
			<content:encoded><![CDATA[<p>Lately I needed a Java Web Application to have its own small database. I know the common/good practice is to have Web apps connect to a DB through a database pool but this requires some user configuration (at least copying the DB driver to the lib folder of the app server) when deploying the app. Since the Web app was supposed to be deploy-and-play this was not an option.</p>
<p>Thus, we decided to embed a SQLite database in the app. This worked fine as long as I was locally testing the application. However, when deploying to a production Tomcat instance I started getting these exceptions:</p>
<blockquote><p>
<code>java.sql.SQLException: opening db: 'restfulepcis.db': Permission denied<br />
	at org.sqlite.Conn. init(Conn.java:117)<br />
	at org.sqlite.Conn. init(Conn.java:49)<br />
	at org.sqlite.JDBC.connect(JDBC.java:86)</code>
</p></blockquote>
<p>The reason is pretty clear, on the production server I did not have permission to write to the Tomcat working directory.</p>
<p>I was left with two solutions:<br />
1) have the directory where the database has to be created as a config parameter<br />
2) find a directory that&#8217;s universally accessible from an app in an app server.<br />
Since 1) involved user-configuration it was not an option.</p>
<p>There is actually a folder to which any Web app can write, the folder where the app is deployed (or at least my knowledge). The location of this folder can be found by calling:</p>
<blockquote><p><code><br />
ServletContext context = servletContext.getRealPath("/")<br />
</code>
</p></blockquote>
<p>from a servlet. Since my app is a JAX-RS (RESTful) application I can obtain it by CDI (Contexts and Dependency Injection):</p>
<blockquote><p><code>    @Context<br />
    ServletContext servletContext;</p>
<p>    /**<br />
     * Returns a representation of the EPCIS REST Adapter home resource according to the requested mime type<br />
     *<br />
     * @param context<br />
     * @return an instance of javax.ws.rs.core.Resource<br />
     */<br />
    @GET<br />
    public Resource getRESTfulEPCIS(@Context UriInfo context) {<br />
        System.setProperty("sqlite.system.home", servletContext.getRealPath("/"));<br />
        RESTfulEPCISBusinessLogic logic = new RESTfulEPCISBusinessLogic();<br />
        return logic.getRESTfulEPCIS(context);<br />
    }<br />
</code></p></blockquote>
<p>I then load the sqlite.system.home from my database manager class (which is not a Servlet) and use it as path in my database connection URI:</p>
<blockquote><p>
<code><br />
...<br />
     String sqliteHome = System.getProperty("sqlite.system.home");<br />
...<br />
    private Connection getConnection() {<br />
        Connection connection = null;<br />
        try {<br />
            Class.forName(DRIVER);<br />
            connection = DriverManager.getConnection("jdbc:sqlite:" + sqliteHome + DB_NAME + ".db");<br />
...<br />
</code>
</p></blockquote>
<p>Note that for Apache Derby, you can make it even easier by simply setting the <code>derby.system.home</code> in the servlet class. Then, you do not need to read it manually from your database manager class as it is read automatically when loading the driver:</p>
<blockquote><p><code> System.setProperty("derby.system.home", servletContext.getRealPath("/"));</code></p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.guinard.org/~misterdom/2010/10/22/embedding-db-war-file/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Getting SOAP XML out of KSOAP2 Requests</title>
		<link>http://www.guinard.org/~misterdom/2010/10/20/soap-xml-out-of-ksoap2/</link>
		<comments>http://www.guinard.org/~misterdom/2010/10/20/soap-xml-out-of-ksoap2/#comments</comments>
		<pubDate>Tue, 19 Oct 2010 22:59:37 +0000</pubDate>
		<dc:creator>misterdom</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[ksoap]]></category>
		<category><![CDATA[SOAP]]></category>
		<category><![CDATA[webservices]]></category>

		<guid isPermaLink="false">http://www.guinard.org/~misterdom/?p=177</guid>
		<description><![CDATA[Use the debug mode of the HttpTransport with:

HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
androidHttpTransport.debug = true;

and get a hold on the raw response from the service using:
String result = androidHttpTransport.responseDump;
]]></description>
			<content:encoded><![CDATA[<p>Use the debug mode of the <code>HttpTransport</code> with:</p>
<blockquote><p><code><br />
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);<br />
androidHttpTransport.debug = true;<br />
</code></p></blockquote>
<p>and get a hold on the raw response from the service using:</p>
<blockquote><p><code>String result = androidHttpTransport.responseDump;</code></p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.guinard.org/~misterdom/2010/10/20/soap-xml-out-of-ksoap2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Switching Java Versions in Ubuntu</title>
		<link>http://www.guinard.org/~misterdom/2010/09/08/switching-java-versions-in-ubuntu/</link>
		<comments>http://www.guinard.org/~misterdom/2010/09/08/switching-java-versions-in-ubuntu/#comments</comments>
		<pubDate>Wed, 08 Sep 2010 14:00:13 +0000</pubDate>
		<dc:creator>misterdom</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.guinard.org/~misterdom/?p=171</guid>
		<description><![CDATA[Use this command to switch between the versions of Java (e.g. Sun, Oracle, Openjdk, etc.)
sudo update-alternatives --config java
]]></description>
			<content:encoded><![CDATA[<p>Use this command to switch between the versions of Java (e.g. Sun, Oracle, Openjdk, etc.)</p>
<blockquote><p><code>sudo update-alternatives --config java</code></p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.guinard.org/~misterdom/2010/09/08/switching-java-versions-in-ubuntu/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Linux: Find What Process Listens to Which Port</title>
		<link>http://www.guinard.org/~misterdom/2010/08/19/linux-find-process-4-port/</link>
		<comments>http://www.guinard.org/~misterdom/2010/08/19/linux-find-process-4-port/#comments</comments>
		<pubDate>Thu, 19 Aug 2010 18:32:05 +0000</pubDate>
		<dc:creator>misterdom</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.guinard.org/~misterdom/?p=162</guid>
		<description><![CDATA[Find what process listens to which port:
fuser -v -n tcp PORT
]]></description>
			<content:encoded><![CDATA[<p>Find what process listens to which port:</p>
<blockquote><p><code>fuser -v -n tcp PORT</code></p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.guinard.org/~misterdom/2010/08/19/linux-find-process-4-port/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Removing Latex Tags in a Word Document</title>
		<link>http://www.guinard.org/~misterdom/2010/06/05/removing-latex-tags-in-a-word-document/</link>
		<comments>http://www.guinard.org/~misterdom/2010/06/05/removing-latex-tags-in-a-word-document/#comments</comments>
		<pubDate>Sat, 05 Jun 2010 14:05:41 +0000</pubDate>
		<dc:creator>misterdom</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.guinard.org/~misterdom/?p=143</guid>
		<description><![CDATA[We can use the regexp feature of the find/replace tool in Word.
Search for:
\\code\{(*)\}
Where:

\ is the escape char (thus the \\ for detecting a Latex tag)
* means &#8220;everything&#8221;
( ) creates a logical entity that you can re-use in the replace field.

and replace by:
\1
which refers to the entity we created by using ().

More info on this doc
]]></description>
			<content:encoded><![CDATA[<p>We can use the regexp feature of the find/replace tool in Word.</p>
<p>Search for:</p>
<blockquote><p><code>\\code\{(*)\}</code></p></blockquote>
<p>Where:</p>
<ul>
<li>\ is the escape char (thus the \\ for detecting a Latex tag)</li>
<li>* means &#8220;everything&#8221;</li>
<li>( ) creates a logical entity that you can re-use in the replace field.
</ul>
<p>and replace by:</p>
<blockquote><p><code>\1</code></p></blockquote>
<p>which refers to the entity we created by using ().</p>
<p><a href="http://word.mvps.org/FAQs/General/UsingWildcards.htm"><br />
More info on this doc</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.guinard.org/~misterdom/2010/06/05/removing-latex-tags-in-a-word-document/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Connecting to the Ploggs using Bluetooth on Linux</title>
		<link>http://www.guinard.org/~misterdom/2009/03/18/connecting-to-the-ploggs-using-bt/</link>
		<comments>http://www.guinard.org/~misterdom/2009/03/18/connecting-to-the-ploggs-using-bt/#comments</comments>
		<pubDate>Wed, 18 Mar 2009 18:32:50 +0000</pubDate>
		<dc:creator>misterdom</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.guinard.org/~misterdom/?p=73</guid>
		<description><![CDATA[1) Get the BlueZ stack and RFComm and minicom for your Linux distro.
2) Do hcitool scan to scan for Bluetooth devices and get the Bluetooth address of the one you want to connect to, e.g.: 00:80:98:E7:CA:16
3) Do rfcomm connect 0 00:80:98:E7:CA:16 1 which basically creates virtual serial port for your Bluetooth device. The first 0 [...]]]></description>
			<content:encoded><![CDATA[<p>1) Get the BlueZ stack and RFComm and minicom for your Linux distro.</p>
<p>2) Do <code>hcitool scan</code> to scan for Bluetooth devices and get the Bluetooth address of the one you want to connect to, e.g.: 00:80:98:E7:CA:16</p>
<p>3) Do <code>rfcomm connect 0 00:80:98:E7:CA:16 1</code> which basically creates virtual serial port for your Bluetooth device. The first 0 means that you want to bind your Bluetooth device (e.g. Plogg) to the <code>/dev/rfcomm0</code> virtual port. The second argument is the BT address of your device, the third is the BT channel to be used.</p>
<p>4) Connect to the Plogg by launching <code>minicom -s</code>, go to the Serial Port Setup menu item and change the entry Serial Device to point to <code>/dev/rfcomm0</code>, i.e. the virtual port for your Plogg.</p>
<p>5) You can now browse the Plogg&#8217;s functionality in command line. Note that this tutorial should work for other BT devices as well.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.guinard.org/~misterdom/2009/03/18/connecting-to-the-ploggs-using-bt/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

