A JBoss Project
Red Hat

Latest posts

In JBoss Tools and JBoss Developer Studio, we’re continuously working to augment the Maven integration experience in Eclipse. Some of the features we’ve been playing with, if deemed successful, will eventually be contributed back to m2e, like the Maven Profile Management UI. Others, more centered around JBoss technologies, will stay under the JBoss Tools umbrella.

JBoss Tools 4.2 and Developer Studio 8, based on Eclipse Luna, take advantage of all the nice improvements made to m2e 1.5.0 and then, add some more :

m2eclipse-egit integration

The Import > Checkout Maven Projects from SCM wizard doesn’t have any SCM provider by default, which can be pretty frustrating at times. With Git becoming the new de facto source control system, it only made sense to make m2eclipse-egit the sensible default SCM provider for m2e.

m2eclipse-egit will now be automatically installed when a JBoss Maven integration feature is installed from the JBoss Tools update site.

It is installed by default with JBoss Developer Studio 8.0.0 as well.

Maven Central Archetype catalog

Since m2e 1.5.0 no longer downloads Nexus Indexes by default, a very small, outdated subset of Maven Archetypes is available out of the box.

To mitigate that, the JBoss Tools Maven integration feature now registers by default the Maven Central Archetype catalog, providing more than 9600 archetypes to chose from, when creating a new Maven project. Accessing the complete list of archetypes is even way, waayyyy faster (a couple seconds) than relying on the old Nexus index download.

maven central catalog

Pom properties-controlled project configurators

JBoss project configurators for m2e now support an activation property in the <properties> section of pom.xml. Expected values are true/false and override the workspace-wide preferences found under Preferences > JBoss Tools > JBoss Maven Integration.

Available properties are :

  • <m2e.cdi.activation>true</m2e.cdi.activation> for the CDI Project configurator,

  • <m2e.seam.activation>true</m2e.seam.activation> for the Seam Project configurator,

  • <m2e.hibernate.activation>true</m2e.hibernate.activation> for the Hibernate Project configurator,

  • <m2e.portlet.activation>true</m2e.portlet.activation> for the Portlet Project configurator.

The pom.xml editor also provides matching XML templates for these properties, when doing ctrl+space in the <properties> section.

Maven Repository wizard improvements

The Configure Maven Repositories wizard, available under Preferences > Jboss Tools > JBoss Maven Integration saw a couple improvements as well :

Advanced options for maven repositories

You can now choose the repository layout, enable/disable snapshots or releases, and change the update policy in the advanced section :

maven repository advanced

Automatically identify local Maven repositories

When adding a new Maven repository, you can scan for JBoss Maven repositories unzipped locally, with the Recognize JBoss Maven Enterprise Repositories…​ button, in order to automatically add it to your .m2/settings.xml.

recognize maven repo

The identification process now looks for a .maven-repository file at the root of the folder you selected. This file follows the .properties file format and is expected to contain up to 3 attributes :

  • repository-id : the repository id

  • name : a (descriptive) repository name. Optional, defaults to repository-id

  • profile-id : the profile id the repository will be activated from. Optional, defaults to repository-id

As a concrete example, the JBoss Mobile repository .maven-repository file would contain :

name=JBoss Mobile Maven Repository

What’s next?

Tired of seeing these "Project configuration is out-of-date" errors whenever you tweak your pom.xml? We’re currently playing with a plugin that will automatically do the Maven > Update project configuration for you. You can try a very alpha version from the following p2 repository : http://download.jboss.org/jbosstools/builds/staging/jbosstools-playground_master/all/repo/. Let us know if/how it works for you, so we can decide what to do next with it.

Enjoy and see you soon!

Fred Bricon

JBoss Developer Studio allows you publish and run your Eclipse projects on OpenShift. This post shows you how to get started using the JBoss Developer Ticket Monster demo application.
In a 2nd part I will show you how to change your code in Eclipse and have those changes instantly available on OpenShift using the JRebel cartridge.

Deploy and Run Ticket Monster on OpenShift

Get the code

The JBoss Developer project created the Ticket Monster demo to showcase a modern angularjs and JavaEE application. The code for this blog is at:

