Tuesday, May 24. 2011
Sound Issue in Linux Adobe Flash
Another quick entry this time. Some months ago I started to watch dexter via streaming, but the past week I noticed the sound was very garbled and strange. My streaming site uses (in my linux user opinion) the annoying adobe flash plugin. Being very busy these days I just found the debian associated bug but, at that moment, it solved nothing. Today I have rechecked it and a user comment links to another adobe bug. It explains that the plugin is using memcpy instead of memmove. And if man pages are consulted it is clear what is going on:
The memcpy() function copies n bytes from memory area src to memory area dest. The memory areas should not overlap. Use memmove(3) if the memory areas do overlap.
Last glibc upgrade has got this sound issue out (you know I have a thing about upgrading my debian box). If you follow the previous adobe link there is a solution from a Russian page. It seems the memcpy function has been binary replaced by memmove (I did not know it was even possible). In my debian box the solution is very similar to the explained by the Russian mate. Please be aware of the fact that you are trusting in a binary change done by this guy (you know, desperate times call for desperate measures).
# wget http://catap.ru/patches/flash64/memcpy-10.3.162.29.bsdiff # cp /usr/lib64/flashplugin-nonfree/libflashplayer.so \ /usr/lib64/flashplugin-nonfree/libflashplayer.so.old # bspatch /usr/lib64/flashplugin-nonfree/libflashplayer.so.old \ /usr/lib64/flashplugin-nonfree/libflashplayer.so \ memcpy-10.3.162.29.bsdiff
Adobe flash plugin is a pain in the ass of any linux user. So please I encourage everybody to change to new HTML5 features, especially pages like grooveshark, megavideo or youtube (google is already doing that) which are part of my life.
Thank you!
Sunday, April 10. 2011
Glassfish Enterprise Profile on Linux amd64
The previous week an ex co-worker, and a good friend, asked me if I had tested Glassfish 2.1.1 on a x64 linux box. The question surprised me cos my new laptop is an amd64 Linux installation, all my glassfish tests are done in it and I had not noticed any problem. He clarified me that he could not setup an enterprise profile. I remember that Glassfish 2.1.1 has no difference between open source and supported edition (it was based on the same source code), so this entry is about how to setup a Glassfish enterprise profile in Linux x64 using its community version.
Glassfish v2 can be installed using three different profiles: developer, cluster or enterprise. Developer profile is a single application server instance. Cluster is a multi-instance setup with central management for all servers and cluster/Load Balancing features enabled. Enterprise profile is exactly like cluster but using NSS (Netscape Security Services) instead of JKS (Java KeyStore) for the certificate store and the possibility of using HADB for session management (a kind of multinode database that Sun used to integrate with Glassfish to get the third type of session-aware cluster I talked about in a previous post). My friend explained to me that the problem was with NSS libraries (supported Glassfish edition includes them), the libraries provided by the Linux distribution were ELF 32-bit and, obviously, they do not work with a 64 bit JVM and system.
I am going to explain the steps I followed testing this issue. This is usually how I like to show my entries, because I think this way is more useful and it is also better for me to remember.
-
As the Glassfish documentation comments, in open source edition NSS and NSPR libraries have to be installed independently from glassfish. In my debian box this step was easily done.
$ apt-get install libnss3-1d libnss3-tools libnspr4-0d libnspr4-dev libnss3-dev
Developer packages were not needed at this time but following points are going to use them.
-
Glassfish installer for open source edition was downloaded from glassfish site. For linux only one package is available. Cluster setup was installed using glassfish instructions.
$ java -Xmx256m -jar glassfish-installer-v2.1.1-b31g-linux.jar $ cd glassfish $ lib/ant/bin/ant -f setup-cluster.xml
Glassfish community edition is installed in the directory where the installer is launched, inside a new glassfish folder (this installation directory will be denoted ${GLASSFISH_DIR} since now). By default the previous process creates a domain (domain1) using cluster profile (not enterprise). So this domain was deleted.
$ cd ${GLASSFISH_DIR}/bin $ ./asadmin delete-domain domain1
-
The configuration file ${GLASSFISH_DIR}/config/asenv.conf was modified to include where NSS are installed (debian installs main NSS and NSPR libs in /usr/lib). So the following properties were modified:
AS_NSS="/usr/lib" AS_NSS_BIN="/usr/bin"
-
If you try to create an enterprise profile domain just like this the issue explained by my colleague happens. It seems a internal libasnss.so is also used and glassfish only provides it in 32 bit mode (as you see in the download page there is no Linux x64 installer). But this is open source so, not wasting any time, I took a look to glassfish 2.1.1 subversion and I found a nssstore.c file. This is a Java Native Interface (JNI) wrapper above NSS library (Java can call native libraries using JNI and this file is a wrapper to make the interaction easier). Although there are some links for completely building glassfish (one for glassfish v3 and another outdated one for v2), I quickly gave up because the process seems to be huge. So I decided to only compile the problematic file.
First the directory that contains this file was checked out:
$ cd /tmp $ svn checkout https://svn.java.net/svn/glassfish~v2/trunk/appserv-native-ee $ cd appserv-native-ee/src/cpp/nssutil/
After that the header file has to be made. In JNI this is done reading the class and executing javah command on it (the problematic class, source of the exception, was com.sun.enterprise.ee.security.NssStore).
$ javah -classpath ${GLASSFISH_DIR}/lib/appserv-se.jar \ -o com_sun_enterprise_ee_security_NssStore.h com.sun.enterprise.ee.security.NssStore
With this header the C file can be compiled against NSS/NSPR debian 64 bits libraries:
$ gcc -fpic -I/usr/lib/jvm/java-6-sun-1.6.0.24/include/ \ -I/usr/lib/jvm/java-6-sun-1.6.0.24/include/linux/ \ -I/usr/include/nss/ -I/usr/include/nspr/ nssstore.c -c $ gcc -shared -Wl,-rpath,${GLASSFISH_DIR}/lib -o libasnss.so nssstore.o -lc \ -L/usr/lib -lnss3 -lnspr4 -lnssutil3 -lsmime3
The new libasnss.so library is copied to glassfish lib directory (a backup is previously done).
$ cp ${GLASSFISH_DIR}/lib/libasnss.so ${GLASSFISH_DIR}/lib/libasnss.so.ORIG $ cp libasnss.so ${GLASSFISH_DIR}/lib/libasnss.so
-
After the previous step the domain is successfully created but it fails to start. It complains about library /usr/lib/amd64/libsoftokn3.so does not exist. Looking again the code of the class EESecuritySupportImpl.java (thrower of the new exception) it tries to initialize the PKCS11 provider (method initNSS) with the libsoftokn3 NSS library compounding its path as follows: the AS_NSS path from asenv.conf (in our case /usr/lib), the architecture if system is 64 bits (amd64 in our case) and finally libsoftokn3.so if system is not windows. So the result is /usr/lib/amd64/libsoftokn3.so but, in case of debian, this library is located in /usr/lib/nss.
I did not think too much and, after becoming root, I created a link.
# cd /usr/lib # ln -s nss amd64
-
Finally the enterprise domain was created and started successfully.
$ cd ${GLASSFISH_DIR}/bin $ ./asadmin create-domain --profile enterprise --user admin --adminport 9898 \ --savelogin=true --savemasterpassword=true domain1 $ ./asadmin start-domain
Here it is a video where the new domain is created and started (as you see my architecture is amd64, the certificate store is NSS and glassfish works perfect).
As a conclusion the glassfish installer for Linux is only provided in 32 bits. It works in x64 Linux system using developer and cluster profile cos a complete Java stack is used (no JNI library is needed) but it fails in enterprise. The enterprise profile uses NSS as the certificate store and a little libasnss.so (JNI library) is provided for easier integration, but it is only in 32 bit. In this entry the library was re-compiled in my amd64 box. Of course another problems could come out cos I did not test all the features and maybe more libraries are used (there are more native libraries in the lib glassfish directory and all of them are 32 bit).
That's the Way I Wanna Rock 'n' Roll!
Sunday, February 6. 2011
Debian 6.0 released!
This time a quick entry. As everybody who usually reads this blog knows I use debian testing as my common linux distribution (working laptop and general use desktop). Today I want to present one of the reasons why I love debian. The next version of this operating system is released when it is ready, and when is it ready? When critical bugs are counted down to zero. And squeeze was ready this morning:
It is incredible how an open community, where anybody opens, follows and patches bugs, can work in such an efficient way.
Congratulations to everyone involved! I admire you guys! And welcome wheezy!
Comments