Enterprise grade Java.
You'll read about Conferences, Java User Groups, Java, Integration, Reactive, Microservices and other technologies.

Friday, May 29, 2015

Java EE Deployment Scenarios for Docker Containers

13:20 Friday, May 29, 2015 Posted by Unknown No comments:
, ,
I've been posting some content around Docker since a while and I like to play around with containers in general. You can find some more information about how to run Docker-Machine on Windows and also showed you how to use the Docker 1.6 client. One of the first blog posts was a compilation of all kinds of resources around Java EE, Docker and Maven for Java EE developers. Working more detailed and often with containers brings up the question about how Java EE applications should be distributed and how developers should use containers. This tries to clarify a little and give you a good overview about the different options.

Base Image Image vs. Custom Image and Some Basics
Most likely, your application server of choice is available on the public registry, known as docker hub. This is true for WildFly. The first decision you have to make is, if you want to use one of the base images or if you are going to bake your own image. Running with the base is pretty much:

docker run -p 8080 -it jboss/wildfly
and your instance is up and running in a second, after the base image was downloaded. But what does that mean? And how does it work? At the heart of every container is Linux. A teensy one. In a normal Linux, the kernel first mounts the root File System as read-only, checks its integrity, and then switches the whole rootfs volume to read-write mode. The teensy Linux in a Docker container does that differently. Instead of changing the file system to read-write mode, it takes advantage of a union mount to add a read-write file system over the read-only file system. In fact there may be multiple read-only file systems stacked on top of each other. If you look at the jboss/wildfly image, this is what you get on first sight:
You see four different levels in this picture. Let's not call them layer, because they aren't yet. This is the hierarchy of images which are the base for our jboss/wildfly image. Each of those images is composed out of a Dockerfile. This is an empty text file with a bunch of instructions in it. You can think of it as a sort of pom-file which needs do be processed through a tool called "Builder". It can contain a variety of commands and options to add users, volumes, add software, downloads and many many more.  If you look at the jboss/wildfly Dockerfile you see the commands that compose the image:

# Use latest jboss/base-jdk:7 image as the base
FROM jboss/base-jdk:7

# Set the WILDFLY_VERSION env variable
ENV WILDFLY_VERSION 8.2.0.Final

# Add the WildFly distribution to /opt, and make wildfly the owner of the extracted tar content
# Make sure the distribution is available from a well-known place
RUN cd $HOME && curl http://download.jboss.org/wildfly/$WILDFLY_VERSION/wildfly-$WILDFLY_VERSION.tar.gz | tar zx && mv $HOME/wildfly-$WILDFLY_VERSION $HOME/wildfly

# Set the JBOSS_HOME env variable
ENV JBOSS_HOME /opt/jboss/wildfly

# Expose the ports we're interested in
EXPOSE 8080

# Set the default command to run on boot
# This will boot WildFly in the standalone mode and bind to all interface
CMD ["/opt/jboss/wildfly/bin/standalone.sh", "-b", "0.0.0.0"]
The first line defines the base from which the image is derived. Looking at the jboss/base-jdk:7 Dockerfile reveals the root which is jboss/base.
Now imagine, that every single one of those lines does something to the filesystem. Most obvious example is a download. It adds something to it. But instead of writing it to an already mounted partition, it get's stacked up as a new layer. Looking at all the layers of jboss/wildfly this sums up to 19 unique layers with a total size of 951mb.

Using the base image, you can expect to have a default configuration at hand. And this is a great place to start. We at JBoss try to make our projects (and products too!) usable out-of-box for as many use cases as we can, but there is no way that one configuration could satisfy everyone’s needs. For example, we ship 4 flavors of the standalone.xml configuration file with WildFly since there are so many different deployment scenarios. But this is still not enough. We need to be able to tweak it at any point. The jboss/wildfly image is not an exception here.
Creating a custom image with

# Use latest jboss/wildfly as a base
FROM jboss/wildfly

is your first step into the word of a customized image. If you want to know, how to do that, there is an amazing blog post which covers almost all the details.

