Compiling Apache HTTPD on Mac (Tech Tip #45)

One of my blogs needed Apache HTTPD 2.4.x on Mac but quickly realized that the binaries are available only for Netware and Win32. Even the build instructions were only for RPM-based systems. So I downloaded the source code and started building it.

Complete compile instructions are explained here. However there were some issues on Mavericks and so decided to document it.

Let’s go!

  1. Download the source bundle and unzip:
    tar xzvf ~/Downloads/httpd-2.4.10.tar.bz2
  2. Source code comes with INSTALL instructions and per that the following should’ve worked:
    ./configure --prefix=PREFIX
    make
    make install
    PREFIX/bin/apachectl start

    So gave the command

    ./configure --prefix=/usr/local/apache2

    and got the first error:

    httpd-2.4.10> ./configure --prefix=/usr/local/apache2
    checking for chosen layout... Apache
    checking for working mkdir -p... yes
    checking for grep that handles long lines and -e... /usr/bin/grep
    checking for egrep... /usr/bin/grep -E
    checking build system type... x86_64-apple-darwin13.3.0
    checking host system type... x86_64-apple-darwin13.3.0
    checking target system type... x86_64-apple-darwin13.3.0
    configure: 
    configure: Configuring Apache Portable Runtime library...
    configure: 
    checking for APR... yes
      setting CC to "/Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.9.xctoolchain/usr/bin/cc"
      setting CPP to "/Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.9.xctoolchain/usr/bin/cc -E"
      setting CFLAGS to " "
      setting CPPFLAGS to " -DDARWIN -DSIGPROCMASK_SETS_THREAD_MASK"
      setting LDFLAGS to " "
    configure: 
    configure: Configuring Apache Portable Runtime Utility library...
    configure: 
    checking for APR-util... yes
    checking for gcc... /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.9.xctoolchain/usr/bin/cc
    checking whether the C compiler works... no
    configure: error: in `/Users/arungupta/workspaces/httpd-2.4.10':
    configure: error: C compiler cannot create executables
    See `config.log' for more details
    
  3. Moved past “checking whether the C compiler works… no” error by following instructions on stackoverflow #13587001.In short, do the following for Mavericks
    sudo ln -s /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.9.xctoolchain
  4. Issued the command to compile the server again and got the error as shown:
    httpd-2.4.10> ./configure --prefix=/usr/local/apache2 
    checking for chosen layout... Apache
    checking for working mkdir -p... yes
    checking for grep that handles long lines and -e... /usr/bin/grep
    checking for egrep... /usr/bin/grep -E
    checking build system type... x86_64-apple-darwin13.3.0
    checking host system type... x86_64-apple-darwin13.3.0
    checking target system type... x86_64-apple-darwin13.3.0
    configure: 
    configure: Configuring Apache Portable Runtime library...
    configure: 
    checking for APR... yes
      setting CC to "/Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.9.xctoolchain/usr/bin/cc"
      setting CPP to "/Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.9.xctoolchain/usr/bin/cc -E"
      setting CFLAGS to " "
      setting CPPFLAGS to " -DDARWIN -DSIGPROCMASK_SETS_THREAD_MASK"
      setting LDFLAGS to " "
    configure: 
    configure: Configuring Apache Portable Runtime Utility library...
    configure: 
    checking for APR-util... yes
    checking for gcc... /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.9.xctoolchain/usr/bin/cc
    checking whether the C compiler works... yes
    checking for C compiler default output file name... a.out
    checking for suffix of executables... 
    checking whether we are cross compiling... no
    checking for suffix of object files... o
    checking whether we are using the GNU C compiler... yes
    checking whether /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.9.xctoolchain/usr/bin/cc accepts -g... yes
    checking for /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.9.xctoolchain/usr/bin/cc option to accept ISO C89... none needed
    checking how to run the C preprocessor... /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.9.xctoolchain/usr/bin/cc -E
    checking for /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.9.xctoolchain/usr/bin/cc option to accept ISO C99... none needed
    checking for pcre-config... false
    configure: error: pcre-config for libpcre not found. PCRE is required and available from http://pcre.org/

    This was resolved using stackoverflow #10663180. In short:

    1. Download PCRE as:
      curl -O ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.33.zip
    2. Compile and install as:
      ./configure --prefix=/usr/local/pcre
      make
      sudo make install

    The compilation output is shown here.

  5. Compile HTTPD source again as:
    httpd-2.4.10> ./configure --prefix=/usr/local/apache2 --with-pcre=/usr/local/pcre
    checking for chosen layout... Apache
    checking for working mkdir -p... yes
    checking for grep that handles long lines and -e... /usr/bin/grep
    checking for egrep... /usr/bin/grep -E
    checking build system type... x86_64-apple-darwin13.3.0
    checking host system type... x86_64-apple-darwin13.3.0
    checking target system type... x86_64-apple-darwin13.3.0
    configure: 
    . . .
    creating server/Makefile
    creating support/Makefile
    creating test/Makefile
    config.status: creating docs/conf/httpd.conf
    config.status: creating docs/conf/extra/httpd-autoindex.conf
    config.status: creating docs/conf/extra/httpd-dav.conf
    config.status: creating docs/conf/extra/httpd-default.conf
    config.status: creating docs/conf/extra/httpd-info.conf
    config.status: creating docs/conf/extra/httpd-languages.conf
    config.status: creating docs/conf/extra/httpd-manual.conf
    config.status: creating docs/conf/extra/httpd-mpm.conf
    config.status: creating docs/conf/extra/httpd-multilang-errordoc.conf
    config.status: creating docs/conf/extra/httpd-ssl.conf
    config.status: creating docs/conf/extra/httpd-userdir.conf
    config.status: creating docs/conf/extra/httpd-vhosts.conf
    config.status: creating docs/conf/extra/proxy-html.conf
    config.status: creating include/ap_config_layout.h
    config.status: creating support/apxs
    config.status: creating support/apachectl
    config.status: creating support/dbmmanage
    config.status: creating support/envvars-std
    config.status: creating support/log_server_status
    config.status: creating support/logresolve.pl
    config.status: creating support/phf_abuse_log.cgi
    config.status: creating support/split-logfile
    config.status: creating build/rules.mk
    config.status: creating build/pkg/pkginfo
    config.status: creating build/config_vars.sh
    config.status: creating include/ap_config_auto.h
    config.status: executing default commands

    Complete output of this configuration is here.

  6. Now issue the command make:
    httpd-2.4.10> make
    Making all in srclib
    Making all in os
    Making all in unix
    /usr/share/apr-1/build-1/libtool --silent --mode=compile /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.9.xctoolchain/usr/bin/cc        -DDARWIN -DSIGPROCMASK_SETS_THREAD_MASK     -I. -I/Users/arungupta/workspaces/httpd-2.4.10/os/unix -I/Users/arungupta/workspaces/httpd-2.4.10/include -I/usr/include/apr-1 -I/usr/local/pcre/include -I/Users/arungupta/workspaces/httpd-2.4.10/modules/aaa -I/Users/arungupta/workspaces/httpd-2.4.10/modules/cache -I/Users/arungupta/workspaces/httpd-2.4.10/modules/core -I/Users/arungupta/workspaces/httpd-2.4.10/modules/database -I/Users/arungupta/workspaces/httpd-2.4.10/modules/filters -I/Users/arungupta/workspaces/httpd-2.4.10/modules/ldap -I/Users/arungupta/workspaces/httpd-2.4.10/modules/loggers -I/Users/arungupta/workspaces/httpd-2.4.10/modules/lua -I/Users/arungupta/workspaces/httpd-2.4.10/modules/proxy -I/Users/arungupta/workspaces/httpd-2.4.10/modules/session -I/Users/arungupta/workspaces/httpd-2.4.10/modules/ssl -I/Users/arungupta/workspaces/httpd-2.4.10/modules/test -I/Users/arungupta/workspaces/httpd-2.4.10/server -I/Users/arungupta/workspaces/httpd-2.4.10/modules/arch/unix -I/Users/arungupta/workspaces/httpd-2.4.10/modules/dav/main -I/Users/arungupta/workspaces/httpd-2.4.10/modules/generators -I/Users/arungupta/workspaces/httpd-2.4.10/modules/mappers  -prefer-non-pic -static -c unixd.c && touch unixd.lo
    /usr/share/apr-1/build-1/libtool --silent --mode=link /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.9.xctoolchain/usr/bin/cc           -o libos.la -static  unixd.lo  
    Making all in server
    Making all in mpm
    Making all in worker
    . . .
    warning: no debug symbols in executable (-arch x86_64)
    /usr/share/apr-1/build-1/libtool --silent --mode=compile /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.9.xctoolchain/usr/bin/cc        -DDARWIN -DSIGPROCMASK_SETS_THREAD_MASK     -I. -I/Users/arungupta/workspaces/httpd-2.4.10/os/unix -I/Users/arungupta/workspaces/httpd-2.4.10/include -I/usr/include/apr-1 -I/usr/local/pcre/include -I/Users/arungupta/workspaces/httpd-2.4.10/modules/aaa -I/Users/arungupta/workspaces/httpd-2.4.10/modules/cache -I/Users/arungupta/workspaces/httpd-2.4.10/modules/core -I/Users/arungupta/workspaces/httpd-2.4.10/modules/database -I/Users/arungupta/workspaces/httpd-2.4.10/modules/filters -I/Users/arungupta/workspaces/httpd-2.4.10/modules/ldap -I/Users/arungupta/workspaces/httpd-2.4.10/modules/loggers -I/Users/arungupta/workspaces/httpd-2.4.10/modules/lua -I/Users/arungupta/workspaces/httpd-2.4.10/modules/proxy -I/Users/arungupta/workspaces/httpd-2.4.10/modules/session -I/Users/arungupta/workspaces/httpd-2.4.10/modules/ssl -I/Users/arungupta/workspaces/httpd-2.4.10/modules/test -I/Users/arungupta/workspaces/httpd-2.4.10/server -I/Users/arungupta/workspaces/httpd-2.4.10/modules/arch/unix -I/Users/arungupta/workspaces/httpd-2.4.10/modules/dav/main -I/Users/arungupta/workspaces/httpd-2.4.10/modules/generators -I/Users/arungupta/workspaces/httpd-2.4.10/modules/mappers -prefer-pic -c mod_rewrite.c && touch mod_rewrite.slo
    /usr/share/apr-1/build-1/libtool --silent --mode=link /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.9.xctoolchain/usr/bin/cc             -o mod_rewrite.la -rpath /usr/local/apache2/modules -module -avoid-version  mod_rewrite.lo 
    warning: no debug symbols in executable (-arch x86_64)
    

    Complete output of the command is shown here.

  7. Finally install Apache2 as:
    httpd-2.4.10> sudo make install
    Password:
    Making install in srclib
    Making install in os
    Making install in unix
    Making install in server
    Making install in mpm
    Making install in worker
    mkdir /usr/local/apache2
    mkdir /usr/local/apache2/modules
    Making install in modules
    . . .
    Installing man pages and online manual
    mkdir /usr/local/apache2/man
    mkdir /usr/local/apache2/man/man1
    mkdir /usr/local/apache2/man/man8
    mkdir /usr/local/apache2/manual

    Complete output of this command is shown here.

Version for HTTPD can be checked as:

httpd-2.4.10> /usr/local/apache2/bin/httpd -v
Server version: Apache/2.4.10 (Unix)
Server built:   Aug 22 2014 16:00:19

Server can be started as:

sudo /usr/local/apache2/bin/apachectl start

Stopped as:

sudo /usr/local/apache2/bin/apachectl stop

Restarted as:

sudo /usr/local/apache2/bin/apachectl restart

Enjoy!

Posted in techtip | Tagged , | 1 Comment

Java EE 6 Sample, with HTML5, jQuery, Hybrid mobile: aka Ticket Monster (Tech Tip #44)

Java EE 7 was released last year, Java EE 8 preparations have already started, so what tempts me to write a blog about Java EE 6 ?

A few reasons …

  • Even though Java EE 5 was the first version where some of the specs were updated to simplify the platform, Java EE 6 is where higher productivity became the primary focus and kicked into high gear.
  • All commercially available application servers are still Java EE 6 compliant.
  • Java EE 7 is pretty cool and provide an awesome bunch of new technologies like WebSocket, Batch, JSON, and Concurrency. But customers are still sticking around with older version of the platform because these applications, servers, and environments cannot change overnight.

So if you are looking for a real-world Java EE 6 sample application that:

  • Use Eclipse for building a Java EE 6 application
  • Build persistence layer with JPA2 and Bean Validation
  • Build business services with JAX-RS
  • Building the User Interface with HTML5
  • Building Administration UI with JBoss Forge
  • Building statistics dashboard using HTML5 and JavaScript
  • Hybrid mobile version of the app using Apache Cordova

In addition, it also shows:

  • Deploy your application on a local instance or a remote instance running in OpenShift
  • Run tests against your JBoss instance

Ticket Monster is your ultimate source. It not only shows how the key Java EE 6 technologies can be used together but also integrate jQuery, HTML5, and mobile version of the application as well.

The video below gives a quick preview of the application:

An instance of Ticket Monster can be previewed at ticketmonster-jdf.rhcloud.com or timo-milestogo.rhcloud.com.

So how do you get started ?

  1. Download Ticket Monster 2.6.0 (with tutorials). Corresponding source code is at github.com/jboss-developer/ticket-monster/tree/2.6.0.Final-with-tutorials.
  2. Set up Red Hat Maven repositories as explained here. If you don’t care reading through the instructions, overwrite .m2/settings.xml with this settings.xml.
  3. Build the WAR of your application
    mvn clean package
  4. To run on local JBoss instance:
    • Download JBoss EAP 6.3
    • Unzip and start as
      ./bin/standalone.sh
    • Deploy the application as
      mvn package jboss-as:deploy

      This will also build the application again.

  5. To run on JBoss instance in OpenShift
    • Create a JBoss EAP 6 application in OpenShift
    • Add PostgreSQL cartridge for this application
    • Create an archive as
      mvn clean package -Ppostgresql-openshift

      This will use the installed PostgreSQL cartridge for persistence.

    • Clone the git workspace from OpenShift
      git clone ssh://XXXXXXXXXXXXXX@timo-milestogo.rhcloud.com/~/git/timo.git/

      The actual git url will be specific to your application.

    • Copy generated WAR file to git workspace and rename to ROOT.war
      cp target/ticket-monster.war <openshift-git-workspace>/deployments/ROOT.war
    • Remove existing source and pom.xml from git workspace, add WAR, and push
      git rm -rf src
      git rm pom.xml
      git add deployments/ROOT.war
      git commit . -m"deploying TicketMonster"
      git push
    • Access the application at htp://<appname-domainname>.rhcloud.com.The following video shows the steps for running TicketMonster on OpenShift:

Ask your questions about Ticket Monster at jbossdeveloper@lists.jboss.org.
Enjoy!

Posted in javaee, jboss, techtip | Tagged , | Leave a comment

WildFly 9: Features and Getting Started (Tech Tip #43)

WildFly 8.1 provides a Java EE 7 compliant application server, and is pretty awesome!

WildFly team has been actively working this summer on the next release. WildFly 9 features were announced a few weeks ago. Here is a quick summary and links to discussions on wildfly-dev:

Links/details to rest of the features TBD.

So how do you get started with WildFly 9 ?

  • Building WildFly 9 requires at least have Maven 3.2.1, download the latest here.
  • Clone the workspace as:
    git clone https://github.com/wildfly/wildfly.git
  • Build the workspace as:
    mvn install -DskipTests

    Took 02:36 mins to build on my machine :)

  • Unzip dist/target/wildfly-9.0.0.Alpha1-SNAPSHOT.zip to a new directory
  • Run WildFly as:
    wildfly-9.0.0.Alpha1-SNAPSHOT> ./bin/standalone.sh 
    =========================================================================
    
      JBoss Bootstrap Environment
    
      JBOSS_HOME: /Users/arungupta/tools/wildfly-9.0.0.Alpha1-SNAPSHOT
    
      JAVA: /Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home/bin/java
    
      JAVA_OPTS:  -server -XX:+UseCompressedOops  -server -XX:+UseCompressedOops -Xms64m -Xmx512m -XX:MaxPermSize=256m -Djava.net.preferIPv4Stack=true -Djboss.modules.system.pkgs=org.jboss.byteman -Djava.awt.headless=true
    
    =========================================================================
    
    Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=256m; support was removed in 8.0
    14:58:52,501 INFO  [org.jboss.modules] (main) JBoss Modules version 1.3.4.Final
    14:58:53,043 INFO  [org.jboss.msc] (main) JBoss MSC version 1.2.2.Final
    14:58:53,122 INFO  [org.jboss.as] (MSC service thread 1-6) WFLYSRV0049: WildFly 1.0.0.Alpha5 "Kenny" starting
    14:58:53,941 INFO  [org.jboss.as.server] (Controller Boot Thread) WFLYSRV0039: Creating http management service using socket-binding (management-http)
    14:58:53,957 INFO  [org.xnio] (MSC service thread 1-11) XNIO version 3.3.0.Beta1
    14:58:53,963 INFO  [org.xnio.nio] (MSC service thread 1-11) XNIO NIO Implementation Version 3.3.0.Beta1
    14:58:53,986 INFO  [org.jboss.as.security] (ServerService Thread Pool -- 49) WFLYSEC0002: Activating Security Subsystem
    14:58:53,986 WARN  [org.jboss.as.txn] (ServerService Thread Pool -- 50) WFLYTX0013: Node identifier property is set to the default value. Please make sure it is unique.
    14:58:54,000 INFO  [org.jboss.as.webservices] (ServerService Thread Pool -- 52) WFLYWS0002: Activating WebServices Extension
    14:58:54,000 INFO  [org.jboss.as.security] (MSC service thread 1-15) WFLYSEC0001: Current PicketBox version=4.0.21.Beta3
    14:58:54,000 INFO  [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 35) WFLYCLINF0001: Activating Infinispan subsystem.
    14:58:54,001 INFO  [org.jboss.as.naming] (ServerService Thread Pool -- 43) WFLYNAM0001: Activating Naming Subsystem
    14:58:54,006 INFO  [org.jboss.as.jsf] (ServerService Thread Pool -- 41) WFLYJSF0007: Activated the following JSF Implementations: [main]
    14:58:54,035 INFO  [org.wildfly.extension.io] (ServerService Thread Pool -- 34) WFLYIO001: Worker 'default' has auto-configured to 16 core threads with 128 task threads based on your 8 available processors
    14:58:54,056 INFO  [org.jboss.as.connector] (MSC service thread 1-9) WFLYJCA0009: Starting JCA Subsystem (IronJacamar 1.2.0.Beta3)
    14:58:54,071 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-10) WFLYUT0003: Undertow 1.1.0.Beta6 starting
    14:58:54,071 INFO  [org.wildfly.extension.undertow] (ServerService Thread Pool -- 51) WFLYUT0003: Undertow 1.1.0.Beta6 starting
    14:58:54,090 INFO  [org.jboss.as.connector.subsystems.datasources] (ServerService Thread Pool -- 30) WFLYJCA0004: Deploying JDBC-compliant driver class org.h2.Driver (version 1.3)
    14:58:54,100 INFO  [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-7) WFLYJCA0018: Started Driver service with driver-name = h2
    14:58:54,150 INFO  [org.jboss.as.naming] (MSC service thread 1-12) WFLYNAM0003: Starting Naming Service
    14:58:54,150 INFO  [org.jboss.as.mail.extension] (MSC service thread 1-7) WFLYMAIL0001: Bound mail session [java:jboss/mail/Default]
    14:58:54,155 INFO  [org.jboss.remoting] (MSC service thread 1-11) JBoss Remoting version 4.0.3.Final
    14:58:54,310 INFO  [org.wildfly.extension.undertow] (ServerService Thread Pool -- 51) WFLYUT0014: Creating file handler for path /Users/arungupta/tools/wildfly-9.0.0.Alpha1-SNAPSHOT/welcome-content
    14:58:54,349 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-8) WFLYUT0012: Started server default-server.
    14:58:54,372 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-5) WFLYUT0018: Host default-host starting
    14:58:54,449 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-3) WFLYUT0006: Undertow HTTP listener default listening on /127.0.0.1:8080
    14:58:54,701 INFO  [org.jboss.as.server.deployment.scanner] (MSC service thread 1-14) WFLYDS0013: Started FileSystemDeploymentService for directory /Users/arungupta/tools/wildfly-9.0.0.Alpha1-SNAPSHOT/standalone/deployments
    14:58:54,732 INFO  [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-9) WFLYJCA0001: Bound data source [java:jboss/datasources/ExampleDS]
    14:58:54,848 INFO  [org.jboss.ws.common.management] (MSC service thread 1-3) JBWS022052: Starting JBoss Web Services - Stack CXF Server 4.3.0.Final
    14:58:54,886 INFO  [org.jboss.as] (Controller Boot Thread) WFLYSRV0060: Http management interface listening on http://127.0.0.1:9990/management
    14:58:54,887 INFO  [org.jboss.as] (Controller Boot Thread) WFLYSRV0051: Admin console listening on http://127.0.0.1:9990
    14:58:54,887 INFO  [org.jboss.as] (Controller Boot Thread) WFLYSRV0025: WildFly 1.0.0.Alpha5 "Kenny" started in 2667ms - Started 193 of 295 services (135 services are lazy, passive or on-demand)

Note that is still very early in the development stages and workspace is constantly evolving. So things may be broken but you know that Red Hat is working actively on your favorite application server :-)

Some useful references …

Posted in techtip, wildfly | Tagged | Leave a comment

Java EE 7 Javadocs Download, Online, Tutorial, Samples (Tech Tip #42)

I was surprised when Google could not find Java EE 7 Javadocs download link clearly on the first page. StackOverflow was helpful here again, but even that was the last link on first page.

Now, I do know the location and can find my ways around. But this needs to be simplified and made more accessible for developers around the world.

So here are some usual Java EE 7 references:

Javadocs can also be installed on Dash as explained in Antonio’s blog.

And as usual, you can download WildFly or GlassFish to get started with Java EE 7!

Enjoy!

Posted in javaee, techtip | Tagged | 1 Comment

Using Infinispan as a persistency solution

Cross-posted from https://vaadin.com/blog/-/blogs/using-infinispan-as-a-persistency-solution. Thanks Fredrik and Matti for your permission!

Various RDBMSs are the de-facto standard for persistency. Using them is such a safe bet by architects that I dare say they are used in too many places nowadays. To fight against this, I have recently been exploring with alternative persistency options, like graph databases. This time I played with Infinispan.

In case you are not familiar with Infinispan, or distributed key/value data stores in general, you could think of it as a HashMap on steroids. Most essentially, the map is shared among all your cluster nodes. With clustering you can gain huge size, blazing fast access and redundancy, depending on how you configure it. There are several products that compete with Infinispan, like Ehcache and Hazelcast from OS world and Oracle Coherence from the commercial side.

Actually, Infinispan is a technology that you might have used without noticing it at all. For example high availability features of Wildfly heavily rely on Infinispan caches. It is also often used as a second level cache for ORM libraries. But it can also be used directly as a persistency library as such.

Why would you consider it as your persistency solution:

  • It is a lightning fast in-memory data storage
  • The stored value can be any serializable object, no complex mapping libraries needed
  • It is built from the ground up for a clustered environment – your data is safer and faster to access. It is very easy for horizontal scaling
  • It has multiple optional cache store alternatives, for writing the state to e.g. disk for cluster wide reboots
  • Not all data needs to be stored forever, Infinispan has built-in sophisticated evict rules
  • Possibility to use transactional access for ACID changes

Sounds pretty amazing, doesn’t it? And it sure is for certain use cases, but all technologies have their weaknesses and so do key/value data stores. When comparing to RDBMSs, the largest drawback is with relations to other entities. You’ll have to come up with a strategy for how to store references to other entities and searching based on related features must also be tackled. If you end up wondering these questions, be sure to check if Hibernate OGM could help you.

Also, doing some analysis on the data can be considered simpler, or at least more familiar, with traditional SQL queries. Especially if you end up having a lot of data, distributed on multiple nodes, you’ll have to learn the basics of MapReduce programming model to do any non trivial queries.

Using Infinispan in a web application

Although Infinispan is not tied to Wildfly, I decided to base my experiments on Wildfly. Its built in version is available for web applications, if you explicitly request it. The easiest method to do this is to add the following MANIFEST.MF entry to your war file. If you don’t want to spoil your project with obsolete files, just add it using a small war plugin config.

Dependencies: org.infinispan export

Naturally you’ll still want to add an Infinispan dependency to your application, but you can leave it to provided. Be sure to use the same version provided by your server, in Wildlfy 8, Infinispan version is 6.0.2. In a Maven project, add this kind of dependency declaration:

<dependency>
    <groupId>org.infinispan</groupId>
    <artifactId>infinispan-core</artifactId>
    <version>6.0.2.Final</version>
    <!-- Provided as we use the Infinispan provided by Wildfly -->
    <scope>provided</scope>
</dependency>

Before accessing Infinispan “caches”, you need to configure them. There are both programmatic and xml configurations available. With Wildfly, it is most natural to configure the Infinispan data store right into the server config. The “right” config file depends on how you are launching your Wildfly server. If you are testing clustering locally, you probably want to add something like this into your domain.xml, under the <subsystem xmlns="urn:jboss:domain:infinispan:2.0"> section.

<cache-container name="myCache" default-cache="cachedb">
    <transport lock-timeout="60000"/>
    <replicated-cache name="cachedb" batching="true" mode="SYNC"/>
</cache-container>

Note that with this config, the data is only stored within the memory of cluster nodes. To learn how to tweak cache settings or to set up disk “backup”, refer to the extensive Infinispan documentation.

To remove all Infinispan references from the UI code, I created an EJB that does all the data access. There I inject the CacheContainer provided by Wildfly and fetch the default cache in an init method.

@Resource(lookup = "java:jboss/infinispan/container/myCache")
CacheContainer cc;

Map<String, MyEntity> cache;

@PostConstruct
void init() {
   this.cache = cc.getCache();
}

I guess you are already wondering it: yes, the Map is the very familiar java.util.Map interface and the rest of the implementation is trivial to any Java developer. Infinispan caches extend the basic Map interface, but in case you need some more advanced features, you can also use Cache or AdvancedCache types.

The MyEntity in the previous code snippet is just a very simple POJO I created for the example. With Vaadin CDI usage, I can then inject the EJB to my UI class and do pretty much anything with it. The actual Vaadin code has no special tricks, just normal CDI spiced Vaadin code.

Based on this exercise, would I use Infinispan directly for persistency in my next project? Probably not, but for certain apps, without hesitation. I can also imagine certain hybrid models where some of the data is only in an Infinispan cache and some in traditional RDBMS, naturally behind ORM, taking the best of both worlds.

We’ll also be using Infinispan in our upcoming joint webinar with Arun Gupta from RedHat on September 8th, 2014. There we’ll show you a simple Vaadin application and how easy it can be to cluster it using Wildfly.

Posted in redhat | 1 Comment

Ceylon JUG Tour – US 2014

Ceylon is a statically and strong-typed programming language, created by Red Hat. Version 1.0.0 was released late last year and 1.1 is coming soon.

Gavin King (creator of Hibernate and CDI) and Stéphane Épardaud will be touring the USA East coast JUGs in October. At each venue, they will explain what Ceylon is, and why you will want to use it for your next production applications. The talks will be aimed at people who have never heard of Ceylon, or who have heard about it but want to know more. At the end of the evening you will be up to date with all that Ceylon is and has to offer.

Their complete itinerary is explained at https://community.jboss.org/docs/DOC-52715.

Don’t miss this opportunity. Make sure to show up at JUGs in your neighborhood and ask all your questions to the language creators!

Posted in conferences, redhat | Tagged , | Leave a comment

JBoss Middleware: Accelerate, Integrate, Automate

RHJB_Middleware_Logotype_RGB-Gray_0213_cw_300

Ever wondered how to understand multiple Red Hat JBoss middleware offerings ?

Mike Piech (@mpiech), GM of JBoss Middleware Business Unit explains them in a succinct video:

Its structured in three buckets:

Accelerate – Building things faster

  • JBoss Enterprise Application Platform provides an innovative modular, cloud-ready architecture, powerful management and automation, and world class developer productivity. It is Java™ EE 6 certified and features powerful yet flexible management, improved performance and scalability, and many new features to maximize developer productivity.
  • Red Hat JBoss Web Server is the only enterprise-class web server solution you need for large-scale websites and lightweight web applications. It provides a more secure and a more stable environment of open source web software, like Apache and Tomcat.
  • Red Hat JBoss Developer Studio provides superior support for your entire development lifecycle. It includes a broad set of tooling capabilities and support for multiple programming models and frameworks, including Java™ Enterprise Edition 6, HTML5, and many other popular technologies. It provides developer choice in supporting multiple JVMs, productivity with Maven, and in testing with Arquillian. It is fully tested and certified to ensure that all its plug-ins, runtime components, and their dependencies are compatible with each other.
  • Red Hat JBoss Data Grid gives you a straightforward approach to overcoming data obstacles, providing the ability to quickly access accurate, real-time information, meet high uptime requirements, streamline interaction with complex and rigid data tiers, and handle unprecedented transaction volumes.
  • Red Hat JBoss Portal is a proven solution for building high-impact, self-service applications

Integrate – Pull the pieces together

  • Red Hat JBoss Fuse is a flexible, small-footprint enterprise service bus (ESB) that enables rapid integration across the extended enterprise. Integration everywhere – on-premise or in the cloud.
  • Red Hat JBoss A-MQ is a flexible, high-performance messaging platform that delivers information reliably, enabling real-time integration and the Internet of Things (IOT).
  • Red Hat JBoss Fuse Service Works is a platform that creates reusable, changeable, and flexible business services that hide the complexity of connecting to different applications in your enterprise. It sets the stage for faster and easier cloud applications, mobile applications, and business process development projects.
  • Red Hat JBoss Data Virtualization is a lean, virtual data integration solution that unlocks trapped data and delivers it as easily consumable, unified, and actionable information. JBoss Data Virtualization makes data spread across physically diverse systems—such as multiple databases, XML files, and Hadoop systems—appear as a set of tables in a local database.

Automate – Automate significant parts of your business

  • Red Hat JBoss BRMS is a comprehensive platform for business rules management and complex event processing. Organizations can incorporate sophisticated decision logic into line-of-business applications and quickly update underlying business rules as market conditions change.
  • Red Hat JBoss BPM Suite is a comprehensive platform for business process management. It includes all the business rules and complex event processing (CEP) capabilities of Red Hat JBoss BRMS [business rules management system], along with advanced tools and runtime support for Business Process Model and Notation v2.0 (BPMN2)-compliant business processes.

And this is also shown in the following image:

accelerate-integrate-automate

Learn all about it at:

Posted in jboss, redhat | Tagged | Leave a comment

WildFly Administration Course by Alexis Hassler

Alexis Hassler (@alexishassler) is a software developer, specialized in Java and Java EE. He is using JBoss since version 2.0, more than twelve years ago. His business is to code for other companies or help them to improve the way they develop and deploy Java applications. He is co-leader of LyonJUG and helps to organize Mix-IT, an annual conference in Lyon.

He recently concluded a WildFly administration course. Here is a brief Q&A with him:

Q. You recently concluded a 4-day WildFly administration course. Tell us more about that.
A. This course will help you understand the operation, configuration principles of WildFly. The core of the course is 3 days long. It deals with installation, deployment, administration tools, security and tuning. The forth day is on clustering and is optional. The recently concluded session was the first one and was conducted on-site in Brussels.

Q. Who is this course targeted for ?
A.  The course is designed for application server administrators. But it is useful for developers and software architects too. In fact, it is useful for anybody who have to work with WildFly.

Q. Where can users register for this course ?
A. The schedule of the course is on my company web site : http://www.sewatech.fr/formation-wildfly.html. Registration can be done by e-mail : formation -at- sewatech.fr.

Q. How much of this course would be relevant for JBoss EAP users/customers ?
A. JBoss EAP 6 is based on JBoss AS 7, but a lot of administration features of the latest EAP has been added in WildFly 8. So if you have EAP 6.2 or 6.3, this course will match ~ 80%. If you have an older EAP, a JBoss AS 7 course would be better (http://www.sewatech.fr/formation-jboss-7.html). JBoss EAP users is not the main target of this course.  RedHat has some great courses on JBoss Middleware Development and JBoss Middleware Administration.

Q. How is your experience with JBoss / WildFly management tools ?
A. Comparing with older versions of JBoss (I mean before JBoss AS 6), WildFly management tools are a huge step ahead. You can choose your tool:

  • Web console
  • Command line
  • JMX
  • HTTP API
  • Java API

Jboss-cli is the most useful one. It allow an admin to automate the whole setup his application server. The HTTP API is great too, as it allow to make custom tools in any language. For example, you can build your own simplified admin console in pure JavaScript. I don’t really like the Java API because, it’s a detyped API and it doesn’t fit with a compiled-time typed language. Maybe a Groovy guy could make a nice DSL on top of it. All in one, the greatest thing is that the different tools are really consistent : same data and same logic to manipulate these data. If you learn jboss-cli, it’s really easy to understand the HTTP API.

Q. What tips would you give for users coming new to WildFly ?
A. If you know JBoss AS 7, it will be easy. WildFly 8 is just the next version. Read the changelog and everything will be fne. If you know older versions of JBoss AS, forget everything you know, and start from the beginning with a good book. If you know Tomcat, be prepared to discover the power to “fly”. And for everybody, learn the CLI tool.

Q. Which application servers developers should choose, for both development and deployment ?
A. It mainly depends on what you want to do. Tomcat can be great too, because it’s really simple. When it comes with Java EE, TomEE is a very nice application server but lacks of administration tools. For Glassfish, we will see with the next versions if the current quality is maintained or if it comes back to a simple RI software. So, OK, WildFly is my favorite choice : great module system, great admin tools and great community.

Q. What resources do you generally refer to when looking for help on WildFly ?
A. For me, the main resource are the official documentation (https://docs.jboss.org/author/display/WFLY8/) and Francesco Marchioni’s blog (http://www.mastertheboss.com/). For a beginner, Francesco’s book WildFly 8, administration guide would be easier. The last resource I would recommend is the WildFly section on my wiki (http://jtips.info/index.php?title=Cat%C3%A9gorie:WildFly), but it’s in French.

 

Posted in wildfly | Leave a comment

JBoss EAP 6.3 now available!

JBoss EAP 6.3 is now available!

jboss-eap-logo

This release brings continued progress on the road to making EAP the most manageable and secure Java EE 6-compliant Application Server for traditional and cloud based workloads. It also continues the core themes of the EAP 6 major version family of better user experience, improved manageability, and enhanced performance.

Where to download ?

For current customers with active subscriptions, the Beta can be downloaded from the customer support portal.

For community users developing applications that will be deployed on a supported EAP, the bits will soon be made available from www.jboss.org/products/eap under development terms & conditions, and questions can be posed to the EAP Forum.

Where are docs ?

Complete documentation is available on customer support portal, and here are quick links:

What’s new ?

  • PicketLink enhancements
  • Domain recovery improvements
  • Support for PKCS11 keystores
  • Web management console
    • Patching available
    • Testing DataSources
    • Unified navigation labels
    • Opt-in analytics collection
  • Deployment overlay enhancement
  • Support for Microsoft Windows Server 2012 R2 and Red Hat Enterprise Linux 7

Complete list of new features is described here.

Some of the features are available in Tech Preview mode such as WebSockets, adding/removing modules using JBoss CLI, multi-JSF and many more.

Features like JBoss OSGi, STOMP with HornetQ, mod_jk and mod_cluster with Apache on RHEL 7 and some others are not supported.

If you are looking for a Java EE 7-compliant Application Server, then download WildFly.

Posted in jboss, redhat | Leave a comment

Adding Java EE 7 Batch Addon to JBoss Forge ? – Part 7 (Tech Tip #41)

This is the seventh part (part 1part 2, part 3, part 4, part 5) of a multi-part video series where Lincoln Baxter (@lincolnthree), George Gastaldi (@gegastaldi) and I are interactively building a Forge addon to add Java EE 7 Batch functionality. So far, here is what different parts have shown:

  • Part 1 showed how to get started with creating an addon, add relevant POM dependencies, build and install the addon using Forge shell, add a new command batch-new-jobxml, and add --reader--processor--writer parameters to the newly added command.
  • Part 2 showed how to identify classes for each CLI parameter that already honor the contract required by the Batch specification.
  • Part 3 showed how parameters can be made required, created templates for reader, processor, and writer, validated the specified parameters.
  • Part 4 added a new test for the command and showed how Forge can be used in debug mode.
  • Part 5 fixed a bug reported by a community member and started work to make processor validation optional.
  • Part 6 upgraded from 2.6.0 to 2.7.1 and started work on reader, processor, and writer template files.

This part shows:

  • Merged the request by George in the workspace
  • Reader, processor, and writer source files are created if they do not exist

Enjoy!

As always, the evolving source code is available at github.com/javaee-samples/forge-addons.

Next episode will add a new test for this functionality.

Posted in jboss, techtip | 1 Comment