Java EE 7, JBoss, WildFly, Devoxx4Kids, and Parties at JavaOne 2014

JavaOne 2014 is about a week away, although some of festivities will start next Friday! This is going to be my 16th JavaOne in as many years and I’ve really enjoyed participating in each one of them. As always, there is great content lined up with rockstar speakers. This conference is a confluence of movers and shakers in the Java world and provides plenty of opportunities to engage with them. This is going to be my first year as Red Hatter and looking forward to catching up with friends and colleagues.

And in case you are wondering, and care about it, here are my engagements for that week:

Saturday, Sep 27

Devoxx4Kids Day

Sunday, Sep 28

8am – 9:30am, Java Champions Brunch
7pm – 11:30pm, NetBeans Party
8pm – 11pm: Java EE Appreciation Event

Monday, Sep 29

8:30am – 10:30am Java EE 7 Soup to Nuts Tutorial [TUT1952]
11:30pm – 12:30pm Meet the Experts on Java EE and HTML5 Enterprise Application Development
1:30pm – 2:00pm Java EE 7 Essentials book signing at O’Reilly Booth

Tuesday, Sep 30

12:30pm – 1:30pm: Lessons learned from real-life Java EE 7 Deployments [CON2450]
2:30pm – 4pm: Java EE Hackergarten
6pm – 9pm: Oracle Authors Appreciation Party
7pm – 9pm: JavaOne IGNITE
7pm – 10pm: PartyOne
7pm – 9:30: Java Champions Social
8pm – 8:45pm: Technology Evangelists Gathering [BOF12166]

Wednesday, Oct 1

8:30am – 10:30am: Devoxx4Kids for Parents Tutorial [TUT1878]
1pm – 1:30pm: Book signing on Java EE and HTML5 Enterprise Application Development book (OOW bookstore in Moscone South, Upper Hall Lobby)
4pm – 6:30pm: #JavaOneStreak meetup, Hilton San Francisco Union Square, Sutter

I’ll also be running my own “hallway track” and so feel free to meet there. Of course, you can catch me at Red Hat booth as well!

There are lots of Red Hat speakers and sessions at the conference as well. And if you are not able to attend a Red Hat session then you can check out the mini-sessions in the exhibit hall.

See ya there!

Advise to Microsoft on Mojang and Minecraft

Microsoft bought Mojang for $2.5 billion, wow! Here is official press release by Microsoft.

minecraft-logo

The game is extremely popular within 8-14 years of age range, but also within other ages, including adults, as well. The education community has been extremely excited because of all the opportunities it provides to engage kids at an early age and teach them Java programming, object-oriented, and mathematical concepts by “modding” the game. The community is highly engaged, passionate and diverse. This “global phenomenon” indeed binds the community very well and gives them a common language to talk with each other. My son has been attending Minecraft-themed birthday parties for last 3 years. There are halloween costumes, 3d printed Minecraft worlds, tshirts, hoodies,  hats, slippers, swimming trunks, plates, spoons, and you name it, its all there!

On a personal level, My son and I’ve personally delivered multiple Minecraft Modding workshops around the San Francisco Bay Area. This workshop has also been delivered around the world by Devoxx4Kids volunteers, and even translated in German, Dutch, and French.

My first reaction to this purchase was a grandpa company that is desperate to be innovative just used their cash power to buy a company behind one of the most innovative game. I felt really miserable, especially knowing that the game is written in Java. Microsoft has no significant history of delivering or maintaining Java programs particularly. I may be wrong, but Microsoft J Sharp is dated 2006. And Visual J# was removed from Visual Studio a few years ago as well. Heck, you even need to install JDK on a Microsoft Windows machine.

Microsoft is known to provide tight integration within their portfolio. So another thought that came was that Microsoft will start integrating Silverlight, .NET, Office 365, Exchange integration, and their complete slew of Windows-specific technologies in the game. May be all backed Microsoft Access, Sharepoint, and Azure, oh no!

Another thought came to mind was that the newer features of the game will be released on XBox first, and then probably limp along on PC and other platforms later. May be make the game exclusive on Windows-based mobile phones, I hope not!

In general, the younger generation seems to not be very excited with Microsoft ecosystem. Anything ranging from virus-infected Windows, legacy Internet Explorer, to mobile phones. At least, that’s the reaction I’ve seen and heard from my family, friends, and hackathons around around the world. Players play Minecraft if they have XBox, they don’t buy XBox because they want to play Minecraft. The experience on PC/Desktop is pretty good IMHO. Although you can easily host a server and then join from any device, which is the cool part about the game.

I seriously hope, I’m wrong on all these initial, may be somewhat emotional, reactions. I really hope so!

Phil Spencer (head of Xbox, @XboxP3) has made it clear that “we plan to continue to make Minecraft available across platforms – including iOS, Android and PlayStation, in addition to Xbox and PC. ” I hope they stick to their promise on PC at the least ;-)

Notch (@notch) has left Mojang already, and so have other co-founders. Minecraft was not intended to grow this big but it turned out to be, and he does not want to be responsible for it now. I respect that he likes to enjoy building games, and would continue to do so. The BIG payoff is accidental, and will allow him to focus his energy on what he is good at.

As father of an avid modder, an educator, Java evangelist, Java Champion, JUG leader, software engineer, here is my wish list for Microsoft to help with Minecraft:

  1. Maintain Minecraft on PC/desktop as a first class game. Make sure the latest snapshots are always available on PC first than any other platforms.
  2. Mojang has talked about delivering an official modding API for the past 2+ years but the status is unclear. It has been very disappointing to see Bukkit dying but fortunately there is Forge and other modding platforms. Deliver a formal modding API within next one year would really allow Microsoft to gain huge favors.
  3. Provide simpler tools/IDE that allow to create mods easily. Eclipse, IntelliJ, and NetBeans are too complex to be used by young developers. Please do not require Visual Studio or any other similar heavy weight tools to be downloaded in order to facilitate it though.
  4. Start bundling JDK with Windows machine so that Minecraft can run out-of-the-box instead of requiring to download it separately. Work on your relationship with Oracle, and help developers instead of getting stuck in your own rut.
  5. Keep Minecon as a separate conference. Do NOT mix it with other Microsoft shows. And organize it more frequently around the worlds.
  6. Start a formal Minecraft User Group (MUG) community where players can open local user groups and exchange ideas.
  7. MVP could now also embrace Minecraft Valueable Player.
  8. Open source Minecraft ?
  9. Do not introduce any Microsoft technologies in the game, keep it true Java on PC.
  10. Mojang launched Realms a few months. Make it more widely accessible.

If there is one thing Microsoft need to do about Minecraft, that is to at least maintain the same experience of the game on PC, or only make it better. DON’T screw up there, otherwise you’ll completely loose the community.

I’m happy that a big company is behind the game now. Hopefully, you’ll take the game to new heights, empower the community more, and truly help address the issues with your experience.

Good luck Microsoft!

Load Balance WebSockets using Apache HTTPD (Tech Tip #48)

JBoss EAP 6.3 provides a technology preview of WebSocket and WildFly have supported them as part of Java EE 7 compliance.

github.com/javaee-samples/javaee7-samples/tree/master/websocket provide tons of Java EE 7 samples that run on WildFly. If you are interested in similar functionality on JBoss EAP 6.3 then github.com/jboss-developer/jboss-eap-quickstarts/tree/6.4.x-develop/websocket-hello is a quickstart. In addition, there are a few more samples at github.com/arun-gupta/jboss-samples/tree/master/eap63.

One of the common questions asked related to WebSockets is how to how to load balance  them. This Tech Tip will explain that for WildFly and JBoss EAP 6.3.

First, what are the main components ?

  • At least Apache HTTPD 2.4.5 is required. Now HTTPD binaries are not available for Mac but fortunately compiling instructions are explained clearly in Tech Tip #45.
  • mod_proxy_wstunnel is an Apache module that provides support for tunneling of Web Socket connections to a backend Web Sockets server, such as WildFly or JBoss EAP. It is a support module to mod_proxy that provide support for a number of popular protocols as well as several different load balancing algorithms. The connection is automagically upgraded to a WebSocket connection.  And all the modules are already included in the modules directory.
  • mod_proxy_balancer module is required that provides load balancing for HTTP and other protocols.

Let’s go!

  1. Download and unzip WildFly 8.1.
  2. Start WildFly 8.1 in domain mode using ./bin/domain.sh.
  3. Download this chat sample, rename the file to “chat.war” and deploy to “main-server-group” as:
    ~/tools/wildfly-8.1.0.Final/bin/jboss-cli.sh -c --command="deploy chat.war --server-groups=main-server-group"

    The only difference from the original Java EE 7 WebSocket Chat sample is the addition of System.getProperty("jboss.node.name") to display the name of WildFly instance serving the application. The source code is available at github.com/arun-gupta/wildfly-samples/tree/master/websocket-loadbalance.

  4. Uncomment the following lines in /usr/local/apache2/conf/httpd.conf:
    LoadModule lbmethod_byrequests_module modules/mod_lbmethod_byrequests.so
    LoadModule proxy_module modules/mod_proxy.so
    LoadModule proxy_wstunnel_module modules/mod_proxy_wstunnel.so
    LoadModule proxy_balancer_module modules/mod_proxy_balancer.so

    This will enable all the required modules.

  5. Add the following code fragment at the end of “httpd.conf”:
    <Proxy balancer://mycluster>
        BalancerMember ws://localhost:8080
        BalancerMember ws://localhost:8230
    </Proxy>
    ProxyPass /chat balancer://mycluster/chat

    Proxy is a container for proxied resources and is creating a load balancing group in this case using balancer directive. BalancerMember adds a member to this load balancing group.  ProxyPass is a standard directive that maps remote servers running on different ports into the space of the local server. In this case, WildFly is started in domain mode and so starts two instances on port 8080 and 8230. Both of these instances are mapped to localhost:80, which is where Apache HTTPD is running by default.

The deployed chat sample is now accessible at localhost:8080/chat (first instance in the managed domain), localhost:8230/chat (second WildFly instance in the managed domain), and localhost/chat (via Apache HTTPD).

Now even if you kill one of the WildFly instances, the other instance will continue to serve the client. Note, this only gives application availability as there is no session failover in this.

This was also verified on JBoss EAP 6.3 and there are a few differences:

  1. Use the sample from github.com/arun-gupta/jboss-samples/tree/master/eap63/websocket-chat instead.
  2. The generated archive name is different and so the command would look slightly different too:
    ~/tools/jboss-eap-6.3/bin/jboss-cli.sh -c --command="deploy websocket-chat-1.0-SNAPSHOT.war --server-groups=main-server-group"
  3. Configure “httpd.conf” as:
    <Proxy balancer://mycluster>
        BalancerMember ws://localhost:8080
        BalancerMember ws://localhost:8230
    </Proxy>
    ProxyPass /websocket-chat-1.0-SNAPSHOT balancer://mycluster/websocket-chat-1.0-SNAPSHOT

And that’s it!

Watch this live in action:

An important point to understand is that there is no concept of “sticky sessions” in WebSocket as, unlike HTTP, there is a direct and “permanent” connection between the client and the server in this case.

Enjoy!

WildFly with a custom configuration in OpenShift (Tech Tip #47)

WildFly instances can be easily started in OpenShift. Tech Tip #7 shows how to spin up an instance of WildFly in OpenShift. Tech Tip #21 explained how to get started using JBoss Tools.

Now this WildFly instance is started with the stock configuration.xml. However some times you may want to configure the containers or specify additional configuration information in this file. This Tech Tip will show you how to do that.

Let’s go!

  1. Start a WildFly instance as explained in Tech Tip #7.
  2. On the application page, clone the workspace associated with this application. The command will look something like:
    git clone ssh://XXXXXXXXXX@test-milestogo.rhcloud.com/~/git/test.git/
  3. This workspace has .openshift/standalone.xml file. Edit this file to meet your need. For example, if you want to use Infinispan as a persistency solution in standalone mode, then you’ll add the following code fragment:
    <cache-container name="myCache" default-cache="cachedb">
        <local-cache name="cachedb"/>
    </cache-container>

    under <subsystem xmlns="urn:jboss:domain:infinispan:2.0"> section.

  4. Commit and push the change:
    config> git commit standalone.xml -m"additional configuration elements"
    [master cef567d] additional configuration elements
     1 file changed, 1 deletion(-)
    config> git push

    This will automatically restart the cartridge and show the output as:

    Counting objects: 9, done.
    Delta compression using up to 8 threads.
    Compressing objects: 100% (5/5), done.
    Writing objects: 100% (5/5), 656 bytes | 0 bytes/s, done.
    Total 5 (delta 1), reused 0 (delta 0)
    remote: Stopping wildfly cart
    remote: Repairing links for 1 deployments
    remote: Building git ref 'master', commit cef567d
    remote: Found pom.xml... attempting to build with 'mvn -e clean package -Popenshift -DskipTests'
    remote: Apache Maven 3.0.4 (r1232336; 2012-12-18 14:36:37-0500)
    remote: Maven home: /usr/share/java/apache-maven-3.0.4
    remote: Java version: 1.8.0_05, vendor: Oracle Corporation
    remote: Java home: /var/lib/openshift/XXXXXXXXXX/wildfly/usr/lib/jvm/jdk1.8.0_05/jre
    remote: Default locale: en_US, platform encoding: ANSI_X3.4-1968
    remote: OS name: "linux", version: "2.6.32-431.23.3.el6.x86_64", arch: "i386", family: "unix"
    remote: [INFO] Scanning for projects...
    remote: [INFO]                                                                         
    remote: [INFO] ------------------------------------------------------------------------
    remote: [INFO] Building test 1.0
    remote: [INFO] ------------------------------------------------------------------------
    remote: [INFO] 
    remote: [INFO] --- maven-clean-plugin:2.4.1:clean (default-clean) @ test ---
    remote: [INFO] 
    remote: [INFO] --- maven-resources-plugin:2.5:resources (default-resources) @ test ---
    remote: [debug] execute contextualize
    remote: [INFO] Using 'UTF-8' encoding to copy filtered resources.
    remote: [INFO] Copying 1 resource
    remote: [INFO] 
    remote: [INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ test ---
    remote: [INFO] Nothing to compile - all classes are up to date
    remote: [INFO] 
    remote: [INFO] --- maven-resources-plugin:2.5:testResources (default-testResources) @ test ---
    remote: [debug] execute contextualize
    remote: [INFO] Using 'UTF-8' encoding to copy filtered resources.
    remote: [INFO] skip non existing resourceDirectory /var/lib/openshift/XXXXXXXXXX/app-root/runtime/repo/src/test/resources
    remote: [INFO] 
    remote: [INFO] --- maven-compiler-plugin:2.3.2:testCompile (default-testCompile) @ test ---
    remote: [INFO] No sources to compile
    remote: [INFO] 
    remote: [INFO] --- maven-surefire-plugin:2.10:test (default-test) @ test ---
    remote: [INFO] Tests are skipped.
    remote: [INFO] 
    remote: [INFO] --- maven-war-plugin:2.3:war (default-war) @ test ---
    remote: [INFO] Packaging webapp
    remote: [INFO] Assembling webapp [test] in [/var/lib/openshift/XXXXXXXXXX/app-root/runtime/repo/target/test]
    remote: [INFO] Processing war project
    remote: [INFO] Copying webapp resources [/var/lib/openshift/XXXXXXXXXX/app-root/runtime/repo/src/main/webapp]
    remote: [INFO] Webapp assembled in [341 msecs]
    remote: [INFO] Building war: /var/lib/openshift/XXXXXXXXXX/app-root/runtime/repo/deployments/ROOT.war
    remote: [INFO] ------------------------------------------------------------------------
    remote: [INFO] BUILD SUCCESS
    remote: [INFO] ------------------------------------------------------------------------
    remote: [INFO] Total time: 8.365s
    remote: [INFO] Finished at: Tue Aug 26 18:01:19 EDT 2014
    remote: [INFO] Final Memory: 9M/113M
    remote: [INFO] ------------------------------------------------------------------------
    remote: Preparing build for deployment
    remote: Deployment id is 336d5b75
    remote: Activating deployment
    remote: Deploying WildFly
    remote: Starting wildfly cart
    remote: Found 127.12.40.129:8080 listening port
    remote: Found 127.12.40.129:9990 listening port
    remote: /var/lib/openshift/XXXXXXXXXX/wildfly/standalone/deployments /var/lib/openshift/XXXXXXXXXX/wildfly
    remote: /var/lib/openshift/XXXXXXXXXX/wildfly
    remote: CLIENT_MESSAGE: Artifacts deployed: ./ROOT.war
    remote: -------------------------
    remote: Git Post-Receive Result: success
    remote: Activation status: success
    remote: Deployment completed with status: success
    To ssh://XXXXXXXXXX@test-milestogo.rhcloud.com/~/git/test.git/
       b08ebff..cef567d  master -> master
    

Now the WildFly instance in OpenShift will use the updated configuration file.

You can even verify this by logging into your application as:

ssh XXXXXXXXXX@test-milestogo.rhcloud.com

And checking for the updated elements in wildfly/standalone/configuration/standalone.xml file.

Alternatively, you can ssh into your instance and use the JBoss CLI to make updates to your standalone.xml file.

Enjoy!

Java EE 7 Real World Experience: Campground Management with Tipi.camp

tipicamp-logo

Tipi.camp provides a simple campground management software and targets 25,000+ independent campgrounds all over Europe. It provides a customer-friendly booking-portal and a RESTful API for partners to integrate. The project was conceived in September 2013 when Christoph returned from vacation, disappointed because of the missed booking for their tent. And now he has created a new solution connecting campers and campgrounds with each other.

The website offers a SaaS where campgrounds can register their camp sites and campers can look at the availability of these campgrounds, check out their calendar, pick a site and make a reservation. It is also available for on-site installation if you prefer running it on your domain. Think of it as koa.com, but available to all the independent campgrounds and much more modern ;)

The landing page is certainly very fancy:

tipicamp-opening-page

Websites of smaller campgrounds are typically characterized by low data maintenance and absence of a booking possibility. tipi.camp has advantages:

  • Easy-to-use portal for campground owners and campers
  • Campground owner administrate and book his sites independently
  • Customer data management
  • External sales channels, for example booking.com, can be connected to sell the log cabins
  • RESTful API it is also possible to handle larger individual installations

Campgrounds get their own portal, reservations, channel management, email and much more for €1/day if they are located in Europe or $1/day if they are in US. Each campground with an Internet connection and browser (whether computer or iPad) can use the software.

In terms of the overall flow, campground owner register their campground with tipi.camp. Traveler checks out the calendar and books the campground using the responsive portal.

tipicamp-architecture

 

Check out the welcome page:

tipicamp-welcome

Campers can search through the available camps and then look at the calendar of a particular camp:

tipicamp-calendar

Pick a particular site on the campground:

tipicamp-maps

And then checkout to make the payment:

tipicamp-checkout

This website is built using Java EE 7:

tipicamp-technology

 

Here is a brief description of the technology stack:

  • Presentation
    • JavaServer Faces + Expression Language. Different templates are used for desktop and iPad apps. JSF Template Library might be used to provide a fully customized portal for the campground owners later.
    • Security: JAAS Principal + JDBC realm
    • Bean discovery mode=”all”
  • Middle Tier
    • EJB for business boundaries
    • Servlets with JSON for web hooks: response from Paypal and Sendgrid
    • JAX-RS for exposing API to partners
  • Backend
    • JPA + Bean Validation, use @Index for database generation during development. Flyway API for database migrations in production.
    • Concurrency: Calculation of statistics and sending messages, Sendgrid takes ~1-4 seconds to send messages
    • Using @Startup @Singleton @Schedule to run a job at pre-defined time

Technologies from outside the platform were:

  • Primefaces 5 for the GUI and Bootstrap for the responsive Enduser-Portal.
  • Sendgrid API for sending mails. This is required as opposed to JavaMail because specific meta information needs to be added to each email.
  • Misc apache commons (eq. FileUtils.writeByteArrayToFile or IOUtils.toByteArray) – there are only a few sections.
  • Flyway API for database migrations
  • Junit with Derby – for testing

Toolset

  • JDK 8
  • IntelliJ 13.1 with Maven
  • Wildfly 8.1.0.Final – Single instance of WildFly is used. The app was previously deployed on GlassFish.
  • Apache httpd is used to:
    • performance-tuning with KeepAlive, mod_expires for the images and the compression
    • easy SSL configuration
    • handle more WildFly under 1 hostname with the mod_proxy
    • mod_redirect for redirect all http requests to the app to https
  • Github
  • Jenkins
  • loader.io for Load-Testing
  • Currently the application is deployed on a self-hostet Linux-Server in the hetzner.de data center.

Wish list for Java EE 8

  • Most used Apache Commons Libs
  • @Temporal works with LocalDate and LocalDateTime
  • Batch processing API does support generics

And here are supporting quotes on Java EE 7

the technology is perfect. very productive with java/ee7, i’m and our customers are very happy with java ee7. With the technology, really everything is possible.

And on WildFly:

superb, unique product

So, do you want to start on this terrific two combination of Java EE 7 + WildFly ?

Download WildFly 8.1 today, learn the technology by reading/trying Java EE 7 samples, browse through Java EE 7 resources.

Or if you want to be on the bleeding edge, check out WildFly 9.0.

Many thanks to Christoph Gapp (info@tipi.camp) and Adam Bien (@adambien) for providing all the answers!

Are you using Java EE 7 and WildFly to deploy your projects ? Would love to feature you here! Send me an email or leave a comment on the blog.

 

Cloud in a Box: OpenShift Online in VirtualBox (Tech Tip #46)

OpenShift-logo

OpenShift is Red Hat’s PaaS platform and comes in three flavors:

  • Origin is the Community PaaS offering. You can explore the community-driven open source upstream of OpenShift. Join the community.
  • Online is the Public PaaS offering. Host your applications in the public cloud with automated provisioning, management, and scaling of applications. Sign up for free.
  • Enterprise is the Private PaaS offering. Leverage PaaS in your own data centers and private cloud. Request evaluation.

This Tech Tip will show how you can setup a Virtual VM running with OpenShift Online. Instructions at openshift.github.io/documentation/oo_deployment_guide_vm.html are pretty self explanatory. Here are the exact ones that I followed on Mavericks:

  1. Download VM:
    curl -O https://mirror.openshift.com/pub/origin-server/release/4/images/openshift-origin.tgz
  2. Unpack VM files
    tar xzvf ~/Downloads/openshift-origin.tgz 
    x OpenShift Origin v4/
    x OpenShift Origin v4/OpenShift Origin v4.nvram
    x OpenShift Origin v4/OpenShift Origin v4.vbox
    x OpenShift Origin v4/OpenShift Origin v4.vmsd
    x OpenShift Origin v4/OpenShift Origin v4.vmx
    x OpenShift Origin v4/OpenShift Origin v4.vmxf
    x OpenShift Origin v4/._origin-vm.vmdk
    x OpenShift Origin v4/origin-vm.vmdk
  3. Follow the instructions to create a VirtualBox instance. Create a new hard drive using the unzipped origin-vm.vmdk file.

    IMPORTANT: Instead of 4.2.4 to add bridged networking, setup a host-only network using 4.2.5.

  4. Boot the VM to see the output as:

    openshift-online-techtip46

    Type “5” to exit to the command prompt.

  5. VM comes pre-configured with Avahi DNS service and so now you can access OpenShift console at broker.openshift.local and seen as:

    openshift-origin-console-techtip46

    The username/password are “demo”/”changeme”.

  6. Create an SSH tunnel into the VM as:
    ssh -f root@broker.openshift.local -L 8080:localhost:8080 -N

    Password is “changeme”. OpenShift admin console is now accessible at localhost:8080/admin-console and looks like:

    openshift-console-techtip46

    More details about Admin Console are well documented.

Many thanks to Harrison for guiding me through creating this process!

Ask your OpenShift questions at stackoverflow or follow them at @openshift.

Enjoy!

 

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!

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!

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 …

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!