Java EE Applications - On Docker
One of the main principles behind Docker is "Recreate — Do Not Modify ". With a container being a read-only, immutable piece of infrastructure with very limited capabilities to be changed at runtime, you might be interested in the different options you have to deploy your application.

Dockerize It
This is mostly referred to as "custom image" beside the needed configuration changes, you also add the binary of your application as a new layer your image.

RUN curl -L https://github.com/user/project/myapp.war?raw=true -o /opt/jboss/wildfly/standalone/deployments/myapp.war
Done. Build, Push and run your custom image. If one instance dies, don't worry and fire up a new one.

Drawbacks:
- No re-deployments. Every
- No changes
- New version, new image version
- Not the typical operations model for now.
- Might need additional tooling (plugins for Maven/Jenkins)

Advantages:
- The Docker Way
- Easy to integrate into your project build.
- Easy to roll-out and configure

Containers as Infrastructure
There's no real term for it. It basically means that you don't care how your infrastructure is run. This might be the called old-fashioned operations model. You will need to have some kind of access to the infrastructure. Either a shared filesystem with the host to deploy applications via the deployment scanner or the management ports need to be open in order to use the CLI or other tooling to deploy your applications into the container.

Drawbacks:
- More complex layering to keep state in containers
- Not the Docker Way
- Not fancy.
- Centralized ops and administration

Advantages:
- Hardly any change to what you're used to as a developer in enterprises today
- Doesn't need to be integrated into your build at all. It's just an instance running somewhere
- No additional tooling.

Recommendation
This is hard. I'd suggest, that you look into what fits best for your situation. Most of the enterprise companies might tend to stick with the Containers as Infrastructure solution. This has a lot of drawbacks for now looking at it from a developers perspective. A decent intermediate solution might be OpenShift v3 which will optimize operations for containers and bring a lot of usability and comfort to the Java EE PaaS world.
If you are free to make a choice, you can totally go with the "Dockerize" way. Keep in mind, that this is a vendor-lock-in as of today and some more promising and open solutions on the horizon already. 

Wednesday, May 20, 2015

My Toddler Knows More About Computers Than I Do. Help?

20:17 Wednesday, May 20, 2015 Posted by Unknown No comments:
, , ,
This is a feature post written by Tonya Rae Moore (@tonyaraemoore, website). Long years working for Oracle as the caretaker for Java.net, she went over to help with kick-starting ZEEF marketing. Working with communities and individuals has always been her passion. Strong believer in equality in tech and fighting anything which doesn't respect minorities. Marketer at heart, knows everything about beer, and is a loving mother married to a sport talk-show host. Member of the CJUG, helping promote Java developers and technologies in Chicago.
We both have toddlers equal age and talked quite a bit about their excitement for our daily work tools and how much is too much and some other parenting things. Here are the answers.

Until fairly recently, I thought of myself as a computer-savvy American. I learned BASIC in grammar school, became proficient in MS Office as it grew and changed, and made chat room mistakes early. I became friends with programmers/engineers/system architects, asked questions, and learned from the answers. I was the person who first built, and later picked out the computers for my parents and less-savvy friends. Then I started working for a giant tech company, running a website that caters to users of a specific programming language. I didn’t know anything about it, but I asked even more questions, and eventually how to translate what the answers to those questions meant in Normal Person Language. I hung in there, and I learned even more. I didn’t learn how to be an engineer, because the engineers are better at engineering that I ever could be.  But, I got pretty good at translating Computer People Language into Normal People Language. I was pretty sure I was a Computer Person, or at least adjacent to them.

Then I had a child. A wonderful, bright little boy who is currently three-years-old, and is proficient on my smartphone. So, here is your first lesson: If you think you know something about computers, just stop right now. If you are correct, and you have a programming background, this is not your article. But if, like me, you suddenly feel like the generational gap is widening around your laptop, there is help available. There are two kinds of folks from here on out: Them and Us. They know what they’re talking about, and we, most assuredly, aren’t even sure where to start. That can be fixed.

The second lesson is: There is a very real probability that your child(ren) will become/already is one of Them instead of one of Us. And that’s GOOD.

