January 30, 2013

Java SE 6 Reaches End of Life (EOL) in February 2013

Oracle has announced that the end of life (EOL) of Java SE 6 has been set to February 2013. Which means that if you have not already upgraded to Java SE 7, now is the time. You can read more about the Oracle Java SE Support Roadmap here.

And for you folks that think that Java SE 7 is a new thing, well, I'm afraid that you are poorly updated. The Java SE 7 was released in February 2011.

January 19, 2013

Common apt-get and dpkg commands for Ubuntu (Debian)

If you have graphical interface for Ubuntu, you probably want to run synaptic, but sometime you don't and then it is good to know you Debian packages commands.

Update local cache of available packages

Search after package

Find out if a package is installed

To install package

Get information about installed packaged

Uninstall package

How to Install Atheros AR8161 Ethernet Controller on Ubuntu 12.10 (Quantal)

Today I had a hard time to install Atheros AR8161 Ethernet Controller on Ubuntu 12.10 (Quantal). Below I will give you a fast guiding how I did.

First a few words about some common network commands that will help you along the way.

  • lspci - list all PCI devices
  • lshw - list hardware
  • lsmod — program to show the status of modules in the Linux Kernel
  • modinfo — program to show information about a Linux Kernel module
  • modprobe — program to add and remove modules from the Linux Kernel

For more detailed information, please use the man command, e.g. man lspci.

And here are a few examples of running the above commands.

Now how to solve your network problem. Whenever you have problem always try to solve it by reading the official vendor pages. I know I do the same thing ask google and millions of answer turns up, but not all of them are good. For me, I first tried to install the drivers from compat-wireless, because I was to lazy to install each official ubuntu packages and they turned up to be quite buggy. So always use official stuff, before going into more experimental things.

So lets do it the official way and that is to use http://askubuntu.com. And here the answer comes up http://askubuntu.com/questions/217361/how-do-i-install-drivers-for-the-atheros-ar8161-ethernet-controller-on-64-bit-12. AND PLEASE USE ANSWER 1, the other will lead you astray.

January 15, 2013

Installing and Using PGP with GNU Privacy Guard (GnuPG) on RHEL 6.3


In this blog I will show you how to use PGP client GNU Privacy Guard (GnuPG) on RHEL 6.3. PGP can be used to encrypt files which can be stored somewhere on remote disc or by sending as attached files.


Installation was quite smooth, except founding the missing dependency package pinentry-gtk, which should be installed automatically.

Test your installation

A simple test to see that GnuPG is installed properly is to ask for each version.


Creating Private Key Pair

The first thing to do, after installation was successful, is to generate the necessary keys used for encrypting and decrypting files. To generate you private key pair, do the following.

Exporting Public Key

To be able to receive encrypted files, you need to export your public key. The text files generated below can be emailed as attachment or more preferable distributed in a more secure way, such as manually handed over via USB memory.


Now you are ready to use GnuPG. A good tutorial guide for the most common usage can be found here http://www.glump.net/howto/gpg_intro.


How to Disable SELinux on RHEL 6.3

SELinux is a good thing, but when sitting on a test machine, you might not be interesting in configure SELinux to have you application running smoothly, without running into SELinux. So here I will show you how to disable SELinux. Remember that this is NOT recommended for a production environment.

First check the current status of SELinux.

Now to disable SELinux. Open /etc/selinux/config and edit the below.

Now restart you system and run sestatus again to verify that you configuration changes had taken affect.


January 12, 2013

How to Install and Configure Subversion (SVN) on RHEL 6.3

In this blog I will show you how to install and configure Subversion (svn) on Red Hat Enterprise Linux (RHEL) 6.3.

1. Installation

First lets install subversion and apache web server, if you already have installed a apache web server, then leave out the httpd package below.

2. Configuration

2.1 Create a new Subversion Repository

Now lets create a new subversion repository named 'demorepo'.

2.2 Authentication

