tag:blogger.com,1999:blog-23492794877991721662024-03-14T05:24:10.393+01:00Music, Sports and Computers, that's what it's all about ...Ralfhttp://www.blogger.com/profile/01978624103770121257noreply@blogger.comBlogger174125tag:blogger.com,1999:blog-2349279487799172166.post-39033164910904064652023-08-06T20:46:00.003+02:002023-08-06T20:46:35.067+02:00QNAP Webinterface funktioniert plötzlich (oder nach Firmware Update) nicht mehr<p>Ich hatte vor kurzem das Problem, das auf meinem betagten QNAP TS-569 Pro das Webinterface per https nicht mehr erreichbar war.</p><p>Es kam der Fehler "503 - Service Unavailable".</p><p>Da ich die Anmeldung bzw. den Aufruf des Webinterface nur per SSL zugelassen hatte, konnte ich nicht mehr die Variante ohne SSL auf Port 8080 probieren, da dort der http Service ja von mir generell abgeschaltet wurde.</p><p>Per QFinder war das NAS aber noch auffindbar und auch der SSH Zugriff funktionierte problemlos. Dies ermöglichte es mir auch, den Fehler zu beheben.</p><p>Ich habe mich per SSH am QNAP als Admin angemeldet und dann die folgenden Befehle ausgeführt:</p><pre style="background-attachment: initial; background-clip: initial; background-color: #f0f0f0; background-image: URL(http://2.bp.blogspot.com/_z5ltvMQPaa8/SjJXr_U2YBI/AAAAAAAAAAM/46OqEP32CJ8/s320/codebg.gif); background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; background: rgb(240, 240, 240); border: 1px dashed rgb(204, 204, 204); color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; overflow-wrap: normal; word-wrap: normal;"> setcfg system "Force SSL" 0
setcfg system "Web Access Port" 8080
</code></pre><p>und danach dann den Apache neu gestartet mit:</p><pre style="background-attachment: initial; background-clip: initial; background-color: #f0f0f0; background-image: URL(http://2.bp.blogspot.com/_z5ltvMQPaa8/SjJXr_U2YBI/AAAAAAAAAAM/46OqEP32CJ8/s320/codebg.gif); background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; background: #f0f0f0; border: 1px dashed rgb(204, 204, 204); color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; overflow-wrap: normal; word-wrap: normal;"> /etc/init.d/thttpd.sh restart
</code></pre><p>Anschließend konnte ich mich per http auf Port 8080 anmelden und auch die https Variante funktionierte wieder.</p><p>Ggfs. kann beim setcfg noch folgender Befehl helfen:</p><pre style="font-family:arial;font-size:12px;border:1px dashed #CCCCCC;width:99%;height:auto;overflow:auto;background:#f0f0f0;;background-image:URL(http://2.bp.blogspot.com/_z5ltvMQPaa8/SjJXr_U2YBI/AAAAAAAAAAM/46OqEP32CJ8/s320/codebg.gif);padding:0px;color:#000000;text-align:left;line-height:20px;"><code style="color:#000000;word-wrap:normal;"> setcfg system "Lan Access" "TRUE"
</code></pre><p>That's it!</p><p> </p>Ralfhttp://www.blogger.com/profile/01978624103770121257noreply@blogger.com0tag:blogger.com,1999:blog-2349279487799172166.post-1212462131285322082022-12-05T15:28:00.005+01:002022-12-07T12:10:45.214+01:00intelliMove - New version of my Android "Keep screen on" app now available in Google Play Store<p>Almost 7 years after I did the latest update of my app "intelliMove" I decided to update and polish the app. Get rid of old and deprecated stuff and do a little facelift.</p><p>The app is available on Google Play using this URL: <a href="https://play.google.com/store/apps/details?id=de.qu.android.intellimove&hl=en">https://play.google.com/store/apps/details?id=de.qu.android.intellimove&hl=en</a></p><h2 style="text-align: left;">Short description of the app</h2><p>intelliMove controls, whether the screen of your device should go off or stays on by detecting if the device is in use. It is a so called "screen on" tool. It's simply bothering, when you are looking at your device (without touching it) and the screen goes off after reaching the display timeout.</p><h3 style="text-align: left;">How does keep screen on works?</h3><p>It works by examining the angle in which the device is being used (or hold). If the device is within a specified range (configured via preferences) the screen will not go off, because intelliMove assumes the device is in use. intelliMove comes with predefined orientation ranges for different device types (e. g. tablet or smartphone) so that a range configuration is usually not necessary. intelliMove keeps the screen on when you need it!</p><p>Furthermore, it is optionally possible to add a face detection using the device front camera. This feature only gets activated, when the device is out of configured orientation range and tries to determine, whether someone is looking at the device.</p><h3 style="text-align: left;">What else can intelliMove do?</h3><p>intelliMove can extend the battery life of your device. Because intelliMove detects when the device is not in use the screen timeout value can be set to the minimal value (e.g. 15 seconds).</p><p>In case the device isn't used anymore, the screen goes off after the minimal configured timeout and not after waiting 2 minutes (or whatever long value is configured in settings)</p><p>The display is the biggest battery consumer of the device and drains the battery the most ... intelliMove can help to reduce those massive drains!</p><h3 style="text-align: left;">What else?</h3><div>Well, intelliMove is able to detect if the phone was put into a pocket and turns off the screen when this gesture was detected. There are a few more gestures that intelliMove can detect.</div><div><br /></div><div>Many of the so called "Screen On" apps work by using the front camera. intelliMove only uses the front camera if this feature was activated (to be honest it is still experimental). Using the camera consumes more battery than using the sensors of the phone. intelliMove uses the sensors of your phone to detect if the phone is in use.</div><div><br /></div><h3 style="text-align: left;">Pricing</h3><div>I have decided to introduce a subscription model for this app. Implementing this app is very time consuming and I have to test it on multiple devices. Please understand this. There is a basic and a premium subscription model. Please support the further development of this app!</div><div><br /></div><div>The app runs in a 7 day trial period so it can be tested extensively. There are a lot of devices out there, and I can not test the app on each and every one of it.</div><div><br /></div><h3 style="text-align: left;">Requirements</h3><div>I hope you like the app and feel free to test it. I am also glad about any feedback you provide. The app should run on almost any modern device (phone, tablet). Android 7 is the minimum requirement.</div><div><br /></div>Ralfhttp://www.blogger.com/profile/01978624103770121257noreply@blogger.com0tag:blogger.com,1999:blog-2349279487799172166.post-69719420542026053232022-10-09T11:19:00.003+02:002022-10-09T18:06:26.562+02:00Automatischer Neustart bei Samsung Handys funktioniert nicht - Hier die (simple) Lösung<p>Seitdem ich ein Samsung A52 besitze, habe ich mit der Funktion <b>"Automatischer Neustart zu festen Zeiten"</b> gekämpft.</p><p>Ich habe diesen Punkt aktiviert, damit das Handy regelmässig mal neu gestartet wird um Arbeitsspeicher freizugeben und Hintergrundaktivitäten zu beenden die evtl. noch unnütz laufen.</p><p>Leider hat der Neustart NIE geklappt. Wenn man unter <b>"Akku -> Wartungsbericht"</b> nachschaut, stand dort immer unter <b>"Letzter automatischer Neustart"</b> der Wert "Nie".</p><p>Die Lösung habe ich nach langem Suchen in <a href="https://eu.community.samsung.com/t5/galaxy-s22-serie/galaxy-s22-normal-automatischer-neustart-funktioniert-nicht/td-p/5153151" target="_blank">diesem Forumseintrag</a> gefunden.</p><p>Damit das Ganze definitiv funktioniert, muss die SIM Kartensperre deaktiviert werden.</p><p>Also unter <b>"Andere Sicherheitseinstellungen"</b> den Punkt <b>"SIM-Sperre einrichten"</b> anwählen und dort die Option <b>"Sperren der SIM-Karte"</b> deaktivieren. Und schwupps klappt es auch mit dem Neustart.</p>Ralfhttp://www.blogger.com/profile/01978624103770121257noreply@blogger.com0tag:blogger.com,1999:blog-2349279487799172166.post-3000355000640517892017-09-01T10:02:00.001+02:002017-09-01T10:02:23.488+02:00Howto exclude files from git without committing changes to .gitignoreLong time, no post ;-)<br />
<br />
There are sometimes use cases where you don't want to change the <b>.gitignore</b> file.<br />
<br />
You want to keep your local modifications just on your local box but you don't want a git pull command to change those modifications.<br />
<br />
The file <b>.git/info/exclude</b> allows you to ignore files from being staged.
It's some sort of own personal .gitignore file, which no other can see or touch.
See <a href="https://hackernoon.com/exclude-files-from-git-without-committing-changes-to-gitignore-986fa712e78d" target="_blank">this blog posting</a> for more details.Ralfhttp://www.blogger.com/profile/01978624103770121257noreply@blogger.com0tag:blogger.com,1999:blog-2349279487799172166.post-55359374866357645172015-08-10T18:03:00.002+02:002015-08-11T11:41:48.566+02:00VirtualBox: Running Samba inside CentOS 7 guest and expose Samba shares to running Windows hostThis was a problem puzzling me a complete day. My environment is as follows:<br />
<ul>
<li>Running Windows 7 (64 Bit)</li>
<li>Using VirtualBox 5 to run CentOS 7 as Linux guest</li>
</ul>
I was looking for a solution to create a Samba share inside the CentOS guest, so I am able to access folders in the running CentOS guest from my Windows 7 host system.<br />
<br />
I configured VirtualBox to use two network adapters (NAT and Host-Only).<br />
<br />
I installed Samba on the CentOS guest and configured it as a Standalone Server. I created a Samba share called "data". See the full smb.conf here, the Samba share is defined at the end of the file:<br />
<br />
<pre style="background-image: URL(http://2.bp.blogspot.com/_z5ltvMQPaa8/SjJXr_U2YBI/AAAAAAAAAAM/46OqEP32CJ8/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> [global]
workgroup = WORKGROUP
server string = Samba Server Version %v
dns proxy = no
# log files split per-machine:
log file = /var/log/samba/log.%m
# maximum size of 50KB per log file, then rotate:
max log size = 50
security = user
passdb backend = tdbsam
load printers = yes
cups options = raw
server role = standalone server
encrypt passwords = true
guest ok = yes
usershare allow guests = yes
obey pam restrictions = yes
unix password sync = yes
passwd program = /usr/bin/passwd %u
passwd chat = *Enter\snew\s*\spassword:* %n\n *Retype\snew\s*\spassword:* %n\n *password\supdated\ssuccessfully* .
pam password change = yes
map to guest = bad user
#============================ Share Definitions ==============================
[homes]
comment = Home Directories
browseable = no
writable = yes
; valid users = %S
; valid users = MYDOMAIN\%S
[printers]
comment = All Printers
path = /var/spool/samba
browseable = no
guest ok = no
writable = no
printable = yes
[data]
comment = Data Folder
path = /data
guest ok = yes
browseable = yes
create mask = 0777
directory mask = 0777
writable = yes
force create mode = 777
force directory mode = 777
force security mode = 777
force directory security mode = 777
</code></pre>
<br />
This Samba configuration works in an Ubuntu 14.04. VirtualBox guest OS perfectly. But no matter what I did, this configuration did not work in CentOS. I always got a "Permission denied" error when I tried to access the Samba share from the Windows host using<br />
<br />
<span style="font-family: "Courier New",Courier,monospace;">\\centos-guest\data\</span><br />
<br />
Well it turned out, that the problem was a running firewall AND SELinux (Security-Enhanced Linux). To disable both do the following steps in CentOS:<br />
<ol>
<li>systemctl stop firewalld</li>
<li>systemctl disalbe firewalld</li>
<li>vi /etc/selinux/config </li>
</ol>
<br />
<pre style="background-image: URL(http://2.bp.blogspot.com/_z5ltvMQPaa8/SjJXr_U2YBI/AAAAAAAAAAM/46OqEP32CJ8/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> # This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=disabled
# change
# SELINUXTYPE= can take one of these two values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
</code></pre>
<br />
After this, reboot the guest OS and you can access the samba shares of your CentOS guest on your Windows host.<br />
<br />
But be warned, you disabled the firewall on your Linux guest OS!<br />
If this is not what you want, you should find an alternative approach.Ralfhttp://www.blogger.com/profile/01978624103770121257noreply@blogger.com0tag:blogger.com,1999:blog-2349279487799172166.post-35852867340095282852014-06-14T12:08:00.000+02:002014-06-14T12:08:15.779+02:00Create and import a MySQL dumpDumping a MySQL database is that simple:<br />
<br />
<pre style="background-image: URL(http://2.bp.blogspot.com/_z5ltvMQPaa8/SjJXr_U2YBI/AAAAAAAAAAM/46OqEP32CJ8/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> /path/to/mysqldump -u$DBUSER -p$DBPASSWD -h$DBHOST $DBNAME > $FILENAME
</code></pre>
<br />
Importing the dump back into a MySQL DB looks like this:<br />
<br />
<pre style="background-image: URL(http://2.bp.blogspot.com/_z5ltvMQPaa8/SjJXr_U2YBI/AAAAAAAAAAM/46OqEP32CJ8/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> /path/to/mysql -u $DBUSER -p$DBPASSWD --database=$DBNAME < $FILENAME
</code></pre>
<br />
If the database to import is encoded with UTF8 it might be necessary to use the option<br />
--default_character_set<br />
<br />
<pre style="background-image: URL(http://2.bp.blogspot.com/_z5ltvMQPaa8/SjJXr_U2YBI/AAAAAAAAAAM/46OqEP32CJ8/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> /path/to/mysql -u $DBUSER -p$DBPASSWD --default_character_set utf8 --database=$DBNAME < $FILENAME
</code></pre>
<br />Ralfhttp://www.blogger.com/profile/01978624103770121257noreply@blogger.com0tag:blogger.com,1999:blog-2349279487799172166.post-20026977853491319932014-06-10T23:13:00.000+02:002014-06-13T17:24:17.341+02:00How to get module name and application name in Java EE applicationsIt's been a long time since my last blog post, but here is an update :-)<br />
<br />
For those of you who always wanted to get the name of the application or the module at runtime in a Java EE application, here is a solution:<br />
<br />
<pre style="background-image: URL(http://2.bp.blogspot.com/_z5ltvMQPaa8/SjJXr_U2YBI/AAAAAAAAAAM/46OqEP32CJ8/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> @Resource(lookup="java:module/ModuleName")
private String moduleName;
@Resource(lookup="java:app/AppName")
private String applicationName;
</code></pre>
<br />
It's been there since Java EE 6 and it's easy and portable!<br />
<br />
There is also the opportunity to get those names via JNDI lookup<br />
<br />
<pre style="background-image: URL(http://2.bp.blogspot.com/_z5ltvMQPaa8/SjJXr_U2YBI/AAAAAAAAAAM/46OqEP32CJ8/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> String myModuleName = (String) initialContext.lookup("java:module/ModuleName");
String myApplicationName = (String) initialContext.lookup("java:app/AppName");
</code></pre>
<br />
If you don't need the names in a field but just in a single method this is the way to go.<br />
<br />
The default module name is the base name of an ejb-jar or WAR archive.<br />
The default application name is the base name of an EAR archive.Ralfhttp://www.blogger.com/profile/01978624103770121257noreply@blogger.com0tag:blogger.com,1999:blog-2349279487799172166.post-63175423653664427132014-02-01T21:13:00.001+01:002014-02-03T11:25:24.863+01:00Solution for “Certificate has expired” in log when starting Glassfish 3.1.2<div dir="ltr">
Since a few weeks my GlassFish installation produces an annoying message whenever it gets started. The message looks <a href="http://stackoverflow.com/questions/18248020/certificate-has-expired-in-log-by-starting-glassfish-3-1-2">like this one posted on </a><a href="http://stackoverflow.com/questions/18248020/certificate-has-expired-in-log-by-starting-glassfish-3-1-2">stackoverflow</a>:</div>
<div dir="ltr">
<br /></div>
<div dir="ltr">
<br /></div>
<pre style="background-image: URL(http://2.bp.blogspot.com/_z5ltvMQPaa8/SjJXr_U2YBI/AAAAAAAAAAM/46OqEP32CJ8/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> ...
[exec]
[exec] [#|2013-08-15T08:57:42.106+0200|INFO|glassfish3.1.2|javax.enterprise.system.core.com.sun.enterprise.v3.services.impl|_ThreadID=39;_ThreadName=Thread-2;|Grizzly
Framework 1.9.50 started in: 16ms - bound to [0.0.0.0:1307 6]|#]
[exec]
[exec] [#|2013-08-15T08:57:42.262+0200|INFO|glassfish3.1.2|javax.enterprise.system.core.com.sun.enterprise.v3.server|_ThreadID=1;_ThreadName=Thread-2;|GlassFish
Server Open Source Edition 3.1.2.2 (5) startup time : Felix (1'1
23ms), startup services(609ms), total(1'732ms)|#]
[exec]
[exec] [#|2013-08-15T08:57:42.309+0200|SEVERE|glassfish3.1.2|javax.enterprise.system.ssl.security.com.sun.enterprise.security.ssl.impl|_ThreadID=40;_ThreadName=Thread-2;|SEC5054:
Certificate has expired: [
[exec] [
[exec] Version: V3
[exec] Subject: CN=GTE CyberTrust Root 5, OU="GTE CyberTrust Solutions, Inc.", O=GTE Corporation, C=US
[exec] Signature Algorithm: SHA1withRSA, OID = 1.2.840.113549.1.1.5
[exec]
[exec] Key: Sun RSA public key, 2048 bits
[exec] modulus: 237418898293472616608124373663877543854434319738611148654904141538840503317458119685231168476255701465927369352097185652960533868421359855348631579831288127741629980536737464707822524076734022381468699944387
29551246768368782318393878374421033907597162218758024581735139682087126982809511479059100617027892880227587855877479432885604404402435662802390484099065871430585284534529627347717530352189612077130606642676951640071336717026459037
542552927905851171460589361570392199748753414855675665635003335769915908187224347232807336022456537328962095005323382940080676931822787496212635993279098588863972868266229522169377
[exec] public exponent: 65537
[exec] Validity: [From: Fri Aug 14 16:50:00 CEST 1998,
[exec] To: Thu Aug 15 01:59:00 CEST 2013]
[exec] Issuer: CN=GTE CyberTrust Root 5, OU="GTE CyberTrust Solutions, Inc.", O=GTE Corporation, C=US
[exec] SerialNumber: [ 01b6]
[exec]
[exec] Certificate Extensions: 4
[exec] [1]: ObjectId: 2.5.29.19 Criticality=true
[exec] BasicConstraints:[
[exec] CA:true
[exec] PathLen:5
[exec] ]
[exec]
[exec] [2]: ObjectId: 2.5.29.32 Criticality=false
[exec] CertificatePolicies [
[exec] [CertificatePolicyId: [1.2.840.113763.1.2.1.3]
[exec] [] ]
[exec] ]
[exec]
[exec] [3]: ObjectId: 2.5.29.15 Criticality=true
[exec] KeyUsage [
[exec] Key_CertSign
[exec] Crl_Sign
[exec] ]
[exec]
[exec] [4]: ObjectId: 2.5.29.14 Criticality=false
[exec] SubjectKeyIdentifier [
[exec] KeyIdentifier [
[exec] 0000: 76 0A 49 21 38 4C 9F DE F8 C4 49 C7 71 71 91 9D v.I!8L....I.qq..
[exec] ]
[exec] ]
[exec]
[exec] ]
[exec] Algorithm: [SHA1withRSA]
[exec] Signature:
[exec] 0000: 41 3A D4 18 5B DA B8 DE 21 1C E1 8E 09 E5 F1 68 A:..[...!......h
[exec] 0010: 34 FF DE 96 F4 07 F5 A7 3C F3 AC 4A B1 9B FA 92 4.......<..J....
[exec] 0020: FA 9B ED E6 32 21 AA 4A 76 C5 DC 4F 38 E5 DF D5 ....2!.Jv..O8...
[exec] 0030: 86 E4 D5 C8 76 7D 98 D7 B1 CD 8F 4D B5 91 23 6C ....v......M..#l
[exec] 0040: 8B 8A EB EA 7C EF 14 94 C4 C6 F0 1F 4A 2D 32 71 ............J-2q
[exec] 0050: 63 2B 63 91 26 02 09 B6 80 1D ED E2 CC B8 7F DB c+c.&...........
[exec] 0060: 87 63 C8 E1 D0 6C 26 B1 35 1D 40 66 10 1B CD 95 .c...l&.5.@f....
[exec] 0070: 54 18 33 61 EC 13 4F DA 13 F7 99 AF 3E D0 CF 8E T.3a..O.....>...
[exec] 0080: A6 72 A2 B3 C3 05 9A C9 27 7D 92 CC 7E 52 8D B3 .r......'....R..
[exec] 0090: AB 70 6D 9E 89 9F 4D EB 1A 75 C2 98 AA D5 02 16 .pm...M..u......
[exec] 00A0: D7 0C 8A BF 25 E4 EB 2D BC 98 E9 58 38 19 7C B9 ....%..-...X8...
[exec] 00B0: 37 FE DB E2 99 08 73 06 C7 97 83 6A 7D 10 01 2F 7.....s....j.../
[exec] 00C0: 32 B9 17 05 4A 65 E6 2F CE BE 5E 53 A6 82 E9 9A 2...Je./..^S....
[exec] 00D0: 53 0A 84 74 2D 83 CA C8 94 16 76 5F 94 61 28 F0 S..t-.....v_.a(.
[exec] 00E0: 85 A7 39 BB D7 8B D9 A8 B2 13 1D 54 09 34 24 7D ..9........T.4$.
[exec] 00F0: 20 81 7D 66 7E A2 90 74 5C 10 C6 BD EC AB 1B C2 ..f...t\.......
[exec]
[exec] ]|#] ...
</code></pre>
<div dir="ltr">
<br /></div>
<div dir="ltr">
There is a simple solution for it. </div>
<div dir="ltr">
<br /></div>
<div dir="ltr">
Just remove the certificate from the GlassFish keystore. Here is just a simple example used with GlassFish on my Windows developer box. It is slightly different when using a clustered GlassFish.<br />
<ol>
<li>Open a DOS command shell</li>
<li>Go to the directory $GLASSFISH_INSTALL/glassfish/domains/domain1/config</li>
<li>Type in the following command and execute it</li>
<pre style="background-image: URL(http://2.bp.blogspot.com/_z5ltvMQPaa8/SjJXr_U2YBI/AAAAAAAAAAM/46OqEP32CJ8/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> keytool -delete -alias gtecybertrust5ca -keystore cacerts.jks
</code></pre>
<li>In some cases you have to provide a password for the keystore. If you did not change that, it is the default GlassFish keystore password '<i>changeit</i>'.</li>
<li>You can verify whether the alias was deleted by executing the following command in a DOS shell</li>
<pre style="background-image: URL(http://2.bp.blogspot.com/_z5ltvMQPaa8/SjJXr_U2YBI/AAAAAAAAAAM/46OqEP32CJ8/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> keytool -list -keystore cacerts.jks > keytool.output
</code></pre>
<li>Opening the file <b>keytool.output</b> in an editor and doing a search for <b>gtecybertrust5ca</b> should yield an empty result set.</li>
</ol>
</div>
Ralfhttp://www.blogger.com/profile/01978624103770121257noreply@blogger.com0tag:blogger.com,1999:blog-2349279487799172166.post-72100662967688992362014-01-25T13:58:00.002+01:002014-01-25T13:59:24.204+01:00How to install Couch DB 1.5 on UbuntuA recent task I had to do on my home Ubuntu Linux box running 12.04. LTS was to install <a href="http://couchdb.apache.org/" target="_blank">CouchDB</a>. I needed it because I wanted to use <a href="http://acra.ch/" target="_blank">ACRA</a> as remote error reporting tool for Android Apps. Acra is completely open source (<a href="https://github.com/ACRA" target="_blank">hosted on GitHub</a>) and an incredible cool tool started by <a href="https://github.com/KevinGaudin" target="_blank">Kevin Gaudin</a>.<br />
<br />
I used to try it out using <a href="http://www.iriscouch.com/" target="_blank">Iris Couch</a> but it turns out for me that Iris Couch using the free of charge account is painful slow. Thus I decided to host my own CouchDB at home.<br />
<br />
The Ubuntu repositories doesn't host an up to date version of Couch DB. I tried it using apt-get and got CouchDB version 1.0.1. This was not a viable choice, because I wanted to use the replicate function of CouchDB which only is available on version higher than 1.2.<br />
<br />
I found a pretty good <a href="http://wiki.apache.org/couchdb/Installing_on_Ubuntu" target="_blank">step by step guide</a> in the Apache CouchDB wiki.<br />
To sum it up:<br />
<br />
I installed it by compiling it from source<br />
<br />
using the following steps.<br />
<br />
<ol>
<li>Download <a href="http://www.apache.org/dyn/closer.cgi?path=/couchdb/source/1.5.0/apache-couchdb-1.5.0.tar.gz" target="_blank">CouchDB 1.5 sources</a></li>
<li>Create a user and a group with name 'couchdb'. This is very important. Don't compile and install it with user 'root'. If you do it with root, CouchDB will not start nor write any error messages to any log file, because CouchDB will start under user 'couchdb' but all installed files and folders don't allow read or write access for any other user than 'root'. If you have compiled and installed it with user 'root' you have to adjust the permissions and owner rights of various files and folders by yourself. I have to admit that I did it with user 'root' the first time and it took me two hours to search for the causes and correct everything. So be warned ;-)</li>
<li>Install at least the following packages.</li>
<pre style="background-image: URL(http://2.bp.blogspot.com/_z5ltvMQPaa8/SjJXr_U2YBI/AAAAAAAAAAM/46OqEP32CJ8/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> sudo apt-get install -y g++
sudo apt-get install -y erlang-dev erlang-manpages erlang-base-hipe erlang-eunit erlang-nox erlang-xmerl erlang-inets
sudo apt-get install -y libmozjs185-dev libicu-dev libcurl4-gnutls-dev libtool
</code></pre>
<li>Extract and compile CouchDB using default installation directory /usr/local. You can change it by using a different --prefix when calling configure. Check manual.</li>
<pre style="background-image: URL(http://2.bp.blogspot.com/_z5ltvMQPaa8/SjJXr_U2YBI/AAAAAAAAAAM/46OqEP32CJ8/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> cd /tmp && tar xvzf apache-couchdb-1.5.0.tar.gz
cd apache-couchdb-*
./configure && make
</code></pre>
<li>Install CouchDB. CouchDB installs into /usr/local</li>
<pre style="background-image: URL(http://2.bp.blogspot.com/_z5ltvMQPaa8/SjJXr_U2YBI/AAAAAAAAAAM/46OqEP32CJ8/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> sudo make install
</code></pre>
<li>Sometimes it's necessary to remove old stuff from ubuntu packages. This was not necessary in my case. But you can do the following:</li>
<pre style="background-image: URL(http://2.bp.blogspot.com/_z5ltvMQPaa8/SjJXr_U2YBI/AAAAAAAAAAM/46OqEP32CJ8/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> sudo rm /etc/logrotate.d/couchdb /etc/init.d/couchdb
</code></pre>
<li>Install init scripts and logrotate</li>
<pre style="background-image: URL(http://2.bp.blogspot.com/_z5ltvMQPaa8/SjJXr_U2YBI/AAAAAAAAAAM/46OqEP32CJ8/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> sudo ln -s /usr/local/etc/logrotate.d/couchdb /etc/logrotate.d/couchdb
sudo ln -s /usr/local/etc/init.d/couchdb /etc/init.d
sudo update-rc.d couchdb defaults
</code></pre>
<li>Verify that CouchDB is running</li>
<pre style="background-image: URL(http://2.bp.blogspot.com/_z5ltvMQPaa8/SjJXr_U2YBI/AAAAAAAAAAM/46OqEP32CJ8/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> curl http://127.0.0.1:5984/
</code></pre>
It should give you an output like this:<br /><pre style="background-image: URL(http://2.bp.blogspot.com/_z5ltvMQPaa8/SjJXr_U2YBI/AAAAAAAAAAM/46OqEP32CJ8/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> {"couchdb":"Welcome","uuid":"5a23983ac768251e1c8d413bb52e67b5","version":"1.5.0","vendor":{"version":"1.5.0","name":"The Apache Software Foundation"}}
</code></pre>
<li>With this setup, CouchDB only listens on localhost (127.0.0.1). If you want CouchDB to listen on all interfaces and access it externally you have to configure it in /usr/local/etc/couchdb/local.ini<br />Just look for the [httpd] section and uncomment the line starting with 'bind_address' and replace 127.0.0.1 with 0.0.0.0</li>
<pre style="background-image: URL(http://2.bp.blogspot.com/_z5ltvMQPaa8/SjJXr_U2YBI/AAAAAAAAAAM/46OqEP32CJ8/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> [httpd]
;port = 5984
bind_address = 0.0.0.0
</code></pre>
<li>Now restart CouchDB and you are done.</li>
<pre style="background-image: URL(http://2.bp.blogspot.com/_z5ltvMQPaa8/SjJXr_U2YBI/AAAAAAAAAAM/46OqEP32CJ8/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> /etc/init.d/couchdb restart
</code></pre>
</ol>
You are also able to install a CouchDB version built by source alongside the default Ubuntu package. Check out the step by step guide mentioned above to look how this is being achieved.<br />
<br />Ralfhttp://www.blogger.com/profile/01978624103770121257noreply@blogger.com0tag:blogger.com,1999:blog-2349279487799172166.post-37557838748752088272014-01-02T17:31:00.003+01:002014-01-02T17:31:48.489+01:00Upgrading to Maven 3.1.1 caused Jenkins Maven Job to failAfter upgrading Maven on my Jenkins CI build server to version 3.1.1 (because the <a href="https://code.google.com/p/maven-android-plugin/" target="_blank">android-maven-plugin</a> version 3.8.2 needs it) I encountered problems with my Maven build jobs in Jenkins (version 1.544).<br />
The error message looks something like this:<br />
<br />
<pre style="background-image: URL(http://2.bp.blogspot.com/_z5ltvMQPaa8/SjJXr_U2YBI/AAAAAAAAAAM/46OqEP32CJ8/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> ERROR: Failed to parse POMs
...
...
...
Caused by: java.lang.ClassNotFoundException: org.apache.maven.cli.MavenLoggerManager
at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:50)
at org.codehaus.plexus.classworlds.realm.ClassRealm.unsynchronizedLoadClass(ClassRealm.java:259)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:235)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:227)
... 18 more
</code></pre>
<br />
Googling around it seems <a href="http://rel-eng-etc.blogspot.de/2013/10/jenkins-maven-jobs-fail-to-parse-poms.html" target="_blank">someone else</a> faced the same problem already. He also mentioned Jenkins issue <a href="https://issues.jenkins-ci.org/browse/JENKINS-15935" style="background-color: white; color: #888888; font-family: Arial, Helvetica, sans-serif; font-size: 13px; line-height: 18px; text-decoration: none;" target="_blank">JENKINS-15935</a> referring to that exact problem.<br />
The solution is to update the <a href="https://wiki.jenkins-ci.org/display/JENKINS/Maven+Project+Plugin" target="_blank">Maven Project Plugin</a> in Jenkins because the issue is fixed in Jenkins 1.509.<br />
As of version 2.0 of the plugin, it is released separately but still bundled with Jenkins. Though, it might be the case, that the newest version of the plugin isn't bundled always with the jenkins release.Ralfhttp://www.blogger.com/profile/01978624103770121257noreply@blogger.com0tag:blogger.com,1999:blog-2349279487799172166.post-37360980361246073712013-12-22T16:51:00.001+01:002013-12-22T16:51:34.153+01:00How to install Jira 6.0.6 on a QNAP TS-569 ProThe QNAP TS-569 Pro is a Intel Atom based NAS system. Therefore it should be no problem to run any Java based application on it.<br />
I managed to get JDK 7 up and running as well, so Jira should be possible too. I installed version 6.0.6, 32 bit edition, but newer versions should run as well.<br />
Keep in mind that the QNAP TS-569 Pro is running a 32 Bit Linux, despite the fact that the underlying architecture is 64 bit.<br />
I upgraded my RAM to 4GB because running Java server applications like Jira or Confluence need more than the stock 1GB.<br />
<br />
Assumptions:<br />
<br />
<ol>
<li>All commands are executed using a ssh connection (admin user) to the TS-569 Pro</li>
<li>I did not use a bash environment. Only the built in sh shell was used.</li>
<li>In general you don't need a separate installation of Java 6 or 7, because Jira comes with a bundled JRE 7. My NAS already had a JDK 7 installation with JAVA_HOME pointing to that location. But in principle this should not be necessary.</li>
<li>To configure the MySQL service I used the phpmyadmin QPKG installation</li>
<li>To make things a little bit easier for me and to have more Linux feeling I installed Optware IPKG </li>
</ol>
<div>
Brief installation instructions:</div>
<ol>
<li>Create an installation directory for Jira. I chose <b>/share/MD0_Data/Opt/jira</b> but this is totally free and up to you.</li>
<li>Download the <a href="http://www.atlassian.com/software/jira/downloads/binary/atlassian-jira-6.0.6-x32.bin" target="_blank">32 Bit installer version of Jira</a>. and save it to a folder on your NAS. It is a script which contains the complete Jira distribution. You don't have to extract anything manual. </li>
<li>Change into the directory where the downloaded file resides</li>
<li>If not already done make the script executable: <i>chmod +x atlassian-jira-6.0.6-x32.bin</i></li>
<li>Start the script by executing: <i>./atlassian-jira-6.0.6-x32.bin</i></li>
<li>You will get an error saying:<br /><span style="background-color: #fafaf8; color: #333333; font-family: 'LiHei Pro Medium', '儷黑 Pro', 'Microsoft JhengHei', 微軟正黑體, Arial, Helvetica, clean, sans-serif; font-size: 13px; line-height: 18.1875px; text-align: justify;">Sorry, but I could not find gunzip in path. Aborting</span></li>
<li>I found the solution for that problem <a href="http://forum.synology.com/enu/viewtopic.php?f=27&t=18362" target="_blank">in this forum post</a>:<br />The gunzip Version on the QNAP seems to be a different one than the script is expecting. The option -V is not recognized by the QNAP gunzip version.<br />So just load the script into an editor of your choice (I used the ipkg emacs version) and remove these lines from the script and save it afterwards:</li>
<pre style="background-image: URL(http://2.bp.blogspot.com/_z5ltvMQPaa8/SjJXr_U2YBI/AAAAAAAAAAM/46OqEP32CJ8/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> gunzip -V > /dev/null 2>&1
if [ "$?" -ne "0" ]; then
echo "Sorry, but I could not find gunzip in path. Aborting."
exit 1
fi
</code></pre>
<li>Start the script again and wait a couple of minutes (yes indeed, it took 2-3 minutes on my NAS)</li>
<li>The console installer starts after the script extracted the installation files and you can continue your Jira installation just like <a href="https://confluence.atlassian.com/display/JIRA/Installing+JIRA+on+Linux#InstallingJIRAonLinux-UsingtheConsoleWizard" target="_blank">described in the official Jira installation documentation</a>.</li>
<li>You may tweak the JVM settings in the <i>setenv.sh</i> file of your Jira installation to adjust memory settings.</li>
<li>That's it. The next thing would be to create start/stop scripts for the runlevels to make the Jira service start whenever the NAS is starting. This is stuff for one of the next articles.</li>
</ol>
Ralfhttp://www.blogger.com/profile/01978624103770121257noreply@blogger.com0tag:blogger.com,1999:blog-2349279487799172166.post-406395429958870812013-12-09T20:06:00.002+01:002013-12-09T20:11:55.220+01:00Useful Subversion pre-commit hook script for Linux serversLooking for useful subversion pre-commit hooks? Maybe this script is for you. It's a Linux bash shell script and makes also use of python.<br />
The script does the following:<br />
<br />
<ol>
<li>Checks whether the commit message is not empty</li>
<li>Checks whether the commit message consists of at least 5 characters</li>
<li>Checks if the committed files are UTF-8 compliant</li>
<li>Checks whether the svn:eol-style property is set to LF on newly added files</li>
<li>Checks if the committed files have no TAB characters</li>
</ol>
<ul>
</ul>
<div>
<br /></div>
<div>
The UTF-8 and TAB checks are performed on the following file suffixes</div>
<div>
<ul>
<li>*.java</li>
<li>*.js</li>
<li>*.xhtml</li>
<li>*.css</li>
<li>*.xml</li>
<li>*.properties (only check for TABs here, no check for UTF-8 compliance)</li>
</ul>
<div>
It should be easy to adjust those settings to your needs.</div>
</div>
<br />
<pre style="background-image: URL(http://2.bp.blogspot.com/_z5ltvMQPaa8/SjJXr_U2YBI/AAAAAAAAAAM/46OqEP32CJ8/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> #!/bin/bash
REPOS="$1"
TXN="$2"
# Make sure that the log message contains some text.
SVNLOOK=/usr/bin/svnlook
ICONV=/usr/bin/iconv
SVNLOOKOK=1
$SVNLOOK log -t "$TXN" "$REPOS" | \
grep "[a-zA-Z0-9]" > /dev/null || SVNLOOKOK=0
if [ $SVNLOOKOK = 0 ]; then
echo "Empty log messages are not allowed. Please provide a proper log message." >&2
exit 1
fi
# Comments should have more than 5 characters
LOGMSG=$($SVNLOOK log -t "$TXN" "$REPOS" | grep [a-zA-Z0-9] | wc -c)
if [ "$LOGMSG" -lt 6 ]; then
echo -e "Please provide a meaningful comment when committing changes." 1>&2
exit 1
fi
# Make sure that all files to be committed are encoded in UTF-8.
while read changeline;
do
# Get just the file (not the add / update / etc. status).
file=${changeline:4}
# Only check source files.
if [[ $file == *.java || $file == *.xhtml || $file == *.css || $file == *.xml || $file == *.js ]] ; then
$SVNLOOK cat -t "$TXN" "$REPOS" "$file" | $ICONV -f UTF-8 -t UTF-8 -o /dev/null
if [ "${PIPESTATUS[1]}" != 0 ] ; then
echo "Only UTF-8 files can be committed ("$file")" 1>&2
exit 1
fi
fi
done < <($SVNLOOK changed -t "$TXN" "$REPOS")
# Check files for svn:eol-style property
# Exit on all errors.
set -e
EOL_STYLE="LF"
echo "`$SVNLOOK changed -t "$TXN" "$REPOS"`" | while read REPOS_PATH
do
if [[ $REPOS_PATH =~ A[[:blank:]]{3}(.*)\.(java|css|properties|xhtml|xml|js) ]]
then
if [ ${#BASH_REMATCH[*]} -ge 2 ]
then
FILENAME=${BASH_REMATCH[1]}.${BASH_REMATCH[2]};
# Make sure every file has the right svn:eol-style property set
if [ $EOL_STYLE != "`$SVNLOOK propget -t \"$TXN\" \"$REPOS\" svn:eol-style \"$FILENAME\" 2> /dev/null`" ]
then
ERROR=1;
echo "svn ps svn:eol-style $EOL_STYLE \"$FILENAME\"" >&2
fi
fi
fi
test -z $ERROR || (echo "Please execute above commands to correct svn property settings. EOL Style LF must be used!" >& 2; exit 1)
done
# Block commits with tabs
# This is coded in python
# Exit on all errors
set -e
$SVNLOOK diff -t "$TXN" "$REPOS" | python /dev/fd/3 3<<'EOF'
import sys
ignore = True
SUFFIXES = [ ".java", ".css", ".xhtml", ".js", ".xml", ".properties" ]
filename = None
for ln in sys.stdin:
if ignore and ln.startswith("+++ "):
filename = ln[4:ln.find("\t")].strip()
ignore = not reduce(lambda x, y: x or y, map(lambda x: filename.endswith(x), SUFFIXES))
elif not ignore:
if ln.startswith("+"):
if ln.count("\t") > 0:
sys.stderr.write("\n*** Transaction blocked, %s contains tab character:\n\n%s" % (filename, ln))
sys.exit(1)
if not (ln.startswith("@") or \
ln.startswith("-") or \
ln.startswith("+") or \
ln.startswith(" ")):
ignore = True
sys.exit(0)
EOF
# All checks passed, so allow the commit.
exit 0
</code></pre>
Ralfhttp://www.blogger.com/profile/01978624103770121257noreply@blogger.com0tag:blogger.com,1999:blog-2349279487799172166.post-59102563249455878842013-11-08T23:59:00.002+01:002013-11-08T23:59:41.139+01:00Hit Ctrl+F9 in Intellij IDEA when JRebel does not work as expectedOften the solution for a problem is so damn easy when you know the cause of the problem ...<br />
Intellij IDEA doesn't have an autocompile feature similar to Eclipse. So if you want your new code to be generated as a class file you have to hit Ctrl+F9 manually.<br />
Well, the same is true when using JRebel. This great piece of software can only detect a change in a class file if the changed class file is generated by a compiler first.<br />
So in case you are using IDEA in conjunction with JRebel and you wonder, why the heck this new code isn't replaced by JRebel on the fly you must hit Ctrl+F9 to generate a new class version and to trigger JRebel afterwards.<br />
<br />
One other thing to keep in mind when working with WAR or EAR artifacts in IDEA is to deploy those artifacts as exploded ones!<br />
<br />
<br />Ralfhttp://www.blogger.com/profile/01978624103770121257noreply@blogger.com0tag:blogger.com,1999:blog-2349279487799172166.post-1442060353413946102013-10-07T13:13:00.000+02:002013-10-07T13:13:06.055+02:00Installing Android 4.3 OTA Update on rooted Nexus 7Ok, the 4.3 OTA update is out now for a few months, but I didn't find the time to do the update on my rooted Nexus 7 device.<br />
Another reason for the delay was the fact, that the <a href="http://forum.xda-developers.com/showthread.php?t=1809195" target="_blank">Nexus 7 Toolkit</a> wasn't released until a few weeks ago. My Nexus 7 already showed me the information that a new update was downloaded and ready to install.<br />
Well, finally I decided to do the install (making a full Nandroid backup prior to the update), but when hitting the button "Reboot and Install" nothing happened.<br />
Usually after waiting 10 seconds the device should reboot and install the update, but the reboot did not occur. My battery wasn't the problem, because it was almost fully charged.<br />
First thing coming to my mind was to flash back the stock recovery. Unfortunately that didn't solve the problem.<br />
The next thing I did was do hit the button "Delete data" of the app "Google Service Framework". This usually forces the system to reset the update state and check for newly available system updates.<br />
And this did the trick. Clicking on "System Updates" the device told me that it was uptodate with a last check date of January 1st, 1970. So I manually hit the button to check for new updates and my device started to download a fresh copy of the 4.3 stock rom.<br />
Now hitting the button "Reboot and Install" rebooted the device and installed the Android 4.3 update.Ralfhttp://www.blogger.com/profile/01978624103770121257noreply@blogger.com0tag:blogger.com,1999:blog-2349279487799172166.post-31845909232170498162013-09-11T22:42:00.001+02:002013-09-11T22:42:39.131+02:00Pitfalls installing wordpress on a Linux box using Multisite with sub directoriesThis post is not about installing wordpress on a Linux box. It just covers two problems I have faced when installing wordpress 3.6 on my Ubuntu 12.04 box at home.<br />
I did install wordpress using the distributed zip archive following <a href="http://codex.wordpress.org/Installing_WordPress#Detailed_Instructions" target="_blank">the detailed instructions</a> on the wordpress site. Setting up the database and editing the PHP config files was no problem.<br />
The installation went smooth and everything was working as expected.<br />
<br />
<h3>
Problem 1: Configuring Multisite</h3>
Multisite is a great feature of wordpress. It gives you the ability to create more than one site (or blog) within your wordpress installation.<br />
I did the setup using <a href="http://codex.wordpress.org/Create_A_Network" target="_blank">this step-by-step guide</a>. So far so good. With my new multisite feature enabled I wanted to create a new site and filled in the necessary informations for it. The creation succeeded without an error and when I clicked on the dashboard of the newly created site I got a "Page Not Found" error.<br />
Hm ... googling around I didn't really find a good answer.<br />
I decided to check the <a href="http://codex.wordpress.org/Multisite_Network_Administration" target="_blank">network administration guide</a> of the wordpress documentation and found a really <a href="http://codex.wordpress.org/Multisite_Network_Administration#Apache_Virtual_Hosts_and_Mod_Rewrite" target="_blank">helpful paragraph about</a> using mod_rewrite (multisite feature needs mod_rewrite) and Apache Virtual Hosts.<br />
My Apache installation is using virtual hosts so what finally did the trick was to add these lines to my VirtualHost section:<br />
<br />
<br />
<pre style="background-image: URL(http://2.bp.blogspot.com/_z5ltvMQPaa8/SjJXr_U2YBI/AAAAAAAAAAM/46OqEP32CJ8/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> <VirtualHost *:80>
<Directory /var/www/vhosts/wordpress>
AllowOverride Fileinfo Options
</Directory>
</code></pre>
<br />
<h3>
Problem 2: Changing the domain name (or change the URL)</h3>
I am using DynDNS and I (and my users) want to access the wordpress installation from the internet. During the installation I did not realize that this was so important, because I thought I can change it easily afterwards. Well, changing it in a Non-Multisite environment is easy, but it turns out that a change of the domain name in a multisite installation is a little bit harder.<br />
What helped me a lot <a href="http://codex.wordpress.org/Moving_WordPress#Moving_WordPress_Multisite" target="_blank">was this documentation</a> on the wordpress site.<br />
Because my installation was totally fresh I skipped the step to make a backup of my database. I walked through all tables of the database and replaced every occurrence of my old domain name with the new DynDNS domain name.<br />
Finally I changed the DOMAIN_CURRENT_SITE attribute in the wp-config.php file to point to the DynDNS name as well and after that my multisite wordpress installation was accessible via the DynDNS url.<br />
<br />
I can't say whether it would have been easier to change the domain name before I activated the multisite feature, but it would make sense to me.<br />
<br />
Anyway, it works now.Ralfhttp://www.blogger.com/profile/01978624103770121257noreply@blogger.com0tag:blogger.com,1999:blog-2349279487799172166.post-40169257272418188992013-07-04T18:00:00.000+02:002013-07-04T18:00:01.087+02:00Referencing a Derby database column with a reserved name using DBUnit<a href="http://www.dbunit.org/" target="_blank">DBUnit</a> is a pretty good tool to achieve reproducible results when unit testing your code. It puts your database in a known state before each test run.<br />
In my case I use JPA with Hibernate as implementation to create the DB schema before each test run. Furthermore I use an embedded in-memory Derby database.<br />
<br />
I ran into problems when inserting dbunit datasets into the created schema. A column was named <b>interval </b>which is a reserved word in Derby.<br />
<br />
No problem I thought, when escaping the column name (using ' or " ticks) the problem would be solved. Well it turns out to be not that simple :-(<br />
<br />
The solution is to set a DBUnit related property/feature to tell DBUnit how to config and use the underlying database. Here is the relevant code snippet<br />
<br />
<pre style="background-image: URL(http://2.bp.blogspot.com/_z5ltvMQPaa8/SjJXr_U2YBI/AAAAAAAAAAM/46OqEP32CJ8/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> IDatabaseConnection memDbConnection = new DatabaseDataSourceConnection(
(InitialContext) context, DEFAULT_DATASOURCE);
DatabaseConfig dbConfig = memDbConnection.getConfig();
dbConfig.setProperty(DatabaseConfig.PROPERTY_DATATYPE_FACTORY, new DefaultDataTypeFactory());
dbConfig.setProperty(DatabaseConfig.PROPERTY_ESCAPE_PATTERN, "\"?\"");
</code></pre>
<br />
<br />
The line<br />
<pre style="background-image: URL(http://2.bp.blogspot.com/_z5ltvMQPaa8/SjJXr_U2YBI/AAAAAAAAAAM/46OqEP32CJ8/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;">dbConfig.setProperty(DatabaseConfig.PROPERTY_DATATYPE_FACTORY, new DefaultDataTypeFactory());</code></pre>
<br />
tells DBUnit to use the default data type factory which works well with Derby. You don't have to set this property explicitly when using Derby.<br />
<br />
The second line<br />
<pre style="background-image: URL(http://2.bp.blogspot.com/_z5ltvMQPaa8/SjJXr_U2YBI/AAAAAAAAAAM/46OqEP32CJ8/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;">dbConfig.setProperty(DatabaseConfig.PROPERTY_ESCAPE_PATTERN, "\"?\""); </code></pre>
<br />
solved my issue. You have to explicitly declare an escape pattern. In my case this was "\"?"".<br />
With default settings DBUnit uses <b>no escape pattern</b>.<br />
<br />
Using this solution, a clean insert into the database with a column that uses a reserved name works as expected.Ralfhttp://www.blogger.com/profile/01978624103770121257noreply@blogger.com1tag:blogger.com,1999:blog-2349279487799172166.post-37823471441780564922013-06-26T17:30:00.000+02:002013-06-27T09:37:46.795+02:00Howto create a DB field with a reserved name using Hibernate and JPAI stumbled upon this problem when I switched from a SQLServer 2008 database to a MySQL database 5.5 using Hibernate in Version 3.6.6 with JPA implementation 2.0.<br />
<br />
<h3>
The goal</h3>
Generating a MySQL database schema or updating a database schema automatically using Hibernate's <b>hbm2ddl.auto</b> feature.<br />
<br />
<h3>
The problem</h3>
Using SQLServer for a long time everything worked fine. When switching to MySQL the schema generation failed. In particular, one single table was not created and I couldn't find a hint in Hibernate's log statements.<br />
<br />
<h3>
The solution </h3>
My persistence.xml file uses the auto update of a database schema using this property<br />
<br />
<property name="hibernate.hbm2ddl.auto" value="update" /><br />
<br />
So far so good. Nothing special here.<br />
I changed the Hibernate dialect to use the MySQL dialect (org.hibernate.dialect.MySQLDialect) and when deploying the application it generates the database schema and it should populate the database with default values. When populating starts it immediately fails with the following Hibernate error message:<br />
<br />
<i>"You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'interval) values (0, '10', 9, 4, 7, 1)' at line 1"</i><br />
<br />
After a few minutes it came to my mind that the column name "interval" might be a keyword in MySQL. So googling around I found out that I was right. "interval" is a keyword in MySQL (but not in SQLServer).<br />
<br />
Ok, reason found. But what is the best way to fix this issue?<br />
Stackoverflow is your friend :-)<br />
Just <a href="http://stackoverflow.com/questions/2224503/creating-field-with-reserved-word-name-with-jpa" target="_blank">read this answer</a> from Stackoverflow and you are done.<br />
<br />
To summarize shortly:<br />
With Hibernate as JPA 1.0 provider you have to annotate the entity field with enclosing backticks like this:<br />
<br />
<pre class="default prettyprint prettyprinted"><code><span class="lit">@Column</span><span class="pun">(</span><span class="pln">name</span><span class="pun">=</span><span class="str">"`interval`"</span><span class="pun">)</span></code></pre>
<pre class="default prettyprint prettyprinted"><code><span class="pun"> </span></code></pre>
and when using JPA 2.0 the syntax was standardized you have to escape the column name like this<br />
<br />
<pre class="default prettyprint prettyprinted"><code><span class="lit">@Column</span><span class="pun">(</span><span class="pln">name</span><span class="pun">=</span><span class="str">"\"interval\""</span><span class="pun">)</span></code></pre>
<br />
This is mentioned in chapter 2.13 (Naming of database objects) of the JPA 2.0 specification:<br />
<br />
<i>"It is possible to specify on a per-name basis that a name for a database object is to be inter-<br />preted as a delimited identifier as follows:<br />• Using annotations, a name is specified as a delimited identifier by enclosing the name<br />within double quotes, whereby the inner quotes are escaped, e.g.,<br />@Table(name="\"customer\"").<br />• When using XML, a name is specified as a delimited identifier by use of double<br />quotes, e.g.,<br /><table name="&quot;customer&quot;"/>"</i><br />
<br />
Using the first (but deprecated) solution you can force Hibernate to quote an identifier in the generated SQL by enclosing the table or column name in backticks in the mapping document. Hibernate will use the correct quotation style for the SQL Dialect. This is usually double quotes, but the SQL Server uses brackets and MySQL uses backticks.<br />
<br />
The second solution is the modern and standardized way of forcing your JPA 2.0 and above provider to quote the identifier.Ralfhttp://www.blogger.com/profile/01978624103770121257noreply@blogger.com0tag:blogger.com,1999:blog-2349279487799172166.post-35890843859625287102013-06-23T21:55:00.003+02:002013-06-23T21:56:24.683+02:00Lösung für "mit Windows Update kann derzeit nicht nach Updates gesucht werden"Wer unter einem Windows 7 (64 Bit) die Funktion "Nach Updates suchen" ausführt und obige Fehlermeldung bekommt fängt erstmal an zu googeln.<br />
Das Problem sollte eigentlich relativ einfach zu beheben sein - dachte ich.<br />
Nun, es gibt diverse Antworten zu dem Problem:<br />
<ul>
<li><a href="http://h30492.www3.hp.com/t5/Notebook-Betriebssysteme-und-Software/mit-Windows-Update-kann-derzeit-nicht-nach-Updates-gesucht/td-p/71651" target="_blank">Dieser Eintrag</a></li>
<li><a href="http://dischue.de/2012/10/windows-update-reparieren/" target="_blank">Oder dieser Eintrag</a></li>
<li><a href="http://www.borncity.com/blog/2011/12/27/mshelper-de-abgeschaltet-windows-update-reparatur-gefllig/" target="_blank">oder dieser Eintrag</a></li>
</ul>
Der letzte Eintrag erwähnt auch das Werkzeug winUpdRestore!v28.exe, welches allerdings mit einem Link in SkyDrive ins Leere läuft.<br />
<a href="http://support.microsoft.com/kb/971058" target="_blank">Die FixIt Lösung</a> von Microsoft hat bei mir nicht funktioniert. Viele Blogeinträge erwähnten jedoch die erfolgreiche Behebung des Problems beim Einsatz des Tools winUpdRestore!v28.exe.<br />
<br />
Leider ist dieses Tool so gut wie gar nicht im Web aufzutreiben. Ich habe es dann doch auf <a href="http://www.pctipp.ch/tipps-tricks/kummerkasten/windows-7/artikel/windows-updates-updates-werden-konfiguriert-64373/" target="_blank">dieser Webseite</a> gefunden.<br />
<br />
Da ich hoffe, dass dieser Blogartikel auch schnell im Google Index auftaucht, gebe ich hier zwei funktionierende Links für diese Datei an:<br />
<br />
<ol>
<li><a href="https://www.dropbox.com/s/n40u1jzphk3bsgs/winUpdRestore!v28.zip">https://www.dropbox.com/s/n40u1jzphk3bsgs/winUpdRestore!v28.zip</a></li>
<li><a href="https://dl.dropboxusercontent.com/u/27481342/winUpdRestore!v28.zip">https://dl.dropboxusercontent.com/u/27481342/winUpdRestore!v28.zip</a></li>
</ol>
Das Tool ist kein offizielles Microsoft Produkt und Microsoft wird seine Gründe haben, warum das Werkzeug nicht mehr zu bekommen ist. Bei mir hat das Tool aber das Problem behoben. Ralfhttp://www.blogger.com/profile/01978624103770121257noreply@blogger.com0tag:blogger.com,1999:blog-2349279487799172166.post-47417511850432631222013-05-22T16:28:00.004+02:002013-05-23T09:19:58.380+02:00Essential resources when building Android Apps using Maven (and Eclipse)If you plan to build your Android application on a build server like Jenkins, Hudson, etc ... you should switch from building your project with your IDE (in my case Eclipse) to a build system like Maven or Gradle.<br />
<br />
I tried Gradle (using the new Gradle Build export in Eclipse ADT plugin) because the new <a href="http://developer.android.com/sdk/installing/studio.html" target="_blank">Android Studio</a> preview release by Google supports Gradle builds, but was totally disappointed by the poor performance of Gradle on my Jenkins CI build server. So I decided to use maven instead and found out about these resources which you have to read and understand:<br />
<br />
<ol>
<li><a href="https://code.google.com/p/maven-android-plugin/" target="_blank">Maven Android Plugin</a>: <br />You need the plugin to build android projects using maven. With Android API 17 the latest stable release 3.5.3 doesn't work. You have to <a href="https://github.com/jvoegele/gradle-android-plugin" target="_blank">pull the plugin's source from GitHub</a> and build version 3.5.4-SNAPSHOT by yourself.</li>
<li><a href="https://github.com/mosabua/maven-android-sdk-deployer" target="_blank">Android SDK Deployer</a>:<br /><i>"Typically artifacts are available in Maven Central, however only the platform versions available in the Android Open Source Project are published to Maven Central. Newer versions of the platform as well as the compatibility package and proprietary extensions like the Google Maps support are not available there and need to be published to your Maven repository, if you want to use them in your Android project.<br />The artifacts published to Maven central are available as dependencies under the groupId com.google.android with the artifactId android and android-test.<br />The Maven Android SDK Deployer has been created to publish artifacts from the Android SDK into your local repository or repository server when using components that are not available in Central."</i><br /><br />I have taken <a href="http://books.sonatype.com/mvnref-book/reference/android-dev-sect-config-build.html" target="_blank">this from the online book Maven - The Complete Reference</a> by Sonatype.<br />With Android API 17 you might run into the same bug like described above. So before building this project you must build version 3.5.4-SNAPSHOT of the Maven Android Plugin</li>
<li><a href="http://rgladwell.github.io/m2e-android/" target="_blank">m2e-android</a>:<br />In case you use Eclipse, you can use this m2e plugin to add maven support to your Eclipse Android project.</li>
</ol>
Ralfhttp://www.blogger.com/profile/01978624103770121257noreply@blogger.com0tag:blogger.com,1999:blog-2349279487799172166.post-5168672021226080012013-05-20T01:19:00.004+02:002013-05-20T01:19:52.297+02:00Install Android Tools on Ubuntu 12.04.<a href="http://bernaerts.dyndns.org/linux/245-ubuntu-precise-install-android-sdk" target="_blank">Check this blog</a> when you have to install Android SDK on Ubuntu 12.04. It simply works!Ralfhttp://www.blogger.com/profile/01978624103770121257noreply@blogger.com0tag:blogger.com,1999:blog-2349279487799172166.post-31567961364727225552013-04-18T17:27:00.002+02:002013-04-18T17:27:50.728+02:00VirtualBox - Let Host-Only mode access the internetIn an <a href="http://qupera.blogspot.de/2012/12/networking-modes-in-virtualbox-explained.html" target="_blank">earlier post I described networking</a> modes in VirtualBox. Combining those modes you'll get some kind of swiss knife in realizing somehow exotic networking modes in your VMs.<br />
What if you want your VM that is configured for Host-Only mode access the internet?<br />
Port forwarding using NAT is an option. But for me that sounded to complicated. I had the following requirements:<br />
<ol>
<li>The host should be able to access services like Apache or GlassFish on the guests (the virtual machine)</li>
<li>The guests should be able to access the outside world (intranet/internet)</li>
<li>The guests should be able to talk to each other using fixed IP adresses</li>
<li>The host should be able to talk to the guests using fixed IP adresses</li>
</ol>
A working solution for these requirements <a href="http://geert.vanderkelen.org/virtualbox-give-host-only-access-to-internet/" target="_blank">is described in this blog article</a>.Ralfhttp://www.blogger.com/profile/01978624103770121257noreply@blogger.com0tag:blogger.com,1999:blog-2349279487799172166.post-10936115342692543862013-03-10T14:26:00.000+01:002013-03-10T14:26:56.163+01:00Using symbolic links under WindowsSince Windows Vista it is possible to use symbolic links just like you know it under Linux/Unix systems.<br />
Warning: You have to use the command line to use this tool ;-)<br />
The syntax is as follows:<br />
<br />
<pre style="background-image: URL(http://2.bp.blogspot.com/_z5ltvMQPaa8/SjJXr_U2YBI/AAAAAAAAAAM/46OqEP32CJ8/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> mklink [[/d] | [/h] | [/j]] <Link> <Target>
</code></pre>
<br />
Most of the time I use it with the /d option. This lets the link point to a directory.Ralfhttp://www.blogger.com/profile/01978624103770121257noreply@blogger.com0tag:blogger.com,1999:blog-2349279487799172166.post-59363737389935869762013-02-17T22:57:00.004+01:002013-02-18T10:22:04.826+01:00Fixing poor performance (lagging) on Samsung Galaxy Nexus GSM (i9250) phonesWoohoo, I can't believe it. My Galaxy Nexus phone is affected <a href="http://forum.xda-developers.com/showthread.php?p=35020486#post35020486">by a bug which causes the phone to slow down</a> and to behave very laggy after a while. Some users reported this might happen when they uploaded or downloaded huge files (e.g. movies).<br />
I can't tell whether huge files caused this problem on my Galaxy Nexus, but from one day to another the phone was reacting very slow. It was no longer usable for me. Typing a single character on the keyboard was a pain in the ass ...<br />
I started to google around and <a href="http://forum.xda-developers.com/showthread.php?p=35020486#post35020486">found this posting</a> on XDA which saved my phone's life ;-)<br />
If you are experiencing the same behavior on your Galaxy Nexus you might consider following the steps there. But be careful not to <b>HARD BRICK</b> your phone, because your phone must have a special chipset.<br />
My phone was produced in 08/2012 and really has the "suspicious" <b style="background-color: white; color: #222225; font-family: Arial, Helvetica, sans-serif; font-size: 13px;">V3U00M</b> chipset mentioned in the XDA posting. I checked it using the <a href="https://play.google.com/store/apps/details?id=net.vinagre.android.emmc_check&hl=de">eMMC Brickbug Check app</a> from the play store.<br />
If your phone is not rooted you can't fix the problem. Either you root it now, or you send it to Samsung and let them repair/swap it. It's up to you.<br />
The next thing to do was to run the <a href="https://play.google.com/store/apps/details?id=com.grilledmonkey.lagfix">LagFix (fstrim) free app</a> or paid version. I now use the paid version, because it has a built in scheduler which runs fstrim every night.<br />
The script mentioned in the posting isn't necessary if you use the paid version of LagFix.<br />
After running the LagFix app my phone was reacting as fast as on the day I bought it and it remains fast until now.<br />
<br />Ralfhttp://www.blogger.com/profile/01978624103770121257noreply@blogger.com0tag:blogger.com,1999:blog-2349279487799172166.post-13884485579018758652013-02-07T18:30:00.000+01:002013-02-07T18:30:01.558+01:00Multi Line Table Cells in Vaadin 6I had a hard time figuring out how to wrap content in a table cell using Vaadin 6.7.<br />
Content in row headers can be forced to wrap using a simple "<br/>" tag in the string. Unfortunately it isn't that simple with non-header cells.<br />
I found a working solution in this <a href="https://vaadin.com/forum/-/message_boards/view_message/1389905#_19_message_154531">Vaadin forum post</a>.<br />
You simply have to create your own CSS stylesheet definition and add the following code to it:<br />
<br />
<pre style="background-image: URL(http://2.bp.blogspot.com/_z5ltvMQPaa8/SjJXr_U2YBI/AAAAAAAAAAM/46OqEP32CJ8/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> .v-table-cell-wrapper {
white-space: normal;
}
</code></pre>
<br />Ralfhttp://www.blogger.com/profile/01978624103770121257noreply@blogger.com2tag:blogger.com,1999:blog-2349279487799172166.post-2366631809685145782013-02-05T18:00:00.000+01:002013-02-18T10:21:23.243+01:00Howto compress and uncompress a Java byte array using JDK Deflater/InflaterIf you ever came across the requirement to store binary data somewhere (e.g. filesystem or database) it might be handy to compress those data.<br />
Besides the common ZIP algorithm Java offers the <a href="http://docs.oracle.com/javase/6/docs/api/java/util/zip/Deflater.html">Deflater</a> and <a href="http://docs.oracle.com/javase/6/docs/api/java/util/zip/Inflater.html">Inflater</a> classes that uses the ZLIB compression library. ZLIB is part of the PNG standard and not protected by any patents.<br />
Here is a small code snippet which shows an utility class that offers two methods to compress and extract a Java byte array. <br />
<br />
<pre style="background-image: URL(http://2.bp.blogspot.com/_z5ltvMQPaa8/SjJXr_U2YBI/AAAAAAAAAAM/46OqEP32CJ8/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> package de.qu.compression.demo;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;
import java.util.Map;
import java.util.zip.DataFormatException;
import java.util.zip.Deflater;
import java.util.zip.Inflater;
public class CompressionUtils {
private static final Logger LOG = Logger.getLogger(CompressionUtils.class);
public static byte[] compress(byte[] data) throws IOException {
Deflater deflater = new Deflater();
deflater.setInput(data);
ByteArrayOutputStream outputStream = new ByteArrayOutputStream(data.length);
deflater.finish();
byte[] buffer = new byte[1024];
while (!deflater.finished()) {
int count = deflater.deflate(buffer); // returns the generated code... index
outputStream.write(buffer, 0, count);
}
outputStream.close();
byte[] output = outputStream.toByteArray();
deflater.end();
LOG.debug("Original: " + data.length / 1024 + " Kb");
LOG.debug("Compressed: " + output.length / 1024 + " Kb");
return output;
}
public static byte[] decompress(byte[] data) throws IOException, DataFormatException {
Inflater inflater = new Inflater();
inflater.setInput(data);
ByteArrayOutputStream outputStream = new ByteArrayOutputStream(data.length);
byte[] buffer = new byte[1024];
while (!inflater.finished()) {
int count = inflater.inflate(buffer);
outputStream.write(buffer, 0, count);
}
outputStream.close();
byte[] output = outputStream.toByteArray();
inflater.end();
LOG.debug("Original: " + data.length);
LOG.debug("Uncompressed: " + output.length);
return output;
}
}
</code></pre>
<br />
It is also possible to receive better compression results by calling the method <a href="http://docs.oracle.com/javase/6/docs/api/java/util/zip/Deflater.html#setLevel%28int%29">setLevel</a> of the Deflater class and specify the constant <a href="http://docs.oracle.com/javase/6/docs/api/java/util/zip/Deflater.html#BEST_COMPRESSION">Deflater.BEST_COMPRESSION</a>.Ralfhttp://www.blogger.com/profile/01978624103770121257noreply@blogger.com3