My name is Juri Strumpflohner and this is my technical blog. I'm a software architect, .Net, Android, Web and Java dev, TDD and best practices promoter and martial arts practitioner.

Recent Posts Subscribe

Dear reader of Juri's TechBlog,
I moved my blog to a new domain and a new hosting solution as well. I'm now blogging on juristr.com.

"Unknown protocol: d"

Today morning when starting a general build of the project I'm currently working on, I got an error saying "unknown protocol: d". It was strange since I couldn't remember of any big changes made and the build didn't also fail the last time. But that's how programming is sometimes. Anyway, "d" was indicating that something must have gone wrong when accessing the hard-disk drive "D". The stack-trace gave me the following:


Exception in thread "main" java.net.MalformedURLException: unknown protocol: d
at java.net.URL.(Unknown Source)
at java.net.URL.(Unknown Source)
at java.net.URL.(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.setupCurrentEntity(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLVersionDetector.determineDocVersion(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
at org.jdom.input.SAXBuilder.build(SAXBuilder.java:453)
at org.jdom.input.SAXBuilder.build(SAXBuilder.java:891)
at org.devbook.utils.XMLHandler.buildDOM(XMLHandler.java:50)
at org.devbook.utils.XMLHandler.loadXMLFile(XMLHandler.java:37)
at org.devbook.data.XMLPersistencyAdapter.load(XMLPersistencyAdapter.java:159)
at org.devbook.sandbox.TestClass.main(TestClass.java:22)
It turned out that the SAXBuilder of JDom caused the error:
private void buildDOM() throws JDOMException, IOException{
SAXBuilder builder = new SAXBuilder();
try {
doc = builder.build(xmlPath);
} catch (JDOMException e) {
throw e;
} catch (IOException e) {
throw e;
}
}
It seems as if the String "xmlPath" which is in the form "D:\\Folder1\\...\\file.xml" is not correctly interpreted as a file reference. Normally such path references are converted internally into the correct file / URL references. If this is not the case - as in my example here - one has to do it by either explicitly creating a valid URL, appending "file:///" such that it looks as follows

doc = builder.build(new URL("file:///" + xmlPath));

or to directly create a file reference. I preferred that solution:
private void buildDOM() throws JDOMException, IOException{
SAXBuilder builder = new SAXBuilder();
try {
doc = builder.build(new File(xmlPath));
} catch (JDOMException e) {
throw e;
} catch (IOException e) {
throw e;
}
}
Attention: Just appending the protocol type "file:///" to the String "xmlPath" isn't enough. It wouldn't show any error but it would not load the xml file correctly (at it least that was my situation). To make it work correctly, one has to explicitly create an object of type java.net.URL (as shown above).

Speakers don't mute when plugging in headphones!

As you may have recognized from the last post I start using Linux more often. With the new upgrade to Gutsy, Ubuntu's performance is much better (that's at least my feeling on my notebook) and I really start liking it. Anyway, from now and then there are some problems you encounter (as Windows accustomed user :) ) for which you have to find a solution. I'd like to post those little problems here in order to help others.

Today for instance I switched on my notebook and while doing my stuff it came me in mind to listen to music. Since my girlfriend was studying besides me (she has to write her Bsc thesis), I plugged in my headphones to not disturb her. The speakers however didn't mute, as it used to be under Windows. It was strange since one may think this kind of switching the speakers on/off is done at hardware level. That's however not the case - at least it doesn't seem so.
The solution to the problem is quite straightforward (if you know where to search for it ;) ). The "Headphone Jack sense" has to be activated. Let's take a look, step by step:

Step 1:
Right-click on the volume-icon on the taskbar and open the volume control window.



Step 2:
In the volume control window:
Probably the dialog looks as the one above. However to turn the "Jack sense" option on, we have to first activate the "Switches" tab. If you have it already, just go ahead to step 3, otherwise click on "Edit/Preferences". The following dialog will appear where you have to switch on the highlighted option.
Step 3:
Now you should see the "Switches" tab. Click on it and activate the option "Headphone Jack Sense" as demonstrated below

That's it! Everything should work now.

Where has Beryl gone??

Yesterday I upgraded Ubuntu to the new 7.10 (Gutsy) version. I don't know whether you've read a post I've written some time ago about Ubuntu's desktop and window effects? Well here and here would be some posts if you're interested.
Anyway, the point is that with the new system upgrade Beryl was uninstalled since it was marked as obsolete package. After some searching on the web I found that Beryl developers went over to Compiz. So the first step was to install the compiz manager. That was quite easy, just go to System -> Administration -> Synaptic Package Manager. Then search for "compizconfig-settings-manager".
After a successful installation the following menu entry should appear:
This is basically the compiz configuration window, where all the effects and stuff can be configured and activated. To use all this effects however, one has to open the "Appearance" dialog which is just the menu entry below.
If it works, everything is fine and Compiz effects will be used. In my case however the error message "The Composite extension is not available" appeared.
I found out that this is connected to my ATI proprietary drivers which I was using on Ubuntu. So I had to adjust some settings in order to make Compiz work.

Step 1:
Run

sudo gedit /etc/X11/xorg.conf
In the configuration file search for "extension" and you'll find something like this

Section "Extensions"
Option "Composite" "0"
EndSection
Change the value "0" to "1" and save your settings. Then go back to the appearance preferences and try again to set the visual effects to "custom". If it works fine, otherwise you have to continue with step 2.

Step 2:
Open a terminal (Press Alt+F2 and type "gnome-terminal"). Then type in "compiz --replace".
You should get something like this:

Checking for Xgl: not present.
No whitelisted driver found
aborting and using fallback: /usr/bin/metacity
Then go on by typing (always in your terminal window):
sudo apt-get install xserver-xgl

After installation, restart your X-server by pressing CRTL-ALT-BACKSPACE.
Compiz should work now.

Learning by understanding and reusing code, not by copying!!

Time ago - as you may have already read on this blog here - I started to experiment with the GME API. The result of my experiments was News Mapper (more here). Today, when scrolling over the Google Mashup Gallery, I found "India News". It does basically the same as News Mapper, with the difference that it displays just news from India.
However just by looking at the page without touching it, one can see the similarity with my News Mapper project. With similarity I'm not referring to the conceptual part. Taking a look at the code approved my suspicion... Most of the code is completely identical to my code I've used for News Mapper. Lets look at some examples. The screenshot below shows for instance that the author is using the same mechanism for laying out the different categories of the news feed. To realize this he uses the same CSS stylesheet class "category" with the same a:hover entry and the same color. His site is basically a slightly modified copy of my source code (even the comments of the JavaScript methods are the same :D )!
Moreover I don't think he has really understood my code since he calls for instance on each load my method called "cleanRSSEntries()" although it is completely useless for his situation. I've just needed it to cut out all HTML code that was inside Reuters RSS feeds because it lead to problems in displaying the information on the map. His feed provider however doesn't include HTML tags in the RSS feed at all.
The same author - with the name "Karthik" - also published another mashup http://cnntop.googlemashups.com/ where the copying of my source code is even more visible. You can compare the source codes if you want, however I don't think you have to. The similarities are too evident. Anyway:

Copyright violation
News Mapper is licensed under the Apache 2.0 license.
Point 4 of the license refers to the redistribution saying the following:

4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:

  1. You must give any other recipients of the Work or Derivative Works a copy of this License; and

  2. You must cause any modified files to carry prominent notices stating that You changed the files; and

  3. You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and

  4. If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
All in all, with this post I publicly encourage the author of those applications to apply the terms specified in the Apache 2.0 license and to add the appropriate copyright notices, placing a link to my News Mapper.

The idea behind Open Source is not to copy and distribute under the own name, but to learn from existing code for exchanging knowledge and eventually contributing to it. It is not a nice way as the author (Karthik) has done it. :)

News Mapper experiences a revival

After I first published my Google Mashup project "News Mapper", it immediately got published first on the Google Code site of the GME project and then also on the Official GME blog. This clearly brought me a lot of traffic which kept on going over more weeks. The attention payed to News Mapper then decreased to an average of about 5 people / day.
Now, in the last 3 days, again more users started to visit News Mapper with a maximum of 324 users just yesterday :) . With my StatCounter logs I was able to see that most of the users came from the Google Mashup Directory blog. I don't think this is an official Google Blog. Anyway thanks for placing my project there, whoever is the owner of the blog ;)
Here is the direct link to the News Mapper entry:


You're welcome to place your rate there :D

Red-Green color deficiency: whats that??

Well, it is a special kind of color blindness and I'm actually one of those guys affected by it. Recently I thought about posting something about it for sharing my experience with others but a friend of mine - Manfred - was faster :) He wrote a very nice FAQ with a lot of information regarding this topic.

So, before posting things redundantly, I'm linking to his post:


And I say it once again:
  • It is neither a disease
  • There is a clear difference in being color blind or having a red-green deficiency! I see colors, just a little different than the majority of people (always the majority defines which things are "right" ;) ). I'm not only seing things in black-white.
  • We are able to drive normally, traffic lights do not pose any problem at all
However read Manfred's post on his blog... it answers most of the questions!

Advent calendars

There exist some interesting advent calendars around the web which may be interesting for some of you. For instance the website "entwickler-press.de" offers a nice one, where you get each day a free developer eBook. There are nice ones such as "The Google Web Toolkit", "Visual C#", "Java 6" and so on. Unfortunately (for all my English-speaking blog readers) these eBooks are all written in German.
Chip.de has also an advent calendar offering each day nice full-version tools for free. Today "BoostSpeed" can be downloaded.

If anyone of you knows other calendars, please put a comment with a link here :) .

Clean up your folder

It's actually not really worth to put a post about this...but anyway :) I recently coded just a simple one-class prog which deletes - or more specifically emtpies - a specified folder in certain time intervals.
You probably ask yourself now what that should be good for. I'll try to explain it. It often happens to me that I create a text-file just for the purpose of adding some note or for trying out some web-related code (as software developer) or I often download files just to view them and so on. These files usually finish on my desktop or some other folder and most often they are no more used and I forget to delete them. So I decided to code a little app (which is just 1 java-class big or better small ;) ) which does the deletion for me.
The idea was to specify a certain folder in which I place all my temporary stuff. The app should then check this folder periodically and delete its content every - say - 14 days or so. One could now argue that this could also be done by writing a batch-file which deletes a certain folder and to schedule the execution of this batch-file as a Windows "Scheduled Task". Yes it would, but not for all cases (or at least I didn't found it out yet). Suppose for instance that I'm scheduling the job (deletion) to be done every Sunday at 5.00 PM. If my machine is running at this time, everything works, if not, the job will not be repeated as soon as I'm switching on my notebook on Monday morning. There may exist some free scheduling tools which may do this work actually, however for myself it was easier to write this 50 line java app.
By the way...while writing this...it came me in mind that I could change this small app in a way that it works as such a job scheduler by launching batch files instead of doing the deletion (in this case) programmatically. This would render it more useful. Maybe I'll change this.
In the mean time you can download the app "FolderCleaner" at

or view the source in its SVN repository at

More details about the usage can be found in the following README file which is also included in the ZIP download.