It is highly recommended to have some authentication to your subversion repository. Here I will use simple login using the built in Apache Web Server module mod_auth_basic. The module is per default installed and configured with the RHEL httpd package, we only need to add new users.

2.3 Configure Apache Web Server

Finally we need to configure the apache web server, for our new web location, but also to apply our authentication. We will facilitate the pre-configured configuration file /etc/httpd/conf.d/subversion.conf that comes with the mod_dav_svn package.

Now we only need to restart our apache web server and test our demo subversion repository - http://localhost/svn/demorepo/.


January 11, 2013

How to Setup and Use Artifactory as Proxy/Mirror for Remote Repositories

In this blog I will discuss and show you how to setup and use Artifactory as proxy (mirror) for remote repositories, such as Central Maven 2 repository or other remote repository, but also using for internal distribution for corporate releases.

First if you have not installed a Artifactory server, start with that. You can read about the installation steps in my previous blog - http://magnus-k-karlsson.blogspot.se/2013/01/how-to-install-artifactory-on-rhel-63.html.

The next step is to create a settings.xml for you company, that uses this newly installed Artifactory server as proxy/mirror. Creating you own settings.xml can be daunting task, but fear not Artifactory can create one for you. Simply open you web browser and open Here we will also select which internal repository we will use for internal distribution. You can create a new, but here we will use the already created repository 'libs-release'.

Then click Generate Settings and save it to ~/.m2/settings.xml. That was not so hard, lets try it out. Before you continue, make sure that you have installed Maven 3. If you are on a RHEL platform, please read my previous blog http://magnus-k-karlsson.blogspot.se/2013/01/how-to-install-maven-3-on-rhel-63.html.

Now lets create a simple project. I will use Apache Wicket Quickstart here, but you can use any maven project. Open http://wicket.apache.org/start/quickstart.html and copy past the maven command to your terminal.

As you can see that maven now request all dependency from you local artifactory server instead from a remote repository. And if you open the artifactory server log you will see that the mirrored remote repository is populated.

Now if everything is working, lets continue by adding a new remote repository. Lets log into artifactory and select the Admin tab and then Repositories from the left menu and add a new remote repository. Here I will use the new JBoss EAP 6 repository, but you can choose any valid remote repository.