The original code for the Ticket Monster is available at Github.
The webapp with its maven pom is located in the demo folder. OpenShift on the other hand is expecting a pom in the root of the git repository. Without it OpenShift will not know how to build the code when you push it. To fix this I created a fork of the webapp where I put the content of the demo folder to the root of the git repository
  1. Copy this url to your clipboard and in your Eclipse, switch to the Git perspective.

  2. Launch the Clone Git Repository wizard. It will popup with all the values already in place. Hit Next

  3. Pick the master branch and hit Finish to get the repo cloned to your local machine.

  4. Once the cloning is done the new repo will appear in the Git Repositories view.

  5. Import the project within it by using menu:Import Projects…​ in the context menu.

  6. Back to the JBoss or Jave EE perspective you will spot the new project ticket-monster in your workspace.

OpenShift, create an Application for my project, please!

You are now ready to deploy it to OpenShift. Pick Configure ▸ New/Import OpenShift Application from the context menu of the ticket-monster project.

configure openshift application

The OpenShift application wizard that you now get prompts you to provide your OpenShift credentials. Either use an existing account from the combo or create a new one, providing server, username and password.
In the next page we choose to create a new OpenShift application and pick the application type. We will use WildFly 8 which you’ll find by filtering the available choices with "wildfly". The latest version of OpenShift has it in the Basic Cartridges (previous versions - like the one used in the screencast - had it in the quickstarts).

wildfly8 application

Once you picked it you can choose the application name in the next wizard page.
The wizard suggests a name that is based on the project name. OpenShift doesn’t allow non-alphanumeric characters for the name, you therefore have to correct it, remove the hyphen and get "ticketmonster".
You may also select the domain (if you have several ones) and possibly adjust the gear size and have your application scaling.

application settings

If you now hit Finish the wizard will create your OpenShift application, prepare your local project to run on OpenShift and create a server adapter for easy publishing.
Once the wildfly cartridge is created on OpenShift, the tooling presents you the credentials to access the wildfly administrative console in a dialog. You should copy those for later usage:

wildfly admin console

In a last step the wizard informs you that it’ll prepare your local ticket-monster project to run on OpenShift. Confirm these changes by hitting OK.

prepare project for openshift

You are now ready to publish your ticket-monster projcet to OpenShift.

Deploy your project!

Get to the "Servers" view, select the freshly created server adapter and tell it to menu:publish ticket-monster to OpenShift via its context menu.

publish to openshift
publish to openshift 2

The dialog prompts you to provide a commit message and select the files that you want to commit and publish.
Among the listed files is the .gitignore. Double clicking it shows you that it now includes Eclipse specific project settings.
The wizard also added OpenShift configurations in the .openshift folder.
Further interesting bits are a marker to have wildFly running on java 8 (.openshift/markers/java8). OpenShift markers allow you to configure specific bits like enabling debugging (Enable JPDA marker), hot deployment (Hot Deploy marker) etc. You may choose among java 7 and java 8 via marker files in .openshift/markers. You can also spot a wildfly configuration file in .openshift/config/standalone.xml that you can modify to your needs. Once you checked all files by clicking the Select All button and provided a commit message, you’re good to go. You can now publish your project to OpenShift by hitting Commit and Publish

The tooling then informs that it will overwrite the current code in OpenShift by doing a push force. It asks you to confirm this.

push force

This is required since the wizard does not properly include the remote history in our local project/git repo. It clones the remote repo and then copies some of its content into the local project, it does not recursive merge since this is/was not fully reliable yet (see JBIDE-14890 for further details). It is therefore required to overwrite the remote content when you do the initial deployment. Once you hit OK the server adapter is pushing the local code to OpenShift.

Eclipse then shows you the Console with the output of the publishing operation. You can see how the maven build is triggered, WildFly is restarted and your project is then deployed.

build and deploy

In order to verify that your server is fully you can have a look at the logs. Pick OpenShift ▸ Tail files…​ from the OpenShift submenu in the context menu of your ticketmonster server adapter. The upcoming wizard allows you to fine-tune the tail files options and include the gears that your application is running on. You can stick to the default which are usually just fine.

