Thursday, July 7, 2011

Installing Sun Java in Ubuntu

Recently I came across issue with using the Iced Tea for run my java code in Ubuntu OS and this behavior is inconsistent , even after looking at number of online posts didn’t help in figuring out the exact cause or the work around to fix it . Hence I finally decide to remove IcedTea and install Sun version of Java .
Below are the steps that one need to follow to install Sun java in Ubuntu

sudo add-apt-repository "deb http://archive.canonical.com/ lucid partner"

sudo apt-get update

sudo apt-get install sun-java6-jdk

sudo apt-get install sun-java5-plugin

Restart the system and you can verify the installation by typing java –version in terminal
Also you can check the java plugin for browser by Open FF -> Tools -> Add On ->Plugin


Before doing the above steps make sure you have uninstalled the IcedTea through Symantec manager(the package management system in Ubuntu) and to launch it one will have to navigate through System -> Administration -> Synaptic Package Manager

Saturday, July 2, 2011

Automate Active MQ Broker start/stop through maven


While writing integration test most of the time you need to start and stop Active MQ manually which most of you won’t prefer doing by this I mean get things automated . This can be easily done using maven(I have really started loving this tool ) plugin where in before you automated test start maven while start the Active MQ service . Below are the things that the developer had to do in maven
First you need to configure pom with the Maven plugin for Active MQ details
<plugin>
<groupId>org.apache.activemq.tooling</groupId>
<artifactId>maven-activemq-plugin</artifactId>
<version>5.4.0</version>
<configuration>
<configUri>xbean:file:src/main/resources/activemq.xml</configUri>
<fork>true</fork>
<systemProperties>
<property>
<name>javax.net.ssl.keyStorePassword</name>
<value>password</value>
</property>
<property>
<name>org.apache.activemq.default.directory.prefix</name>
<value>${project.build.directory}/target/</value>
</property>
</systemProperties>
</configuration>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring</artifactId>
<version>2.5.5</version>
</dependency>
<dependency>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-xbean</artifactId>
<version>6.1.11</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-activemq</artifactId>
<version>1.1.0</version>
</dependency>
</dependencies>
</plugin>


Secondly , we will have to create activemq.xml which is the configuration file for Active MQ .
<beans xmlns="http://www.springframework.org/schema/beans"
  xmlns:amq="http://activemq.apache.org/schema/core"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://www.springframework.org/schema/beans
  http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
  http://activemq.apache.org/schema/core
  http://activemq.apache.org/schema/core/activemq-core.xsd
  ">
  <broker xmlns="http://activemq.apache.org/schema/core" brokerName="localhost" dataDirectory="./data">
  <systemUsage>
            <systemUsage>
                <memoryUsage>
                    <memoryUsage limit="20 mb"/>
                </memoryUsage>
                <storeUsage>
                    <storeUsage limit="1 gb" name="foo"/>
                </storeUsage>
                <tempUsage>
                    <tempUsage limit="100 mb"/>
                </tempUsage>
            </systemUsage>
        </systemUsage>
    <!-- The transport connectors ActiveMQ will listen to -->
    <transportConnectors>
      <transportConnector name="openwire" uri="tcp://0.0.0.0:61616" />
      <transportConnector name="stomp" uri="stomp://0.0.0.0:61613" />
    </transportConnectors>
  </broker>
</beans>

That’s it , once you are done with the above two steps you need to open up your system terminal and run
mvn clean install activemq:run -Dmaven.test.skip=true

AuthBind


Authbind is an Open source system utility which allows a program that would normally require superuser privileges to access privileged network services to run as a non-privileged user. Authbind allows the system administrator to permit specific users and groups access to bind to TCP and UDP ports below 1024

$ sudo apt-get install authbind

You can use dpkg to know more about authbind after installing it
$ dpkg -s authbind