Being computer-savvy in the modern world doesn’t mean our kids will grow up to be nerds (though, here’s hoping, because nerds make more money and have more influence on shaping our society than just about anyone). They might become doctors who use imaging to treat patients, writers who build their own websites, or anybody who goes home from their 9-5 job to write an app for extra cash or fun. Being a “computer person” no longer means you work in tech, it has become a component of life.

In an effort to not be left behind by our own children (Who had to teach their parents how to text? Show your hands. Everyone? Good.), we’ve put together a guide to help you get and stay up to pre-kindergarten speed.

Question #1: What in the heck is Minecraft, anyway?
If you are a Clueless Parent, you’re probably here because Minecraft. Here is a pretty good overview. Go read it.
Once you’ve read that, email me with any questions, and bookmark MineMum for later. For now, you should know that Minecraft is the game all the kids are playing, and it is fast becoming a first gateway to nerdom. You should try playing it sometime, too. It’s really pretty fun.

Question #2: I want my child to be exposed to computers at an early age/I’m scared of my child being exposed to computers at too early of an age. How young is too young? And how much is too much?
Let’s tackle the big stuff first, right? The answers are: I don’t know and It depends.

To address the second question first, I’m sure you’ve read all the research headlines about screen time on developing brains. But, I hope we can agree on a difference between learning new skills via technology and letting Bob the Builder raise your offspring. Does your kid show an aptitude for visual learning? Maybe that kid can benefit from early computer games. Is s/he listlessly poking around on Google looking up words you don’t understand but frighten you? Pull the plug and get on your bicycles. But, if your child is showing a true interest in something, I trust you will encourage that as much as you feel comfortable, and then go get on your bicycles. Because, seriously, bicycles are awesome.

Now, how young is too young? That’s sticky. My three-year-old is obsessed with my laptop. It has become impossible for me to get any work done while he’s around, because he’s constantly launching sneak attacks to hit the spacebar or calculator quick key. He is in love with that calculator. If I leave the computer to get some water, when I come back it looks like I won at Solitaire. Does this mean I’m enrolling him in a toddler CompSci class? No. What does he know about what he likes? He’s three. He also likes it when I hit him with his beanbag until he falls down.

There are lots of apps and games to help develop your toddler’s squishy brain in a STEM direction, but let’s not get bogged down in big dreams of Nobel Prizes just yet, k? Learn the alphabet, play outside, figure out how not to poop during the night. These should be the toddler’s focus.

Question #3: That’s great. But where do I go?
If you want to encourage (or start) your child’s computer development, I can personally and highly recommend downloading the Magic Desktop for your little one. I’ve made my son a user account on my computer. His icon is his picture, and his password is his name. The only thing available under his account is the Magic Desktop. A lot of it is still beyond him, but he’s familiarizing himself with a keyboard, learning how to launch apps, and has a bunch of educational games he can complete on his own. There are also solid parental controls and customizable options for many ages. I’ve found it to be a great tool for both of us.

Are you more of a study/research type? Try Kids, Computers, and Learning: An Activity Guide For Parents. It will help you get hands-on at an early age, and keep control of what your kids are learning on computers. It’s a handy resource to keep in your library, especially for non-tech ‘rents who are struggling with first steps, and scared about second ones.

Do you have a little builder? Maybe more like four, five, or six, who likes to get his/her hands on the Legos? I LOVE the Kano for the younger set. Build your own computer! It is so simple for adults, even clueless ones, and is a great first project for young kids. Even if it turns out to not be their specific interest, they’ll love the satisfaction of building their own computer. Bragging rights are important.

If they Kano bored them, or they zipped right through it, try one of the Snap Circuits kits. The Jr. is their first-step system, where you and your child (if they’ll let you) can build over 100 experiments like flying saucers and alarms. Who doesn’t want to build a flying saucer? COME ON.

Did I go too far for you? Let’s take a step back and look at educational games on your computer. We utilize the websites from Nick Jr., PBS Kids, and especially our old, familiar friend, Sesame Street, which has a “Parent Tip” attached to each game, giving you an offline activity to do with your child. My son loves Dinosaur Train, possibly more than he loves me. Thanks to PBS Kids, we can watch the cartoon, play the game, and learn from the app on my phone.

