January 4, 2013

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

$ yum groupinstall jboss-eap6

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.

$ yum groupinfo jboss-eap6
Group: JBoss EAP 6
 Mandatory Packages:
   jbossas-appclient
   jbossas-bundles
   jbossas-core
   jbossas-domain
   jbossas-hornetq-native
   jbossas-jbossweb-native
   jbossas-modules-eap
   jbossas-product-eap
   jbossas-standalone
   jbossas-welcome-content-eap

$ rpm -ql jbossas-hornetq-native
/usr/share/jbossas/modules/org/hornetq/main/lib
/usr/share/jbossas/modules/org/hornetq/main/lib/linux-x86_64
/usr/share/jbossas/modules/org/hornetq/main/lib/linux-x86_64/libHornetQAIO.so

$ rpm -ql jbossas-jbossweb-native
/usr/share/jbossas/modules/org/jboss/as/web/main/lib
/usr/share/jbossas/modules/org/jboss/as/web/main/lib/linux-x86_64
/usr/share/jbossas/modules/org/jboss/as/web/main/lib/linux-x86_64/libapr-1.so
/usr/share/jbossas/modules/org/jboss/as/web/main/lib/linux-x86_64/libcrypto.so
/usr/share/jbossas/modules/org/jboss/as/web/main/lib/linux-x86_64/libssl.so
/usr/share/jbossas/modules/org/jboss/as/web/main/lib/linux-x86_64/libtcnative-1.so

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.

$ yum install mod_jk-ap22 mod_cluster-native

After installation you can list the installed files.

$ rpm -ql mod_jk-ap22
/usr/lib64/httpd/modules/mod_jk.so
/usr/share/doc/mod_jk-ap22-1.2.36
/usr/share/doc/mod_jk-ap22-1.2.36/LICENSE
/usr/share/doc/mod_jk-ap22-1.2.36/NOTICE
/usr/share/doc/mod_jk-ap22-1.2.36/README.txt
/usr/share/doc/mod_jk-ap22-1.2.36/TODO.txt
/usr/share/doc/mod_jk-ap22-1.2.36/mod_jk.conf.sample
/usr/share/doc/mod_jk-ap22-1.2.36/workers.properties.sample
/var/run/mod_jk

$ rpm -ql mod_cluster-native
/etc/httpd/conf.d/mod_cluster.conf
/usr/lib64/httpd/modules/mod_advertise.so
/usr/lib64/httpd/modules/mod_manager.so
/usr/lib64/httpd/modules/mod_proxy_cluster.so
/usr/lib64/httpd/modules/mod_slotmem.so
/usr/share/doc/mod_cluster-native-1.2.3
/usr/share/doc/mod_cluster-native-1.2.3/JBossORG-EULA.txt
/usr/share/doc/mod_cluster-native-1.2.3/README.txt
/usr/share/doc/mod_cluster-native-1.2.3/lgpl.txt
/usr/share/doc/mod_cluster-native-1.2.3/release.txt
/usr/share/selinux/packages/mod_cluster-native
/usr/share/selinux/packages/mod_cluster-native/mod_cluster-native.pp
/var/cache/mod_cluster

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 http://127.0.0.1:6666/mod_cluster_manager.

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.
$ yum install httpd
2. Start Apache Web Server.
$ service httpd start

3. Check that Apache Web Server is running.

$ netstat -tulpn | grep :80
tcp        0      0 1.1.1.64:80                 0.0.0.0:*        LISTEN      

4. Open port 80 in firewall.

$ system-config-firewall

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

$ vi /etc/sysconfig/httpd

and change to

#
# The default processing model (MPM) is the process-based
# 'prefork' model.  A thread-based model, 'worker', is also
# available, but does not work with some modules (such as PHP).
# The service must be stopped before changing this variable.
#
HTTPD=/usr/sbin/httpd.worker

Restart Apache Web Server.

$ service httpd restart 

Validate that workers are working.

$ ps -ef | grep httpd 
root      3060     1  0 10:52 ?        00:00:00 /usr/sbin/httpd.worker
apache    3062  3060  0 10:52 ?        00:00:00 /usr/sbin/httpd.worker
apache    3063  3060  0 10:52 ?        00:00:00 /usr/sbin/httpd.worker
root      3431  3231  0 11:20 pts/1    00:00:00 grep httpd

Troubleshooting

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

$ vi /etc/httpd/conf/httpd.conf
#
# Listen: Allows you to bind Apache to specific IP addresses and/or
# ports, in addition to the default. See also the <VirtualHost>
# directive.
#
# Change this to Listen on specific IP addresses as shown below to 
# prevent Apache from glomming onto all bound IP addresses (0.0.0.0)
#
Listen 1.1.1.64:80
#Listen 80

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.

$ yum search term

Display information about package.

$ yum info package_name

Check if package is installed.

$ yum list installed package_name

Lists all installed and available packages.

$ yum list all

List all the files in a installed package.

$ rpm -ql package_name

List all the files in a NOT installed package.

$ repoquery -q -l --plugins package_name

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

Search for package that contains certain file.

$ yum provides \*filename_to_search_after

Install package.

$ yum install package_name

Check for updates.

$ yum check-update

Run update.

$ yum update

Reference:

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.

$ chkconfig service_name on

And to verify/list that service is enable.

$ chkconfig --list service_name

And to list all services.

$ chkconfig --list

And to disable a service.

$ chkconfig service_name off

References:

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

Introduction

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.

$ connect

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.

deploy /tmp/demo-1.0-SNAPSHOT.war

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

$ cd deployment=
$ ls -l
demo-1.0-SNAPSHOT.war

Or open the standalone.xml file.

    <deployments>
        <deployment name="demo-1.0-SNAPSHOT.war" runtime-name="demo-1.0-SNAPSHOT.war">
            <content sha1="303fe111257bf4f083d3f0e3f403b4f5e7e1de0c"/>
        </deployment>
    </deployments>

And to undeploy.

undeploy demo-1.0-SNAPSHOT.war

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

Introduction

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:

$ mvn archetype:generate -DarchetypeGroupId=org.apache.wicket -DarchetypeArtifactId=wicket-archetype-quickstart -DarchetypeVersion=6.4.0 -DgroupId=se.msc.examples -DartifactId=wicket -DinteractiveMode=false

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.

    <properties>
        <project.build.outputEncoding>UTF-8</project.build.outputEncoding>
    </properties>

2. Add wicket extra dependency.

        <!-- OPTIONAL DEPENDENCY -->
        <dependency>
            <groupId>org.apache.wicket</groupId>
            <artifactId>wicket-extensions</artifactId>
            <version>${wicket.version}</version>
        </dependency>

        <dependency>
            <groupId>org.apache.wicket</groupId>
            <artifactId>wicket-datetime</artifactId>
            <version>${wicket.version}</version>
        </dependency>

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

            <plugin>
                <groupId>org.mortbay.jetty</groupId>
                <artifactId>jetty-maven-plugin</artifactId>
                <version>${jetty.version}</version>
                <configuration>
                    <scanIntervalSeconds>1</scanIntervalSeconds>
                    <useTestClasspath>true</useTestClasspath>
                    <webXml>${basedir}/src/test/resources/override-web.xml</webXml>
                    <connectors>
                        <connector
                            implementation="org.eclipse.jetty.server.nio.SelectChannelConnector">
                            <port>8080</port>
                            <maxIdleTime>3600000</maxIdleTime>
                        </connector>
                    </connectors>
                </configuration>
            </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

$ mvn jetty:run

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.

References: