Archive for the ‘Debian’ Category

Since a couple of days, I was plagued by some DNS problems when using Docker 1.10+. Seems that the dnsmasq process is writing the address 127.0.1.1 into the resolv.conf. The purpose of the dnsmasq is to cache DNS queries. Unfortunately, it was no longer available in my Docker containers. The only solution for now (maybe it is a workaround) is to throw dnsmasq out. You can do this by editing the file:

/etc/NetworkManager/NetworkManager.conf

Open the file with an editor and comment out the line

dns=dnsmasq   ---> #dns=dnsmasq

After that, kill dnsmasq and restart the network-manager. You should see the changes in the resolv.conf after that:

sudo killall dnsmasq
sudo service network-manager
restart cat /etc/resolv.conf
Advertisement

Recently I had to roll out a REST-Webservice on Glassfish which used jMagick as a library. Now, ImageMagick is a C++ library and is available in Java through JNI. The installation on a standard EC2-Ubuntu AMI is pretty straightforward once you know the tricks. I executed the following steps to get things up and running:
  1. Make an EC2-Instance, attach an EBS and install JDK7 and GFv3.2.1 (these are the version which I installed)
     
  2. Install ImageMagick using sudo yum install ImageMagick. You can’t use apt-get or aptitude since Amazon prefers yum.
     
  3. Next thing is to install jMagick. You can download the latest from ftp://ftp.imagemagick.org/pub/ImageMagick/java/. Use wget to get the RPM (32 or 64 bit – I used the 64bit version).
    wget ftp://ftp.imagemagick.org/pub/ImageMagick/java/jmagick-6.4.0-3.x86_64.rpm
  4. Install the RPM using sudo yum  jmagick-6.4.0-3.x86_64.rpm
     
  5. When all goes well, you should be able to see a handful of Magick-files using ls /usr/lib64/libM* (which were installed in step 2) and of course the Java library ls /usr/lib64/libJMagick.so
  6. There should also be an accompagning JAR file for the library. Check if /usr/lib64/jmagick-6.4.0.jar is there.
     
  7. Now we get to the Glassfish part. Suppose your domain is called “domain1”. Copy the JAR into the /lib directory of your domain so it will get loaded during the startup of Glassfish.
     
  8. Point your browser to the admin-console or open the domain.xml. You need to add a JVM-parameter to get this running. In the console go to the configurations / server-config / JVM-settings and then the JVM-options tab and add the following line:

    -Djmagick.systemclassloader=no

    or add in the domain.xml the line

    -Djmagick.systemclassloader=no
    This line prevents jMagick of using the system-class-loader as you might have expected. Not adding this line leads to errors.
     

  9. Restart your domain and deploy the application. The System.loadLibrary(“JMagick”); in Magick.java runs as planned. (http://jmagick.svn.sourceforge.net/viewvc/jmagick/trunk/src/magick/Magick.java?revision=91&view=markup
We can now redeploy our application in Glassfish at will because the class is loaded by Glassfish during the startup. When not, you can expect exception when redeployen when your jMagick.JAR is in your project. The classloader will tell you that the classes are already loaded when you deploy a second time.
PS: when running Maven tests outside the container, do not forget to specifiy the -Djava.library.path=/your-path-to/libJMagick.so. 
PS2: if you install JMagick using a repository, then the JMagick.so files are stored in the /usr/lib64/jni directory. Copy the libJMagick.so file to /usr/lib64 and restart your domain. There is no need to add java.library.path to the JVM parameters in the domain.xml (something which apparently doesn’t function well).