Question #4: All in the same day?
No, and that’s where the real stuff comes in. More than being one specific thing, we want to encourage our kids to be healthy and well-rounded. Computers are awesome, but so are bicycles (I really love bikes). Being present while your child is learning is important, but so is letting them figure things out on their own. Using your brain is healthy, but so is using your hands and feet.

Show them some of the above programs and games, see if they like them. I can also recommend some non-electronic games that will stimulate the same sort of brain functions, like the Perplexus and Quirkle for the first school years, and building sets for kids who have outgrown MegaBloks but aren’t quite ready for Kano. Our lucky kids have innumerable options available for learning these days. And we lucky parents can present them with a variety of ways to grow and express themselves.

Two last links of advice. If you’re looking for some guidelines as to what is actually educational and what is pap with good marketing, bookmark and use Common Sense Media and the Center on Media and Child Health. These are two useful resources that research and nurture child development in a media-rich culture.

So, be skeptical, but not scared. Be proactive, not reactive. The world has changed since we were kids, and it can be overwhelming. But, we all want to encourage our children to be the best people they can be, now and later. Our computers can be incredibly useful tools toward that goal, and it’s up to us to learn how to utilize them correctly.

Now go outside and play. 

Wednesday, May 6, 2015

Docker Machine on Windows - How To Setup You Hosts

12:00 Wednesday, May 6, 2015 Posted by Unknown No comments:
, ,
I've been playing around with Docker a lot lately. Many reasons for that, one for sure is, that I love to play around with latest technology and even help out to build a demo or two or a lab. The main difference, between what everybody else of my coworkers is doing is, that I run my setup on Windows. Like most of the middleware developers out there. So, If you followed Arun's blog about "Docker Machine to Setup Docker Host" you might have tried to make this work on windows already. Here is the ultimate short how-to guide on using Docker Machine to administrate and spin up your Docker hosts.

Docker Machine
Machine lets you create Docker hosts on your computer, on cloud providers, and inside your own data center. It creates servers, installs Docker on them, then configures the Docker client to talk to them. You basically don't have to have anything installed on your machine prior to this. Which is a hell lot easier, than having to manually install boot2docker before. So, let's try this out.

You want to have at least one thing in place before starting with anything Docker or Machine. Go and get Git for Windows (aka msysgit). It has all kinds of helpful unix tools in his belly, which you need anyway.

Prerequisites - The One For All Solution
The first is to install the windows boot2docker distribution which I showed in an earlier blog. It contains the following bits configured and ready for you to use:
- VirtualBox
- Docker Windows Client

Prerequisites- The Bits And Pieces
I dislike the boot2docker installer for a variety of reasons. Mostly, because I want to know what exactly is going on on my machine. So I played around a bit and here is the bits and pieces installer if you decide against the one-for-all solution. Start with the virtualization solution. We need something like that on Windows, because it just can't run Linux and this is what Docker is based on. At least for now. So, get VirtualBox and ensure that version 4.3.18 is correctly installed on your system (VirtualBox-4.3.18-96516-Win.exe, 105 MB). WARNING: There is a strange issue, when you run Windows itself in Virtualbox. You might run into an issue with starting the host.
And while you're at it, go and get the Docker Windows Client.  The other is to grab the final from the test servers as a direct download (docker-1.6.0.exe, x86_64, 7.5MB). Rename to "docker" and put it into a folder of your choice (I assume it will be c:\docker\. Now you also need to download Docker Machine, which is another single executable (docker-machine_windows-amd64.exe, 11.5MB). Rename to "docker-machine" and put it into the same folder. Now add this folder to your PATH:
set PATH=%PATH%;C:\docker
If you change your standard PATH environment variable, this might safe your from a lot of typing. That's it. Now you're ready to create your first Machine managed Docker Host.