Repository Key: jboss-eap-repository
URL: http://repo1.maven.org/maven2
Public Description: JBoss EAP Maven Repository
Includes Pattern: **/*
Checksum Policy: Generate if absent
Max Unique Snapshots: 0
Handle Releases: true
Handle Snapshots: true
Use default for the rest of the settings.

After added, we will add this remote repository to virtual repository remote-repos. The advantage of using virtual repositories, is that we do not need to updated our settings.xml. The remote-repos is already there by default.

Al right. Now lets test it. Lets open up our wicket pom.xml and add the JBoss EAP Java EE Spec dependency.

After editing you pom.xml, lets test it.

And in your artifactory server log.

How to Install Artifactory on RHEL 6.3

In this blog I will show you how to install Artifactory on Red Hat Enterprise Linux 6.3.

Artifactory comes in two flavours:

In this blog I will show you how to install the Artifactory Open Source version. So lets get started. First download the latest RPM package from sourceforge - http://sourceforge.net/projects/artifactory/files/artifactory/. Then install it as root.

You can read more about what files are installed and where in the Artifactory Installation Guide chapter RPM Installation - http://wiki.jfrog.org/confluence/display/RTF/RPM+Installation. Or list all installed files with rpm command.

If you want more information about how to work with yum and rpm commands, please read my previous blog - http://magnus-k-karlsson.blogspot.se/2013/01/quickguide-to-most-common-yum-and-rpm.html.

If you are not happy with artifactory, you uninstall it with yum.

Now lest test our Artifactory installation. Lets first start it. After started you can access it from http://your_server_ip:8081/artifactory.

And to login use:
username: admin
password: password

And if you are happy with the installation, you can set the artifactory to start automatically when booting, by reading my previous blog here http://magnus-k-karlsson.blogspot.se/2013/01/how-to-autostart-program-at-bootup.html.

January 9, 2013

How to Install Maven 3 on RHEL 6.3

In RHEL 6 there is no package for Apache Maven 3 and if you search the official repo you will end up with.

But that package does not contain any maven binaries. So since there is no official package and I do not want to clutter my RHEL installation, by adding custom repositories, we will do it manually. And that is no big thing.

First download the apache maven binaries, I downloaded the zip file. And extract it in /usr/share.

Now "install" it, i.e. create a soft link.

And finally set all needed environment variables in /etc/environment. And for my RHEL 6.3 machine they look like this.

Now test your installation of Apache Maven 3.0.4.

How to Setup JBoss EAP 6 HA Cluster With mod_cluster Using TCP Multicast Networking

JBoss EAP 6 uses JGroups to handle cluster communication. JGroups is a full fledged communication API and you can read more about it here, http://www.jgroups.org/manual-3.x/html/index.html.

Default is JBoss EAP 6 configured to use UDP, but in this blog I will show you how to configure JBoss EAP 6 HA cluster to use TCP multicast networking instead.

JGroups is flexible API, that can stack several protocol on top of each other, or chain them if you like. The JGroups protocol can be divided into the following:

  • Reliable transmission: pbcast.NAKACK, UNICAST, RSVP
  • State transfer: pbcast.STATE_TRANSFER, pbcast.STATE, BARRIER

Now revisit our cluster domain example that I have previously described here http://magnus-k-karlsson.blogspot.se/2013/01/how-to-cluster-domain-jboss-eap-6-and.html. But now lets change the global configuration in ./domain/domain/configuration/domain.xml.

Now if you have already started the cluster you need to restart the Domain Controller and then log into the domain controller with you CLI tool and restart each cluster node.

Watch each cluser server node log for error, if any revisit the above and sort out problems. If everything OK, you should see something similar on server1.

And host server2.

Now in the JBoss EAP 6 Administration and Configuration Guide there is suggested to turn off the ServerAdvertise in the Apache Web Server mod_cluster, we do that and restart everything. After restart make sure that mod_cluster is up and running, by checking every cluster node is registered in the

Now you can test the clustered application by open

January 5, 2013

Rest Example with Jersey (Reference Implementation of JAX-RS)

When reading the official Oracle J2EE 6 Tutorial there are very few complete and runnable example. So in this blog I will have a go with a simple Hello World REST example. REST is build on top web service and some people might right now be sceptical. But the REST architecture is said to deliver. The other problem with web service, is that is so many implementation, depending on which platform you are deploying to. In this blog I will use the reference implementation of JAX-RS, Jersey - http://docs.oracle.com/javaee/6/tutorial/doc/giepu.html.

After that said, lets get started with our first runnable Hello World REST example with Jersey.

And here is the web.xml that contains the dispatcher servlet.

And finally our pom.xml, that shows the jersey dependency and a maven jetty plugin, which we will use for running our example.

Now lets test our application.


Why equals() and hashcode() is important for JPA and Hibernate

For you people out there, that have wonder why you should override equals() and hashcode(), when writing your Entity Beans, please read this JBoss wiki https://community.jboss.org/wiki/EqualsandHashCode

How to Remote Connect JConsole to JBoss EAP 6

One of the maybe most imported task after deployment, is to establish a good monitoring tool. The standardized tool for Java is JConsole.

To remotely connect to a application server, have previously been a pain, but the standardization work has finally given some fruit. The JBoss EAP 6 and AS 7 server now supports the JSR 160 - JMX Remote API for remote management and monitoring. The JSR 160 is a great leap forward, since the standard does not build upon RMI, which makes it really hard to use behind a firewall and only have access via SSH port. So now is JMXConnector used and under the hood uses JBoss its own remoting libraries. The only drawback with this is that you have to add these dependency libraries when starting jconsole. But Red Hat had already provided a ready cooked script for that.

So lets start trying this out. Start with by unzipping a fresh jboss-eap-6.0.1.zip to a new folder and start the server in standalone mode.

The next thing we need to is to create a management user, since the JMXConnector requires login. We create new users with the add-user.sh script.

Now we are ready to start the jconsole on a remote machine, with the jconsole.sh script.

Before starting the jconsole, be sure that you have set the JAVA_HOME environment variable.

Now you can remotely login to service:jmx:remoting-jmx://, with the above credential.

How to Cluster Domain JBoss EAP 6 and AS 7


In my previous blog I showed how to cluster with JBoss EAP 6.0.3 in standalone mode, but standalone mode is really used in production, where the domain mode is the preferred way to manage multiple JBoss installations.

In this blog I will also cluster two JBoss nodes, but started in domain mode. To achieve that we need a domain master (domain controller) and slave (host controller), that push and respectively receive configuration. The deployment scenario is the following.

I have in the deployment diagram also added the concerned configuration file for each artifact, which I hope will help you to remember which configuration files goes to which artifact. Lets get started, but first some prerequisites.


In this blog I will start everything up on the same machine, which is adequate for testing, but of course not for production, so when you move to production you need to change interfaces IP for each JBoss. But that is about it. Lets get started.

To simulate and keep things separated I have extracted the jboss-eap-6.0.1.zip into three folders:

  • domain
  • host1
  • host2

Domain Controller

The domain controller is configured with three configuration files.

  • domain.xml - main configuration files
  • host-master.xml - boot up configuration files, telling that this is domain controller.
  • host.xml - additional configuration files for server group, such as system-wide properties and JVM configuration.

Lets first define our server group in ./domain/domain/configuration/domain.xml.

Then we will leave the ./domain/domain/configuration/host-master.xml unaltered and use defaults. The part that points out that this is domain controller is the below.

The last thing we need to do is to create a management user in the domain controller.

Now we are ready to start the domain controller.

If you wanted to bind the domain controller to a specific IP, you would have used the -Djboss.bind.address.management. Which property you see in the interface element in the host-master.xml configuration file.

Now lets move onto the host controller.

Host Controller

A host controller is a slave to the domain controller which listen for configuration and start/stop instruction. The host controller then feeds that information to all server node on a physical machine. The host controller is not really something special to only domain mode, but is also present in a standalone mode, but then not really used.

Lets get started with the configuration for the host controller. Lets open ./host1/domain/configuration/host-slave.xml and define the server nodes that will be managed by this host controller.

Since we are running everything on the same machine, we need to set the port-offset property. If this was running on a dedicated server you leave that out.

We use the server group that was defined in the domain controller.

Next we need to set up security to the domain controller. The host controller needs to know how to establish a connection to the domain controller. Here we use the same base64 password that we recieved when creating the management user for the domain controller.

The last thing we need to change, and this is because we are running everything on the same machine is the management port.

Now lets multiply the above configuration to host 2 also.

Now we are ready to start the host controllers.

You should now see the following in the domain controller log.

Test Installation

To test is installation, we need a clustered application. I will as in my earlier blog borrow a ready application from https://github.com/akquinet/jbosscc-as7-examples/tree/master/cluster-example.

But now we will use the new JBoss CLI tool to deploy and start and stop our server nodes. See my previous blog on how to deploy with CLI http://magnus-k-karlsson.blogspot.se/2013/01/how-to-deploy-and-undeploy-in-jboss-eap.html.

If you now look in each host controller log file, you should see the deployment. If everything is ok. Lets test the application, open

Now lets stop the server node, that you were served and test the replication.

And you should now see in that node server log.

Lets now hit the application again.

January 4, 2013

How to Cluster Standalone JBoss EAP 6 and AS 7

In this blog I will show you how to cluster two JBoss standalone servers.


When you have the prerequisites up and running we are ready to start the JBoss servers. Here I will start with the most simple configuration, i.e. standalone-ha mode.

To simulate a more real situation I have unziped jboss-eap-6.0.1.zip to two different folders, jb1 and jb2. Now lets start each JBoss server.

Since we will be running two servers on the same machine we need to differentiate the servers ports. This can easy be made with the JBoss property port-offset.

Now you should see in each JBoss log file that it picked up mod_cluster.

Also verify that mod_cluster in Apache Web Server has detected the two JBoss servers.

If mod_cluster have not detected two server or they have not Status: OK, then stop here and check the Apache Web Server error log file (/etc/httpd/logs/error_log) and JBoss server log file (./jb1/standalone/log/server.log).

In my case had SELinux problem that stopped the second JBoss instance to be properly detected by mod_cluster in Apache Web Server. I received the following error message in /etc/httpd/logs/error_log.

To temporarily disable that, run the below on RHEL 6.3. For a lengthier description see http://sysadminsjourney.com/content/2010/02/01/apache-modproxy-error-13permission-denied-error-rhel/.

Since the new JBoss load modules lazily, you will not see much in the log file, without a cluster application. You can write you own clustered application, but that is out of scope for this blog, so I copied a simple application from https://github.com/akquinet/jbosscc-as7-examples/tree/master/cluster-example.

Now deploy the clusterd application to each JBoss deploy folder $JBOSS_HOME/standalone/deployments/. And you see in each JBoss log file, that they have started Infinispan, and clustering have detected each other.

After successful deployment, now lets try the web app,

Now to test the failover capability kill the server you was served for. And then hit again.

How to Install JBoss EAP 6.0.1 Native Components and Webserver Connector Natives for RHEL 6

When I wanted to install the JBoss EAP 6.0.1 native components and Webserver Connector natives on RHEL 6.3 I had some hard time. The only thing I knew was that I wanted to install them via RPM package, so I could get the nice built in management support for upgrades, reinstall and uninstall. But finding the correct packages was not that obvious.

As usual when knowing the answer everything is easy, which I'm going to present to you below.

First install JBoss EAP 6.0.1 via yum. That is described in the JBoss EAP 6 Installation Guide, which you can find here https://access.redhat.com/knowledge/docs/en-US/JBoss_Enterprise_Application_Platform/6/html/Installation_Guide/Install_JBoss_Enterprise_Application_Platform_6_using_the_Red_Hat_Network_RPM_installation.html

If you then grab the yum group info for that group package and then the list the installed file, you will see that the JBoss EAP 6 native components are already bundled in the jboss-eap6 group package.

If you do not want install the JBoss EAP 6 via yum, you can do that manually which for example is described here - http://www.opensourcearchitect.com/tutorials/instaling-eap-600-rhel-6x. But I do not recommend that for JBoss EAP 6, because it is already nice packaged. If you are installing JBoss EAP 5.x, you probably want to take that path, but no for JBoss EAP 6.

The next thing is to install JBoss EAP 6 Webserver Connector Natives, but before doing that you need to install Apache Web Server, which I have earlier described here, http://magnus-k-karlsson.blogspot.se/2013/01/install-apache-web-server-on-red-hat.html

After you have installed Apache Web Server you only need to install two packages.

After installation you can list the installed files.

As you can see from the list of installed files, the mod_cluster-native package have already added a configuration file for the Apache Web Server - /etc/httpd/conf.d/mod_cluster.conf. After restarted you Apache Web Server you can test you mod cluster, by open a web browser and point it to

January 3, 2013

Install Apache Web Server on Red Hat Enterprise Linux 6.3 (RHEL)

In this blog I will show you how to install Apache Web Server on RHEL 6.3.

1. Install httpd package.

2. Start Apache Web Server.

3. Check that Apache Web Server is running.

4. Open port 80 in firewall.

If you are planning to run JBoss behind Apache Web Server.

and change to

Restart Apache Web Server.

Validate that workers are working.


If you have trouble restart Apache Web Server after activating workers, you might need to define listening ip:port

Quickguide to the most common yum and rpm commands

The first thing you probably want to learn better after have installed a RHEL or Fedora system, is how you manage your programs. And the answer to that is the command yum or rpm. Below follows a list of the most common yum and rpm commands.

Search RPM package names.

Display information about package.

Check if package is installed.

Lists all installed and available packages.

List all the files in a installed package.

List all the files in a NOT installed package.

* Note repoquery requires packages yum-utils to be installed.

Search for package that contains certain file.

Install package.

Check for updates.

Run update.


How to Autostart a Program at Bootup (Enable a Service)

RHEL (Red Hat Enterprise Linux) has a uniform way to auto start application when booting or more strictly said, how to enable a service.

And to verify/list that service is enable.

And to list all services.

And to disable a service.


Installing RHEL 6 (Red Hat Enterprise Linux)

For you that have not installed RHEL (Red Hat Enterprise Linux) before there is a really good step-by-step guide at http://computernetworkingnotes.com/installation/how-to-install-rhel6-from-dvd.html.

January 2, 2013

How to deploy and undeploy in JBoss EAP 6


In this blog I will present how to deploy application with JBoss EAP 6 and JBoss AS 7, both via the new Command Line Interface, CLI and the traditional way, by dropping deployable in deployment folder.

Old School - Deployment Folder

The easiest way is to start the JBoss in standalone and drop the deployable package in $JBOSS_HOME/standalone/deployments/ folder. If successfully deployed you will a get a new marker file in the deployment folder with extension .deployed.

To undeploy simply remove the deployable file.

And to redeploy simply touch a file with the same name as deployable + ".dodeploy".

New Way - Command Line Interface, CLI

The new and recommended way to manage deployments are via the CLI tool. Before you can proceed with the CLI you must first start your JBoss. Then you start the CLI with $JBOSS_HOME/bin/jboss-cli.sh.

To connect to local server simply type connect. And if you want to start a remote server, the easiest way is to open a SSH tunnel to the remote server and do the above.

To deploy, use the deploy command. Remember that JBoss CLI has autocompletion, which means you can use the tab key for autocompletion of paths and commands.

To verify the deployment, you can either do that with the JBoss CLI tool.

Or open the standalone.xml file.

And to undeploy.

How to Debug and Run Apache Wicket Quickstart with Jetty Web Server


The development environment for Apache Wicket is really good. In this blog I will show you how to run Apache Wicket web application with the maven jetty plugin, but also how to debug your web application.

How to run with Maven Jetty Plugin

First lets get started with creating a simple Apache Wicket web application with the wicket maven archetype. If you are not familiar with maven archetype, please read http://maven.apache.org/guides/introduction/introduction-to-archetypes.html. To get the latest version of Apache Wicket, please visit http://wicket.apache.org/start/quickstart.html. In this blog I will make some changes to this Apache Wicket Quickstart, which I will describe below and why I have made them.

First remove the extra repository from the archetype command. This extra repository is not necessary and In my opinion you should as far as possible stick with standard repository, as long as possible. The final archetype command I used looks the following:

After finished you can import the maven project into Eclipse or you preferred IDE. Now open the pom.xml. I made the following changes.

1. Add UTF-8 encoding to reporting.

2. Add wicket extra dependency.

3. Add the following configuration to the jetty-maven-plugin.

The scanIntervalSeconds configuration makes the jetty web server automatically restart whenever you make changes in you IDE. This makes coding easy and you can directly see you changes in your web browser.

The next configuration (useTestClasspath) adds you test code to the jetty web server classpath. This is convenient if you want to mock your server facade.

And with last configuration (webXml) you can switch the standard web.xml with a completely mocked web.xml, which may contain no security classpaths to you mocked classes.

To run the maven jetty plugin, simply open a terminal and write

How to Debug with Jetty Web Server

The last and maybe the most imported is the debug capability. The Apache Wicket archetype comes also with a jetty web server that is started from a java class /src/test/java/se/msc/examples/Start.java. And if you do not need the SSL support I recommend you to comment that code out. Now simple right click on Start class and select Debug As → Java Application. Add breakpoints and open that page in you web browser. Easy and elegant.