Java applet not working after refresh

I had a funny problem with my java applet in web start application - it worked every second time I refreshed web page.

After a little debug I found out that java machine didn’t make it in time to shutdown, start and show applet.

Solution was rather fun:

1
<param name="separate_jvm" value="true" />

It helped because now new instance off applet launched in a new JVM, simultaneously with closing old instance of applet in old JVM.

But be careful if your applet writes something to user disk or etc - both old and new instance can be doing is for a little time!

Invalid signature file digest for Manifest main attributes

Today i run into error

Invalid signature file digest for Manifest main attributes
while running my java web start applet.

I wondered for a while and finally found the reason - yesterday I modified my .pfx key for signing applet, but manifests in jars merge with each other - so I really had jar with invalid digest.

To fix it, I just had to remove META-INF folder from all my jars, add them manifest again and re-sign them. You can remove it with any archiver - for example, with 7-zip.

Warning: The signer`s certificate chain is not validated

I had a week of trouble, signing my web start java applet.

While I signed (with a good COMODO code signing certificate), there was

**Warning: The signer's certificate chain is not validated.**
But I didn't pay much attention to it.

And my signed applet appeared to be of unknown publisher even through “Show details” in browser showed me that applet is signed with the correct certificate. Of cause, it was much restricted - and I need to read user disc, etc… It could be solved my directly installing CA to user computer - but that’s unreasonable to request every user to do it manually. So I suffered for a week and suddenly came up with a solution, inspired by this post (thank you, Supriya Roy):

  1. Install your .pfx certificate with the “Mark this key as exportable. This will allow you to back up or transport your keys at a later time” and “Include all extended properties” checked.

  2. Check that that you have full certificate chain for this certificate and it is valid. Otherwise, install neccessary CA.

  3. Export the installed certificate with “Yes, export the private key” option and “Include all certificates in the certification path if possible” and “Export all extended properties” checked under the option .PFX or PKCS #12.

  4. Use exported .pfx file to sign the JAR. Don’t forget that it could change alias - get new one with

    keytool.exe -list -keystore D:\keys\code.pfx -storetype pkcs12

Worked like magic - warning disappeared and my jars are trusted now!

Немного про разработку

Решил утащить на память к себе две чудесные статьи, которые полностью описывают моё отношение к разработке. Из первой я несогласен только с одним абзацем - который говорит про невозможность работы с неработающим кодом.

OracleToGit: released!

At last, I released a useful tool for Oracle DBAs - a special customizable script which helps you to store database DDL (views, tables, package code…) in Git repositary so that you can always see history of object’s changes.

Have fun!

Oracle To Git

Мир Тьмы: Белоснежка

Спрятавшись за поваленным деревом, мы с ужасом смотрели, как стекло меняется под его пальцами. Там, где он прикасался, оставались жирные отпечатки, и оно темнело, становясь обычным хрупким материалом. Пролетевшая мимо разноцветная птица упала на землю, став серым воробьём. Мы услышали, как стекло хрустит под собственной тяжестью….

Снежная королева - киберсказка

Герда задумчиво догрызала грязный ноготь на указательном пальце правой руки. Увы, остальные уже закончились, а ожидание казалось нестерпимым. Её старый компьютер громко выл кулерами, компилируя простой низкоуровневый код. От потоков воздуха, которые разогревались, проходя сквозь раскалённый до 90 градусов процессор, заметно шевелились засаленные жалюзи. Свет в комнате периодически помаргивал, и она лишний раз порадовалась тому, что несколько дней назад всё же отдала несколько новых йен за старый, но кое-как отремонтированный и всё же работающий стабилизатор напряжения. Меньше всего ей бы хотелось повторять всё заново… Она отрывисто вздохнула и не глядя вытащила ещё одну сигарету из помятой пачки.

Set up Centreon SMS notifications with Android smartphone

This small tutorial will show how to send centreon notifications via SMS with Android smartphone. It is made for android 2.3 gingerbread and using android 4 may be easier. But cheap android smartphones use 2.3 now…

You will need:

  1. Configured nagios with centreon.
  2. Rooted Android smartphone with installed busybox and SD card, connected to centreon server via USB.
  3. Minimum programming and Linux skills.

How it works:

  1. Centreon writes notification log in JSON to phone card.
  2. Persistent service on android smartphone reads JSON, composes a messages and sends it.

Step by step guide:

Share Android SD card with PC via USB on gingerbread using mass storage device protocol

Android 4 already has MTP (Media Transfer Protocol), but sometimes you need to use android 2.3. We use it for sending SMS notofications - it’s simple and cheap.

To share SD card to both PC and Android, you need a rooted phone and a dirty hack. So here it is:

  1. Enter device console on android device (via ADB, ssh, terminal emulator, etc)
  2. issue “mount” command - it will show you all currently mounted devices.
  3. There you’ll see smth like
    /dev/block/vold/179:1 /mnt/sdcard vfat 
    Remember it.
  4. plug your device into computer, select file transfer mode.
  5. In device console, enter smth like
    mount -r -t vfat /dev/block/vold/179:1 /mnt/sdcard
  6. Your SD card is mounted on your android device in read only mode (-r flag), you are wonderful!

You can probably mount in writable mode but it can be dangerous.

If you need to use this mount often, you can create another mount point (which is always -r connected with SD card), or write a software button which mounts it.

Here’s a sample of my mounting program (works for samsung galaxy mini): https://github.com/jehy/mount_sd Feel free to use and to fork.