Create Your Docker Host With Machine
All you need is a simple command:
docker-machine create --driver virtualbox dev
And the output should state:
←[34mINFO←[0m[0000] Creating SSH key...
←[34mINFO←[0m[0001] Creating VirtualBox VM...
←[34mINFO←[0m[0016] Starting VirtualBox VM...
←[34mINFO←[0m[0022] Waiting for VM to start...
←[34mINFO←[0m[0076] "dev" has been created and is now the active machine.
←[34mINFO←[0m[0076] To point your Docker client at it, run this in your shell: eval "$(docker-machine.exe env dev)"
This means, you just created a Docker Host using the VirtualBox provider and the name “dev”. Now you need to find out on which IP address the host is running.
docker-machine ip
192.168.99.102
If you want to configure your environment variables, needed by the client more easy, just use the following command:
docker-machine env dev
export DOCKER_TLS_VERIFY=1
export DOCKER_CERT_PATH="C:\\Users\\markus\\.docker\\machine\\machines\\dev"
export DOCKER_HOST=tcp://192.168.99.102:2376
Which outputs the Linux version of environment variable definition. All you have to do is to change the "export" keyword to "set", remove the " and the double back-slashes and you are ready to go.
C:\Users\markus\Downloads>set DOCKER_TLS_VERIFY=1
C:\Users\markus\Downloads>set DOCKER_CERT_PATH=C:\Users\markus\.docker\machine\machines\dev
C:\Users\markus\Downloads>set DOCKER_HOST=tcp://192.168.99.102:2376

Time to test our Docker Client
And here we go now run WildFly on your freshly created host:

docker run -it -p 8080:8080 jboss/wildfly
Watch the container being downloaded and check, that it is running by redirecting your browser to http://192.168.99.102:8080/.

Congratulations on having setup your very first docker host with Maschine on Windows.

Tuesday, May 5, 2015

Red Hat is now a Strategic Eclipse Member

14:56 Tuesday, May 5, 2015 Posted by Unknown No comments:
, ,
The Eclipse Foundation announced today, that Red Hat has become a strategic member of the Eclipse Foundation. Red Hat has been a long-time solution member of the Eclipse Foundation and actively involved in the Eclipse open source community. As a new strategic member, Red Hat will take a seat on the Board of Directors of the Eclipse Foundation, strengthening its support of the Foundation.

What Does That Really Mean?
The Eclipse Foundation knows several different types of memberships with different levels of commitment. We've always been active in contributing and officially a solution member since some time. While the solution member commitment was very limited, the new Strategic Developer membership allows us to be seen as a major contributor to technology to Eclipse. One main point here is, that we will have at least eight developers assigned full time to developing Eclipse technology and will be represented on the Eclipse Foundation Board of Directors allowing them direct influence over the strategic direction of Eclipse. Strategic members also have a seat on the Eclipse Requirements Council providing input and influence over the themes and priorities over the Eclipse technology.

Eclipse Is An IDE. Why Are We Interested In That?
It is true that flagship product of the Eclipse Foundation is the Eclipse IDE, but Eclipse Foundation actually has a lot of other projects that are not related to Eclipse IDE at all. Red Hat already contributes to a lot of projects and we just recently launched a website with all the details about the membership and the projects, we lead or co-lead on JBoss.org/eclipse/.
By becoming strategic developer we also plan to be involved more in how Eclipse IP and Development process works and evolves. Something that become more important to make more effective for fast moving projects to feel better at home at Eclipse.
On top of that Eclipse have a lot of other areas going on which Red Hat are keeping our eye on - especially in the area of web IDE’s and Internet-of-things.

What Is Next?
We’ve been contributing and continue to help making Eclipse Mars a great release, together with the rest of the community. We are especially working on fixing GTK/SWT on Linux, making Docker support and looking at improving the Java Script Development tools.

Contribute!!
If you are interested in hearing more about this or have a suggestion please feel free to contact Max Rydahl Andersen (@maxandersen). And in general, reach out to the projects we are involved with and learn how to contribute to the Eclipse ecosystem.

Further Reading!
The official blog on JBoss Tools.
The Eclipse Foundation Press Release
Red Hat's Commitment To Eclipse