tail files

A fully started Wildfly will output 'Wildfly 8.1.0.Final "Kenny" started' in the logs.

wildfly started

You’re now ready to have a look at your running project. Pick menu:[Show In > Web Browser] from the context menu of your ticketmonster server adapter and see how the browser is pointed to your deployed webapp.

open browser
ticket monster webapp

Change locally, see OpenShift change instantly!

Install JRebel

We are now getting a step further and show you how we can change the application code locally and have those changes instantly available on OpenShift.
To achieve this you need to install the JRebel plugin into your JBoss Developer Studio. The Eclipse plugin is available from JBoss Central. Switch to the Software/Updates tab, search for JRebel, check it once it is listed and hit "Install/Update". Once you restarted Eclipse your have JRebel enabled in your IDE

install jrebel

Enable JRebel for your Project

Open up the context menu of your project and enable the JRebel Nature for your project (menu:[JRebel > Add JRebel Nature]). In a 2nd step then enable JRebel Remoting.

enable jrebel remoting

You have to configure the local JRebel where to publish to. You therefore need the public URL of your ticket monster as it runs on OpenShift. You get this in the application details: pick OpenShift ▸ Details and copy the Public URL.

application public url

Paste it to the JRebel Deployment URL(s) by picking Advanced Properties from the JRebel context menu of your ticket-monster project.

jrebel deployment url

Downgrade to Java 7

Wildfly is configured to run with Java 8 by default. With JRebel enabled the OpenShift small gear that you get for free tends to run out of memory. It is therefore suggested that you downgrade to Java 7. You go to the context menu of your project and pick *OpenShift ▸ Configure Markers…​, uncheck java8 and check Java 7.

java7 marker

Add the JRebel cartridge in OpenShift

The JRebel cartridge for OpenShift, available from Github, makes it very easy to enable JRebel for any Java app on OpenShift. To add this cartridge to your application you get to the Servers view and choose menu: OpenShift[Edit Embedded Catridges…​].
In the upcoming wizard you check the Code Anything cartridge and paste the following url:

code anything cartridge

Once you hit Finish the wizard will add the cartridge to your OpenShift application and enable JRebel for it.

Publish your project to OpenShift

You now have to push all your local changes to OpenShift (you added the JRebel nature and downgraded to java7). You have to tell the server adapter to publish: Choose Publish in the context menu of your OpenShift server adapter.
The upcoming commit- and publish-dialog shows your local changes:

jrebel changes

You replaced the java8 with a java7 marker and added 2 xml files that configure JRebel. Once you add a commit message you’re ready to hit Commit and Publish.
If you now go to the Console view and pick the ticketmonster, you will see how OpenShift picks those changes and rebuilds your code.

ticketmonster console

You can inspect the server logs to make sure wildfly the procedure is all finished and widlfly fully restarted. In the Servers view, pick OpenShift ▸ Tail Files…​, stick to the default options and hit Finish.

wildfly started

'WildFly 8.1.0.Final "Kenny" started' in the logs tells you that wildfly was successfully restarted. You are now ready to change code locally and have them picked up in OpenShift instantly.

Pick my local changes instantly, OpenShift!

We will change the ticket price and we will therefore first check the current price. Use Show In ▸ Browser in the context menu of your server adapter which will open up the application in your browser. In your browser then hit hit Buy tickets now, Book Ticket, choose some venue, date, time and section. You will then see the current price:

ticket price1

Back in your JBoss Developer Studio let us now change the ticket price:
Open up the TicketPrice and get to the getPrice() method. Change it to the following:

    public float getPrice() {
    //   return price;
    	return createFakePrice();

    private float createFakePrice() {
		return 42f;

When you save your Java editor, you will see the JRebel console popping up and show you how it is updating the java classes in OpenShift.

rebel updating openshift

Now get back to your browser and refresh the page. You will have to select the venue again in order to see the new ticket price: It is now at $42!

ticket price2

We did not have to publish our code to OpenShift via the server adapter. JRebel published our local changes on the fly!

Looking for older posts ? See the Archived entries.
back to top