tag:blogger.com,1999:blog-6027694593297476442024-03-14T06:43:50.911+09:00Miscellaneous notes from BMEverything popular is wrong. (Oscar Wilde)Unknownnoreply@blogger.comBlogger118125tag:blogger.com,1999:blog-602769459329747644.post-36027658518844739372012-09-28T18:35:00.003+09:002012-09-28T18:38:19.546+09:00Oracle Fustercluck on Solaris 11You're trying to install Oracle Cluster? And this thing wants you to install their stuff as "root" user. Except the "root" user cannot go to the other Solaris nodes via SSH, because it is very insecure to Oracle.<br />
<div>
In other words, Oracle Cluster is asking you to make your OS insecure first. :-)<br />
<div>
<br /></div>
<div>
Here are steps for you how to fix the issue (saves you a half of a day):</div>
<div>
<br /></div>
<div>
<b>1. Modify<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"> /etc/user_attr</span> file.</b></div>
<div>
Before:</div>
<div>
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">root::::type=role</span></div>
<div>
<br /></div>
<div>
After:</div>
<div>
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">root::::</span></div>
<div>
<br /></div>
<div>
<b>2. Comment out line <span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">CONSOLE=/dev/console</span> in<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"> /etc/default/login</span> file.</b></div>
<div>
Why? Read the description there.</div>
<div>
<br /></div>
<div>
<b>3. Allow remote login for root in SSH daemon by editing <span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">/etc/ssh/sshd_config</span> file.</b></div>
<div>
Before:</div>
<div>
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">PermitRootLogin no</span></div>
<div>
<br /></div>
<div>
After:</div>
<div>
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">PermitRootLogin yes</span></div>
<div>
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"><br /></span></div>
<div>
<span class="Apple-style-span" style="font-family: inherit;"><b>4. Restart SSH daemon by issuing the following command:</b></span></div>
<div>
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"># svcadm restart /network/ssh</span></div>
<div>
<br /></div>
<div>
<b>5. Set password for root:</b></div>
<div>
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"># passwd root</span></div>
<div>
<br /></div>
<div>
<b>6. Generate SSH keys:</b></div>
<div>
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"># ssh-keygen -t rsa</span></div>
<div>
<br /></div>
<div>
Phew! Now you can put your public SSH keys elsewhere and enjoy <strike>Snorcle Fustercluck</strike> Oracle Cluster installation (as an example). :-)</div>
</div>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-602769459329747644.post-57231401986360561412012-08-02T23:05:00.001+09:002012-08-02T23:05:56.032+09:00How to shut Solaris down NOW?<br />
Instead of<br />
$ pfexec shutdown -y -i5 -g0<br />
<br />
...do:<br />
<br />
$ pfexec poweroff<br />
<br />Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-602769459329747644.post-31507171179211416322012-07-23T20:26:00.003+09:002012-07-23T20:31:21.236+09:00Fixing /usr/bin/fscked Oracle Slowlaris 11<br />
You probably know already that for Oracle "Primary Administrator" is "too powerful", so they decided to remove it at all. If you use "System Administrator", you will not have the same privileges. And yeah, entering password all the time you're working on some box is just... lame.<br />
<br />
Here is just put that stuff back as before:<br />
<br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;">echo 'Primary Administrator:suser:cmd:::*:uid=0;gid=0' >> /etc/security/exec_attr</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;">echo 'Primary Administrator:::All administrative tasks:auths=solaris.*;solaris.grant;help=RtPriAdmin.html' >> /etc/security/prof_attr</span><br />
<br />
Also kill that $%^# ancient sendmail so it will stop vomiting on your primary console usual garbage.<br />
<br />
Also enable verbose booting by modifying <span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">/rpool/boot/grub/menu.lst</span> kernel line something like (x86 systems):<br />
<br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;">kernel$ /platform/i86pc/kernel/amd64/unix -B $ZFS-BOOTFS -v -m verbose</span><br />
<br />
Also setup your repositories from two full ISO files:<br />
<br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;">$ cat sol-11-1111-repo-full.iso-a </span><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;">sol-11-1111-repo-full.iso-b > sol-11-1111-repo-full.iso</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;">$ pfexec zfs create rpool/export/fullrepo</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;">$ pfexec lofiadm -a sol-11-1111-repo-full.iso</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;">$ mkdir /tmp/fullrepo</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;">$ pfexec mount -F hsfs /dev/lofi/1 /tmp/fullrepo</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;">$ pfexec rsync -aP --progress /tmp/fullrepo/ /export/fullrepo/</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;">$ pfexec umount /tmp/fullrepo</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;">$ pfexec lofiadm -d /dev/lofi/1</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;">$ pfexec pkg set-publisher -G '*' -M '*' -g file:///export/fullrepo/repo solaris</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;">$ pfexec pkg refresh --full</span><br />
<br />
Also, if you do need X11 and all that Gnome-2 stuff, install slim install:<br />
<br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;">$ </span><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;">pfexec </span><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;">pkg install slim_install</span><br />
<br />
From now on you can start using Oracle Solaris properly (hating everyone there for B&W text Emacs, bad VIM and other minor things). Once you have it enough, go get something better: <a href="http://openindiana.org/" target="_blank">Illumos-based OpenIndiana</a> :-)<br />
<br />
<br />
<br />Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-602769459329747644.post-73854878456797690262012-04-03T17:35:00.003+09:002012-04-03T17:35:33.999+09:00Main problem in UI of all Google productsThe main problem in the user interface of all Google products are <b>the icons</b>. No single icon is properly understood until one points with a mouse on it and waits for the pop-up hint to know what the heck this little thingy means.Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-602769459329747644.post-85562496476540727402012-03-20T19:59:00.003+09:002012-03-20T20:06:04.240+09:00Better checksum in JavaYou were also pissed off by the need of writing shitcode like you can find on RoseIndia examples while striving to get a way to represent digest bytes as a hexadecimal string, right? Here is a better way:<br /><pre>MessageDigest digest = MessageDigest.getInstance("SHA1"); // Or MD5...<br />digest.update("hello world");<br />String hexdigest = new BigInteger(1, digesst.digest()).toString(16);</pre>And that's it.Unknownnoreply@blogger.com1tag:blogger.com,1999:blog-602769459329747644.post-35842093021814213182012-03-07T23:15:00.003+09:002012-03-07T23:25:25.564+09:00Want to reset Linux machine remotely?Sometimes it is a good idea to completely reset the machine without shutting it down gracefully. Especially, doing it remotely via SSH, for example.<div><br /></div><div>Here is how:</div><div><br /></div><div><div><span class="Apple-style-span" >$ sudo -s</span></div><div><span class="Apple-style-span" ># echo 1 > /proc/sys/kernel/panic</span></div><div><span class="Apple-style-span" ># echo c > /proc/sysrq-trigger</span></div></div><div><br /></div><div>The file "panic" by default has value "0". If you want machine actually reboot, this needs to be changed, otherwise machine will simply "hang" until hardware reset or power cycle.</div><div><br /></div><div>The file "sysrq-trigger" has a lot of commands, where "c" is what we need at this time. Here is full list of the commands one could use in a future:</div><div><div><ul><li>'r' - Turns off keyboard raw mode and sets it to XLATE.</li><li>'k' - Secure Access Key. Kills all programs on the current virtual console.</li><li>'b' - Immediately reboot the system without syncing or unmounting disks.</li><li>'c' - Intentionally crash the system without syncing or unmounting disks. This is most useful if the NETDUMP client package has been installed.</li><li>'o' - Shut the system off (if configured and supported).</li><li>'s' - Attempt to sync all mounted filesystems.</li><li>'u' - Attempt to remount all mounted filesystems read-only.</li><li>'p' - Dump the current registers and flags to current console.</li><li>'t' - Dump a list of current tasks and their information to current console.</li><li>'m' - Dump current memory info to current console.</li><li>'0'-'9' - Sets the console log level, controlling which kernel messages will be printed to current console. For example, '0' would make it so that only emergency messages like PANICs or OOPSes would make it to current console.</li><li>'e' - Send a SIGTERM to all processes, except for init.</li><li>'i' - Send a SIGKILL to all processes, except for init.</li><li>'l' - Send a SIGKILL to all processes, INCLUDING init. This turns the system completely hosed.</li></ul><div>Hope it helps.</div></div></div>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-602769459329747644.post-76673237130240581072010-11-06T01:09:00.003+09:002010-11-06T01:14:07.725+09:00Finally we've got Base64 in Java...It was always a pain and we used those strange Sun packages (crossing fingers, of course). But now Java 6 has a little thing, that is a standard package and won't collide, at least:<br /><code><br /> public static byte[] decodeFromBase64(String encoded) {<br /> return javax.xml.bind.DatatypeConverter</code><div><code> .parseBase64Binary(encoded);<br /> }<br /><br />public static String encodeToBase64(byte[] binary) {<br /> return javax.xml.bind.DatatypeConverter</code></div><div><code> .printBase64Binary(binary);<br /> }<br /></code><br />Nothing special. Just nice to know. :-)</div>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-602769459329747644.post-22814249969374457932010-10-28T10:10:00.006+09:002010-10-29T09:26:31.762+09:00VMWare and SpringVMWare <a href="http://goo.gl/9hsx">bangs their bells for Spring framework</a>, trying to tell it is best choice. Lots of people excited etc.<div><br /></div><div>Now <i>(*cracks my fingers*)</i> questions and doubts:</div><div><ol><li>Spring's arguments are valid. Yes, they are. With one little note: they are valid on EJB2 and JEE5, where first one has incredibly bad design, another is bulky and not really convenient. Wait a second... but we are not talking for <b>old</b> projects future, but for <b>new</b>! So, when you going to choose framework <b>for plain new</b> project, the we <b>do</b> have EJB3 and JEE6 today.</li><li>RedHat <i>(also known as a leader at Enterprises in Linux world, by the way)</i> and Snorcle <i>(also know as Oracle, also known as benevolent dictator, also known as Sun Microsystems eater)</i> — both of them completely don't really like Spring. In fact, they think it is a bullshit and they think JEE6 would fit to your datacenter much better.</li><li>Do you <i>really</i> like that <a href="http://uncyclopedia.wikia.com/wiki/XML">XML thing</a>? I think this is all like back to a stone-age, instead have just everything minimalistic and cute (means: modern).</li><li>Template classes as intrusive as it turns your code to a bullshit. Yes, you can have a <b>workaround</b> for this, but the keywords here are still stays to <i>"bad"</i> and <i>"design"</i>.</li><li>Tell me, you configuring or you coding?.. In Spring you will code^H^H^H^Hconfigure your project in XML. Well, no, you're literally <b>coding</b>. You are freakin' <b>coding</b> in XML, don't get fooled and mislead.<br /><br />Let me explain here a bit: a configuration file is something like you can find in Unix <i>/etc</i> directory. It is a small, simple ASCII text file, you can put comments in there and you can parse it with your Perl/Python/Ruby or just AWK/Sed. This is what is called: <i>configuration file</i> and was more than 30 years around. Now what Spring brings you into? A pile of XML, that are actually built into your WAR file. They do believe you have to change XML, so no need to change source code of Java.<br /><br />But this is utterly misleading: <i>you intrude to a deployed application</i> anyway (sane companies will put it through a "Change Request" procedure that involves also testing and quality assurance sometimes), while <i>configuring application</i> means you change only that little cute file in <i>/etc</i> directory (or click few checkboxes in admin UI) and thus your buddy sysadmin can do that with a cigarette in his teeth with a little effort (change request still required, but a consequences are significantly smaller).</li><li><b>Spring adds complexity</b>, it does <i>not</i> removes it. Don't be fooled: you will need to have a serious and difficult learning curve as well as you will need to spend weeks to configure your XML (see above).</li><li>Bugs in framework itself <b>will cost you</b> a lot. So make sure your framework is extensively supported, reviewed and updated. Who you will trust more: giants like Oracle and RedHat that has tons of very fat customers, or just a little VMWare — yet another player in virtual world with not the best business model? You choose.</li><li>OK, you can dismiss my XML rants by changing from XML to annotations. Great point! Because here is another problem:<b> different ways to do the same thing</b>. Java coders chronically away from Unix, but we already been there and we know it is called as "Tim Toady" or TMTOWTDI or "There's More Than One Way To Do It" or, simply <b>Perl</b>. It results to things <a href="http://www.perlmonks.org/?node_id=296552">like this</a> or <a href="http://www.perlmonks.org/?node_id=496245">like this</a>. In contrast, the beauty of Python language lays in its great philosophy: <i>"There should be only one — and preferably only one — obvious way to do it"</i>.<br />Little note to above: I was <b>not</b> talking about code obfuscation.</li><li>We already learned that <b>doing often casting is a bad idea</b>. So that's why we do have Generics for this and why we are trying to go away from casting operations as much as far as possible. However, Spring is pushing you back to a mesozoic era to fight <i>java.lang.ClassCastException</i> dinosaurs each next step. Stupid.</li><li><b>\u3042\u306a\u305f\u306f\u99ac\u9e7f\u3067\u3059</b> — this is how to say "Good morning" to your boss in Japanese <i>(anata ha baka desu)</i>, or exactly what you will get, once you open your ResourceBundle in VIM editor.</li><li>It is going up to eleven... You normally should keep <a href="http://www.javapractices.com/topic/TopicAction.do?Id=105">SQL separate from the code</a>. Try it with Spring and see how it works (or not) for you.</li></ol><div>Of course, the main question still around: <b>Why bother with Spring</b>, if JEE6:</div><div><ul><li>Is getting to be more and more lightweight than Spring 3</li><li>Is less complicated (recently) than Spring 3</li><li>Is well designed</li><li>Is well documented</li><li>Is well supported</li><li>Is an industry standard and chosen by industry leaders (sure).</li><li>Has <i>more</i> features</li><li>Is easier to learn (because it is less complicated)</li><li>Is not proprietary, versus Spring which <i><b>is</b> proprietary</i> container.</li></ul></div></div><div>I certainly don't have an answer on above. Maybe you have?</div><div><br /></div><div>Feel free to explain. :-)</div><div><br /></div>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-602769459329747644.post-45188998213829579482010-10-19T13:18:00.004+09:002010-10-19T13:38:16.042+09:00JSR 286 and crying developersJSR 286 is probably a primary way of how any web-related stuff should be done. Definitely. However, it has some nasty limitations, that would lead novice to hit the wall, step on rake, step on rake again etc. One of such limitations (well, not really, but still) is to return a file. Normally, JSR286 wants you to return HTML. But what if you want to click on some button and get a PDF file or TIFF or DOC or MP3 and so on? Usually, developers are setting content type, putting some content disposition to define filename etc, put some headers to flush cache, write to the output stream, recompile and deploy.<div><br /><div>Problem solved.</div><div>No, not really: once they call their portlet, entire application disappears and log is filled with devil's 666 lines of Java traceback from Hell. So, random desperate rants over forums begins usually with "me too!" or "pass me some code!" messages.</div><div>The real thing is: you need to read JSR286 <i>properly</i>. See, the JSR 168 does not allows us to use something else than just HTML. Pretty much silly. But JSR 286 allows. How? Easy: serve it as a resource. Hence the recipe:</div><div><ol><li>Implement/override method in GenericPortlet:<br /><span class="Apple-style-span" style="font-family:'courier new';"><span class="Apple-style-span" style="font-size:small;">serveResource(ResourceRequest request, ResourceResponse response)</span></span></li><li>In your JSP (or whatever you use) refer to it with Resource URL. In JSP you do it like this (use it on your own way):<br /><span class="Apple-style-span" style="font-family:'courier new';"><span class="Apple-style-span" style="font-size:small;">renderResponse.createResourceURL().toString()</span></span></li><li>In that "serveResource" thing check your request parameters and then return your content into an InputStream.</li></ol><div>Keep in mind, that normally you're dealing with <i>ResourceResponse</i>, which is different than HTTP response in a servlet. So after you've put content type in usual way, "setHeader" method is actually not available. But you can always use "setProperty" instead.</div><div>Now, if you are smart enough and using Liferay :-) instead of something else, then you simply could use one-liner <i>PortletResponseUtil</i> class, wher you can find a bunch of "sendFile" or "write" methods. They are just for your convenience: get from byte array, InputStream etc. As an example how it works, watch:</div></div><div><span class="Apple-style-span" style="font-family:'courier new';">PortletResponseUtil.sendFile(response,<br /></span><span class="Apple-style-span" style=" ;font-family:'courier new';"> "test.pdf",<br /> new FileInputStream(new File("/tmp/test.pdf")),<br /></span><span class="Apple-style-span" style=" ;font-family:'courier new';"> "application/pdf");</span></div><div>Now use your own imagination how to make it actually right (by replacing <i>FileInputStream</i> with something more valuable, as a starter). </div><div>This is it. Enjoy. :-)</div></div>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-602769459329747644.post-74314760941165752572010-10-12T10:31:00.003+09:002010-10-12T10:32:50.417+09:00Webrick or "We Brick"<div>Yup. "<i>We Brick</i>" ©:</div><div><br /></div><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhvxV3gLe8bLxKyP1Lywvh4vUgOU7HN2QD377shTi4g_Z1u11dwSxt8tiv1RE0lkD43dFcEWGoCcj1Gq-tthunaPYwOJDuGCrDCcTaGwsKiNVtCdi4rm9YmLzj1H8yX6MBEV5rcrFgsZmDg/s1600/Screen+shot+2010-10-12+at+10.30.46+AM.png"><img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 400px; height: 302px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhvxV3gLe8bLxKyP1Lywvh4vUgOU7HN2QD377shTi4g_Z1u11dwSxt8tiv1RE0lkD43dFcEWGoCcj1Gq-tthunaPYwOJDuGCrDCcTaGwsKiNVtCdi4rm9YmLzj1H8yX6MBEV5rcrFgsZmDg/s400/Screen+shot+2010-10-12+at+10.30.46+AM.png" border="0" alt="" id="BLOGGER_PHOTO_ID_5526966258485036674" /></a>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-602769459329747644.post-28446094242704308162010-10-07T22:24:00.006+09:002010-10-07T22:47:27.317+09:00Jasper Reports: gone!OK, this is it. I fed up fighting <a href="http://jasperforge.org/plugins/project/project_home.php?projectname=jasperreports">Jasper Reports</a> and simply ditched it. <a href="http://www.eclipse.org/birt/phoenix/">BIRT</a> (or "dirt" — you call it) although has interesting things, still is even worse than the <a href="http://jasperforge.org/plugins/project/project_home.php?projectname=jasperreports">Jasper Reports</a>. There is also <a href="http://reporting.pentaho.com/">Pentaho Reports</a> available. They are actually nice, but buggy as hell, crashes and has no much features. Embedding is odd.<div>At first, I don't need that fancy GUI editor. I simply don't. Do you need? No, you don't either. Here is why: it <i>requires</i> programming <b>anyway</b>. So if you think you will get this sexy full-screen editor with mousedraggable objects and will pass you your girls at operations department — you're wrong, wrong and once again wrong. They won't use that. Because if boss will ask you to make <span class="Apple-style-span" style="color:#FF0000;"><b>red color</b></span> some figures that are greater than 1000 — what you will do? It is not anymore mousedraggable and clicketyclickdroppable.</div><div>At second, I had a trouble with Japanese, but that's font package installation. Why do they do it this way — their problem. I don't like their (Jasper Report's) way to distribute fonts either.</div><div>Therefore I decided to make my own parser of my own markup, that is very similar to <a href="http://www.reportlab.com/docs/rml2pdf-ds.pdf">RML</a>, but is more looks like just a regular HTML. Basically a 50/50 mix of them.</div><div>So far, I achieved (in compare to Jasper Reports):</div><div><ul><li>Something like 40 times faster PDF compilation. Yes, up to forty times.</li><li>A very simple way to embed it to your servlet. The keyword here: "very". It is mostly a re-entrant one-liner, something like this:<br /><span class="Apple-style-span" style="font-family:'courier new';">new PDFRender(OutputStream, InputStream);</span></li><li>Very small footprint.</li><li>Resulting PDF simply crashes my Preview.app ... BWAHAHAHAHAHAHA!</li></ul><div>It renders still bit ugly sometimes and I still working on styles, but I have fully controlled by styles headers, footers, pagination, page layout, text body, paragraphs, True Type fonts, embedded images and a simple grid-like tables.</div><div><br /></div><div>Soon table spanning and styling is still coming (probably right tomorrow). Later I will add SVG support for native charts (still don't know how what way to do it is the best), barcodes and lovely Japanese <a href="http://en.wikipedia.org/wiki/QR_Code">QRCode</a> that is required just everywhere through.</div></div>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-602769459329747644.post-41845752943533090862010-09-17T12:47:00.008+09:002010-09-17T14:24:51.780+09:00Custom TTF Fonts in JasperReportsYou hit this wall too, aren't ya? At first I was truly pissed off by the overall design of Jasper Reports (entire suite in general). At second, I am even more pissed off how fonts are handled in PDFs.<div><br /></div><div>First what you do, is you're trying to install some TTF fonts into your JVM, somewhere in $JRE/lib/fonts, map them and hope things will fly. Then you probably specify that your new font in Jasper Report XML file, something like:</div><pre><font fontName="Great Font" /></pre><div>...and you finding it not working: in your PDF you see Helvetica. If you expect some Asian support (Japanese, e.g.), then you will find blank space there. Familiar, eh? Of course, you go around the XML Schema and finding that Jasper Reports actually has some more arguments to the "font" aggregate, so you adding it:</div><pre><font fontName="Great Font" ispdfembedded="true"/></pre><div>...and you finding it not working: in your PDF you see Helvetica. Then you, puzzled, finding out that there is also some more attributes (although they are quite odd anyway), so you use them too:</div><pre><font fontName="Great Font" ispdfembedded="true"<br />pdffontname="/madly/hardcoded/path/on/the/system/to/your/greatfont.ttf"/></pre><div>...and you still finding it not working: in your PDF you see Helvetica. Then you, angry, yelling "WTF!!!", googling around and you finding a lots of people, suffering from the same problem.</div><div><br /></div><div>The key to solve this puzzle is to deal with completely stupid implementation of Jasper Reports engine: you have to <i>package</i> these fonts into JAR file and <i>embed</i> into your application. They (developers) think that since it is Java, so "run everywhere", therefore you take your .WAR or .JAR or .EAR file and put on any possible container and it will just work, so no need to setup the environment. In reality, however, when you deploy 1000 applications like this, you also have 1000 duplications of the same stuff. It results to a horrible mess and very very VERY angry sysadmins that literally hates all the guts of Java. Moral: <b>keep it simple, stupid</b>.</div><div><br /></div><div>So anyways, how to use own TTFs or at least find Japanese visible? JaperReport's answer is: put this stuff into JAR and toss in into the classpath. Here is how to do it:</div><div><ol><li>In the default, root package, create a property file with a magic name: <i>jasperreports_extension.properties<br /><span class="Apple-style-span" style="font-style: normal;">Developers could not name it more elegant, like fonts.properties or, perfectly elegant, having none of it at all.</span></i></li><li><i>Create a package for your fonts. Let's say it is foo.bar.fonts</i></li><li>In this strange properties file we've made above, you have to put two things at least. One is very magical static property that normally can be hardcoded once and forever somewhere deep in the guts of JasperReports and never ever remembered anymore:<br /><i>net.sf.jasperreports.extension.registry.factory.simple.font.families<br />=net.sf.jasperreports.engine.fonts.SimpleFontExtensionsRegistryFactory<br /><span class="Apple-style-span" style="font-style: normal;">Can you read that wide?</span></i></li><li>Another property is to reference the reference to the reference of the actual files, embedded into the JAR:<br /><i>net.sf.jasperreports.extension.simple.font.families.<b>somebullshit</b><br />=foo/bar/fonts/fonts.xml<br /></i>That's how to let finally Jasper find the <i>fonts.xml</i> file. Please not one very nasty and ugly thing: there is no leading slash prior to "foo". Noticed? If you put it <i>(as it should be)</i>, then forget it working.</li><li>Now, in the <i>foo.bar.fonts</i> package create "<i>fonts.xml</i>". You can change its name in step #4.</li><li>Map your fonts there as it is in examples of JasperReports (demo/fonts).<br /></li><li>Compile all this assembly into a JAR file and toss in somewhere in your app $CLASSPATH. Now your PDF should pick up the font finally.</li><li>Phew!</li></ol></div><div>If you still find this idiotic (like I do), you'd better try Dynamic Jasper <a href="http://http//dynamicjasper.sourceforge.net/">http://http://dynamicjasper.sourceforge.net/</a> and it suppose to help you.</div><div><br /></div><div>You might ask: how it should be better implemented? OK, you ever heard about X11 and how fonts are mapped there? In the same fashion. Why not use just <i>fontmap.properties</i> file in the JAR and just simply drop fonts there and have zero XML? Yes, it is magic name, but it is the only magic name. And then stick to something like one line per font, e.g.:</div><div><span class="Apple-style-span"><span class="Apple-style-span" style="font-size: small;">family=weight,encoding,embedded,file.ttf</span></span></div><div>Said that, it might look this way:</div><div><span class="Apple-style-span"><span class="Apple-style-span" style="font-size: small;">greatfamily=n,UTF-8,t,greatfont-nnormal.ttf</span></span></div><div><span class="Apple-style-span"><span class="Apple-style-span" style="font-size: small;">greatfamily=i,UTF-8,t,greatfont-italic.ttf</span></span></div><div><span class="Apple-style-span"><span class="Apple-style-span" style="font-size: small;">greatfamily=b,UTF-8,t,greatfont-bold.ttf</span></span></div><div><span class="Apple-style-span"><span class="Apple-style-span" style="font-size: small;">greatfamily=bi,UTF-8,t,greatfont-bold-italic.ttf</span></span></div><div>Then, you run something like $JASPER_REPORTS/bin/fontpack ...and it would create such a JAR right away for you. How that sounds? That sounds just greatly simplified yet idiotism. What it actually should be: you specify font name "Great Font" (not path to actual TTF!) in the XML and it picks up automatically from the JVM right away. If font is not installed, then it has to fall-back to the default (Helvetica, in this case) by warning the user to the log file (instead of crashing, by the way). </div><div><br /></div><div>Still, I suffer from its <i>performance</i>, if this is the word. Generating PDFs are still hell very slow for my requirements. My next step will be ditching JasperReports and go OpenOffice.org as template editor and renderer iText based engine. Well, if company will pay for that. :-)</div>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-602769459329747644.post-21316590337346653262010-09-01T14:23:00.004+09:002010-09-01T14:56:32.602+09:00Nexenta 3.0 Zones: Fixing Broken BonesAs a rule of thumbs, when things installs very smoothly, I always suspect something wrong, because there is an old Ukrainian saying: <span style="font-style: italic;">"Devil lives in a silent lake"</span>. This time same thing happened to newly installed Nexenta Core 3.0 Release. Installation went just as sweet and smooth.<br /><br />But when it comes to zones... :-(<br /><br />Long story short: Zones are just totally broken in Nexenta Core 3.0 Release, end of story. SSH won't work, you won't login, no passwords asked, nothing. And I am quite surprised it was never fixed (probably nobody took a chance to test it). Now is the way how I fixed, grepping over bugs database:<br /><br />First, before you install a zone, you have to fix broken <span style="font-weight: bold;">/usr/bin/createzone</span> Perl script. This should be done in two steps:<br /><ol><li>Replace <span style="font-weight: bold;">elatte-unstable</span> with <span style="font-weight: bold;">hardy-unstable</span> on a line #41.</li><br /><li>Throw away <span style="font-weight: bold;">@source_files</span> with all its guts and replace with the following:<br /><pre>my @source_files = qw(<br />/lib/svc/method/nexenta-sysidtool-system<br />/var/svc/manifest/system/nexenta-sysidtool.xml<br />/lib/svc/method/nexenta-sysidtool-net<br />);<br /><span style="font-family:Georgia,serif;"></span></pre></li></ol>Second, fix broken <span style="font-weight: bold;">/lib/svc/method/svc-syseventd</span> script. This is done in quite dirty way, but at least works fine:<br /><ol><li>In the <span style="font-style: italic;">global</span> zone edit the script above. Find this line (below the CDDL header):<br /><pre>. /lib/svc/share/smf_include.sh</pre>...and add this:<br /><pre>[ `zonename` = global ] || sleep 3600 & exit 0<br /></pre>...so in result you will get this:<br /><pre>. /lib/svc/share/smf_include.sh<br />[ `zonename` = global ] || sleep 3600 & exit 0<br /></pre></li></ol><p>This will allow required services finally start.</p><p>Now you can install your zone (<span style="font-weight: bold;">zoneadm -z yourzonename install</span>).<br /></p><p>Third, fix <span style="font-style: italic;">shadow</span> and <span style="font-style: italic;">passwd</span>. Boot your zone and <span style="font-weight: bold;">zlogin</span> to it in a single mode (-S), then issue <span style="font-weight: bold;">pwconv</span> command and exit.</p><p>Finally, after you anyhow login to that thing, reconfigure broken system service once again, like this:<br /></p><pre>dpkg-reconfigure sunwcsd<br />svccfg import /var/svc/manifest/system/sysevent.xml<br /></pre><br />And yes, this is Unix. You should <span style="font-style: italic;">reboot</span> your zone in order it getting working right. :-)Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-602769459329747644.post-75615972964100268362010-08-30T11:18:00.003+09:002010-08-30T12:46:25.241+09:00GlassFish v3 on OpenSolarisOpenSolaris is dead as a distro, but it is still around, unless it's content moved/migrated to Nexenta or, later, IllumOS. Today I've got weird error from GlassFish v3 after installation. Apparently that's because OpenSolaris has chronically screwed up locales (one never grows up). Here is the way how the thing looks like in all its glory:<br /><pre>Waiting for DAS to start ..Error starting domain: domain1.<br />The server exited prematurely with exit code 6.<br />Before it died, it produced the following output:<br /><br />UTF ERROR ["../../../src/solaris/instrument/EncodingSupport_md.c":66]: Failed to complete<br />iconv_open() setup<br /></pre>So the cure is quite simple: fix that broken locale (in fact, broken locale breaks other things anyway). To do so, install <code>SUNWlang-enUS</code> from the IPS and add <code>export LANG=en_US.UTF-8</code> in your <code>.profile</code> to make it default. Maybe also good idea to add it to the skeleton... :)Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-602769459329747644.post-67631916348079095082010-08-17T17:26:00.004+09:002010-08-17T17:50:38.620+09:00Mirroring ZFS rpoolOK, time to mirror my rpool. Apparently, it rendered for that works with FreeBSD, but does not with Solaris. <i>(WTF!?)</i><br /><pre># zpool attach rpool c0t0d0 c0t1d0<br />cannot label 'c0t1d0': EFI labeled devices are not supported on root pools.</pre>Ewww... :-(<div><br /></div><div>Here is the steps to cure this illness:</div><div><ol><li><b>format -e</b> will give you all the drives available.</li><li>If you found one it needs to be formatted, use <b>fdisk</b> and create 100% <b>Solaris2</b> partition.</li><li>Your drive supposed to be in <span class="Apple-style-span" style="font-family:'courier new';">/dev/<b>rdsk</b>/</span> somewhere (don't forget to look in "rdsk", instead in "dsk"). In my case <span class="Apple-style-span" style="font-family:'courier new';">/dev/rdsk/c0t1d0</span></li><li>Fix broken bones for the Disk Format:<br /><span class="Apple-style-span" style="font-family:'courier new';">prtvtoc /dev/rdsk/c0t0d0 | fmthard -s - /dev/rdsk/c0t1d0</span><br />Then <b>fmthard</b> should tell you something like:<i> "New volume table of the contents now in place"</i>. If it didn't — you're out of luck and try to figure out why. :-)</li><li>Try to attach a drive to <i>rpool</i>, but it may scream, something like this:<br /><span class="Apple-style-span" style="font-family:'courier new';">zpool attach rpool c0t0d0 c0t1d0<br />invalid vdev specification<br />use '-f' to override the following errors:<br />/dev/dsk/c0t0d0 overlaps with /dev/dsk/c0t1d0<br /></span><br />Well, so be it. Use '-f' option to force it:<br /><br /><span class="Apple-style-span" style="font-family:'courier new';">zpool attach -f rpool c0t0d0 c0t1d0<br /><br />Please be sure to invoke installgrub(1M) to make 'c0t1d0' bootable.<br />Make sure to wait until resilver is done before rebooting.</span></li><li>Normally, you're done: <b>zpool status</b> should show you a mirrored <i>rpool</i>. But you're <u>almost</u> there: still you need to install GRUB.</li><li>Install GRUB this way:<br /><span class="Apple-style-span" style="font-family:'courier new';">installgrub -m /boot/grub/stage1 /boot/grub/stage2 /dev/rdsk/c0<span class="Apple-style-span" style="color:#FF0000;"><b>t1</b></span>d0</span></li></ol><div>Basically this is it, now you might try to boot from another drive. But wait your rpool resilvered though... :-)</div></div>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-602769459329747644.post-57237008615935203312010-06-02T11:55:00.002+09:002010-06-02T12:02:28.262+09:00Fight with OpenNMS on OpenSolarisI've tried to install OpenNMS on OpenSolaris from standalone installer (shipped in one single JAR file that you suppose to run). Everything fine (mostly) as long as you follow the instructions, but some ugly things needs to be mentioned:<div><ul><li>Your JRE is not enough. See, OpenNMS will ask you to install full blown JDK. What for — I have no idea. But that's why we hate most Java developers: they are unable to make cute small things in most cases.</li><li>Your PostgreSQL will say something rude to the installer and latter will be upset, asking you personal questions. So make sure, in prior to running the installer, you did the following:<br /><span class="Apple-style-span" style="font-family:'courier new';">postgres=# create user opennms with password 'opennms';<br /><br />postgres=# alter user opennms with password 'opennms';<br />ALTER ROLE<br /><br />postgres=# create database opennms owner opennms;<br />CREATE DATABASE<br /><br />postgres=# grant all privileges on database opennms to opennms;<br />GRANT</span></li><li><div>You changed your passwords for "opennms" user in DB and also you fixed your trust store where password it "changeit".</div></li></ul></div>Everything else should work, as long as your ports are opened properly. In order to know if something wrong (and it usually is), try to see what's running and what's not by issuing a command:<div><br /><div><span class="Apple-style-span" style="font-family:'courier new';">$OPEN_NMS/bin/opennms -v status</span></div><div><br /></div><div>This will list all the processes and will show you the status.</div><div><br /></div></div>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-602769459329747644.post-27642022571450643652010-05-13T09:42:00.002+09:002010-05-13T09:52:11.528+09:00Cloud vs Grid computingFolks, enough!<div>There is no such thing as "versus" and it is not anything that you don't know yet. Grid computing is an engine on a chassis, where cloud computing is a complete car that you drive on. Hence, <b>grid computing</b> is how data is distributed in heterogeneous fashion skipping geographical constraints, while <b>cloud computing</b> is how data is accessed. So the complete product is all these things working together. End of story.<div>And, yes, it has been around for last 20 years: "<a href="http://www.thenetworkisthecomputer.com/">The Network Is The Computer</a>", if you still didn't noticed...</div></div>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-602769459329747644.post-5724974812034518932010-03-29T10:58:00.001+09:002010-03-29T10:58:33.035+09:00DTrace. Quick start.<a href="http://www.opensolaris.org/os/community/edu/nocost_resources/DTRACEGSG.pdf">Here</a>.Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-602769459329747644.post-2165895415119476722010-03-29T10:15:00.003+09:002010-03-29T10:54:31.804+09:00OpenSolaris and ISO imagesYou have an OpenSolaris box and you also want to archive some things on DVD (well, just in case). Here the things everyone on Solaris should know (in case you don't):<div><ol><li>First, make an ISO out of the directory that allows full 31 character filenames, instead to truncate them 8.3 format which is compatible with MS-DOS. You also might consider <b>"joliet-long"</b> option in order to allow Joliet filenames to be up to 103 Unicode characters. This breaks the Joliet specs, but appears to work. The following example is just a straight-forward:<br /><b>mkisofs -J -l -o foobar.iso /path/to/the/folder</b></li><li>Second, you want to test and verify it. In Solaris, prior to mounting, you should make a block device from the file, first. In this case, <b>lofiadm</b> is your friend in this way:<br /><b>pfexec lofiadm -a foobar.iso</b><br />Please note that you will need to escalate a privileges, because it will create a new device in <b>/dev/lofi</b> directory. To know all the list, simply run <b>lofiadm</b> as is. In this example it appears as <b>"/dev/lofi/1"</b> device.</li><li>Now is a time to mount the device. Create some directory (e.g. <b>/tmp/foobar</b>) and mount the device (not the .iso file):<br /><b>pfexec mount -F hsfs /dev/lofi/1 /tmp/foobar/<br /><span class="Apple-style-span" style="font-weight: normal;">Things looks OK? :)</span></b></li><li>Un-mount your filesystem and remove mount point to cleanup the mess behind you:<br /><b>pfexec umount /tmp/foobar; rmdir /tmp/foobar</b></li><li>Remove block device (same mess):<br /><b>pfexec lofiadm -d /dev/lofi/1</b></li><li>I usually don't burn CD/DVD's on a server remotely due to a number of issues with that, but if you like, you can do it. Normally, you want to use "<b>cdrw</b>" on Solaris (<b>SUNWcdrw</b> package in IPS, in case you haven't it installed) like this:<br /><b>cdrw -C -i /path/to/your/foobar.iso</b><br />This will also detect automatically you're burning DVD or CD, will check the size and so on.</li><li>Probably remove your .iso image as well. :-)</li></ol><div>That's was a Solaris way and is slightly different that on a typical Linux box.</div></div>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-602769459329747644.post-80360602883413893592010-03-26T09:25:00.003+09:002010-03-29T10:53:35.053+09:00Mail.app, show me a plain text!I hate HTML messages. Especially, when you ask your mates <b>not</b> to send HTML for simple text. They do. You won't shoot em, because you will have to do their job as well (this leads to lack of sleep). So there is other way: force Mail.app display a plain text. Normally, there is no checkbox in Preferences, but Mail.app still "eats" this preference in plist, like this:<pre><key>PreferPlainText</key><br /><true/><br /></pre>Cool. So we can do this:<br /><code>defaults write com.apple.mail PreferPlainText -bool TRUE</code><p></p><p>Now restart Mail.app and you've done.</p>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-602769459329747644.post-69147676076175285072010-02-01T10:52:00.003+09:002010-02-01T10:59:30.510+09:00What 2010 is going to bring us?<div>I am thinking: is 2010 is a year for epic failures? Project Kenai is going to be closed "for better user experience" which means "no more Kenai for the rest of us", only for those, who pays to the god Oracle goddamn money. And Jobs with his strange not-really-an-iPhone XXL, called iPad — next laptop will be 4x times bigger as well?</div><div><br /></div>Now, recently new NetBeans 6.8 tutor came out — <a href="http://netbeans.org/kb/docs/web/hibernate-webapp.html">http://netbeans.org/kb/docs/web/hibernate-webapp.html</a> — with a multitude of the code, that results to a simple CRUD. Tendency is ridiculous again: now with embedding parts of query language right into your code. "Brilliant" design! — they welcomed things which they wanted go away from.<div><br /></div><div>Wait, a president elections in my country now happening...</div>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-602769459329747644.post-310270962150418212010-01-14T11:44:00.004+09:002010-01-14T11:58:40.972+09:00Bye-bye, Postfix...Times ago I've dumped Sendmail and replaced with a Postfix. Now, after a while, having a number of requirements that needs to be implemented with something more sophisticated, it is a time to replace Postfix for something better, easier and more flexible.<div><br /></div><div>My choice is now Apache James (<a href="http://james.apache.org/">http://james.apache.org/</a>).</div><div><br /><div>Tests went fine, things works as expected. Configuration is dull easy, like for those, who see an email server for the first time in their life. Apache James looks pretty good inside (source code), is extensible, has nice plugins and great API to make your own, if you like (that's exactly what I really need). Some folks reports it handles about 3K messages per a minute. I think, that's impressive number, but I don't need such anyways. :-)</div><div><br /></div><div>The greatest thing of all this story: this particular mail server is a 100% pure Java.</div></div>Unknownnoreply@blogger.com2tag:blogger.com,1999:blog-602769459329747644.post-70791033614814019402010-01-13T23:29:00.002+09:002010-01-13T23:35:37.259+09:00How to run background process in GWTThere is no such thing as "background process" in Google Web Toolkit client, because... it is a <i>client</i> part. So you can not do threads, can not do daemons, since it supposed to be cross-compiled to JavaScript and run in a browser <s>pretty ugly way</s>. However, you can repeatedly call the same function. In JavaScript it is timeout. But you want to avoid JSNI for this. Hence, do the following: use a <code>com.google.gwt.user.client.Timer</code>. If you want call it periodically each 5 seconds, you can do something like this:<br /><pre>private void updaterProcess() {<br /> Timer timer = new Timer() {<br /> @Override<br /> public void run() {<br /> // call stuff here<br /> }<br /> };<br /><br /> timer.scheduleRepeating(5000);<br />}<br /></pre>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-602769459329747644.post-8265717958740344602010-01-13T09:36:00.002+09:002010-01-13T09:38:36.184+09:00Shift happens...<p>Google got pissed off:</p><p><i>"We have decided we are no longer willing to continue censoring our results on Google.cn, and so over the next few weeks we will be discussing with the Chinese government the basis on which we could operate an unfiltered search engine within the law, if at all. We recognize that this may well mean having to shut down Google.cn, and potentially our offices in China."</i></p>Complete story here: <a href="http://googleblog.blogspot.com/2010/01/new-approach-to-china.html">http://googleblog.blogspot.com/2010/01/new-approach-to-china.html</a><div><br /></div><div>Well done, Google! Well done.</div>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-602769459329747644.post-12586637105886834962010-01-12T11:57:00.004+09:002010-01-12T12:30:17.476+09:00How things gets screwed up, when you're not thinking...Short note how JNLP is screwed up in the GlassFish. <div>You like GlassFish, aren't ya? Now, consider, you want distribute your application over JNLP, as <a href="http://www.uhradio.fm/web/guest/listen">I did on my radio website</a>. It is an MP3 player with an ability send SMS messages, so far. Note, the website is in Ukrainian language, but you can simply click on that whacky image somewhere in the middle of the article. :-)</div><div><br /></div><div>Since it is Java Web Start, the way you put it to the GlassFish is using Enterprise Application, then create a client to it, and then put your stuff there, pack as an ".ear" and deploy. Sounds cool, right? Yes, sounds very-very cool. Note that since it is Java Web Start, you don't want to listen to your complaining users for like "WTF is this?!" etc., instead you want your application:</div><div><ul><li>Be damn fast.</li><li>Be damn small.</li><li>Be damn quick.</li></ul><div>However, not with Enterprise Application. Once you've packed your app as ".ear", it will suck up a sh*tload of <b>useless</b> jar's, verify each by unpacking, checking etc. On an average user's Vista laptop, where all the resources went to antivirus and antimalware package, you do not want it happen ever. Some of my users complained they had to wait 8 (eight, EIGHT) minutes to load a very little tiny application, like that one. Take a look what you've got in your cache among other crap: Java EE jar! Application Server runtime! OMG!..</div><div><br /></div><div>Now... The obvious question is how to cure all this mess to make your 200K application start literally in a moment? Forget stupid Enterprise Application, once you go with JNLP. It is still good if you do EJB things (I do, so far so good). Never touch JEE for client part (make sure it is server thing in your app) and deploy as a simple GUI that talks to your server via webservices (REST or SOAP is fine). Deploy it just manually, as a static data somewhere on the server.</div><div><br /></div><div>How deploy it manually on GlassFish. I assume you're using NetBeans? If no, you should. :-) So go to the properties of your Project, select "Web Start enabled", sign your jars with an SSL certificate and rebuild all the stuff. In your Project's "dist" folder you will find ready to go app (almost). Then edit codebase URL in order it point to your website over HTTP instead using file:// from local system. Tar/gzip all the dist/ folder with everything inside, scp to your server and unpack to the static folder of the GlassFish ($ROOT/domains/$DOMAIN/docroot) or, if it is GlassFish + Liferay, then look inside deployed Liferay package.</div><div><br /></div><div>That's it.</div><div><br /></div><div>P.S. Sun, I hope Oracle will kick your ass very hard to gently encourage you think properly and organize your technology the way it be once actually usable for everyone.</div></div>Unknownnoreply@blogger.com2