Česky   |  Deutsch   |  English   |  Español   |  Français   |  Indonesia   |  日本語   |  한글   |  Polski   |  Português (BR)   |  Türkçe   |  中文   |  正體中文   |  Your Language  
PlanetNetbeans
Planet NetBeans is an aggregation of NetBeans related musings from all over the Blogosphere.
Adam Bien - July 20, 2018 05:04 PM
Lean WebApps with Skinny Miniservices #usetheplatfom #slideless Devoxx Poland 2018

"Lean WebApps with Skinny Miniservices #usetheplatfom" session from devoxx.pl 2018 (The Dragon Edition)

See you at MicroProfile With or Without Jakarta EE, at Munich Airport, Terminal 2 and at Single Page Applications (SPAs) -- the "no frameworks, no migrations" approach, at Munich Airport, Terminal 2 or webstandards.training (online).


Real World Java EE Workshops [Airport Munich]>

Adam Bien - July 19, 2018 05:16 AM
Managing Taxi Companies with Thin WARs and Java EE

Victor, please introduce yourself

Hi Adam, thank you first of all to consider me and my project for an interview :-).
My name is Victor Röder, and I'm simply a freelancing software developer and I'm living close to the geographical midpoint of the European Union (at least till 2019), that is in Germany somewhere 70 km north east of Frankfurt/Main.
You can find me on Github https://github.com/victorroeder and on Twitter @vicaware. But in both spheres I'm not that active.

You told me you are building a small Taxi App. Why Java EE?

Yes, in 2017 I actually planned to do a sabbatical and suddenly I got a request from several smaller taxi companies whether I'm willed and able to build something that could help them with their paper-and-pencil-based taxi management. So it would be a software that I could develop on my own, nearly without time pressure and the ability to earn some money, so I said "ok". And - who guessed it - the backend of it is (of course) done using Spring.

Ok, kidding - Java EE :). Or how I meanwhile call it: JSYSNRTO (for 'Java Stuff You Should Not Rename That Often')
Why Java EE? Well through your workshops I could recognize how lean and easy Java EE is/became, so I wanted to use it in a real-life project as soon as possible. And this was an opportunity.
I used J2EE years before and was impressed how it developed. But of course - as every technique - you even can also make it mega complicated with Java EE. So I'm glad to use the Adam Edition of the Enterprise Edition :-).

What is the purpose of the application?

The purpose is to simplify the management of small and medium-sized taxi companies. Every taxicab gets an Android-based provisioned tablet installed with which the drivers could record and manage their shift data and record-only the taxi tours (I'm explicitly writing 'recording-only the tours' since some guys of the German Tax Authority might read this interview as well... "hi guys..." :-D). The tablet itself is connected via BlueTooth to a small mobile printer to print out the tour receipts for the passengers and daily receipts with all shift details at the end of the shift for the drivers themselves.
The tablets transfer the shift and tour information to the backend and request possible changes of the master data if there was a server-side change. The maintaining of the master data is done by the company owner via a web UI. The App for the tablets is installed via the Play Store and the tablets initialize and configure themsevles when they are registered (with a correct key) and accepted by the backend. An easy on-boarding (and usage of the software later on) was very important to me, since I did not want to become a support center :-).

Are you happy with Java EE so far? Is Java EE productive?

Happy: Very. Now that the product is in place since over one year and being now somehow in a retrospective mode while preparing me for this interview, there are of course several things, I would not repeat in future projects. I'm using Vaadin for the backend's UI and I'm quite sure that using JSF would have been more than sufficient and JSF would have integrated better with CDI & stuff. Also I was playing around with the Fat Entity approach for the JPA entities, meaning that the entities managed their persistence themselves (using the ThreadLocal hack), contain the code for JSON de-/serializiation and other logic. Reason was, that a) I wanted to try it out and b) tried to find a way to log (for audit purposes) changes - made by UI users - on JPA level. With hindsight, I would keep it simple. But ok - honestly - I could not blame Java EE for that but rather you Adam, because you wrote about it in your book and thus put the bee in my bonnet ;-P.
The last but not least point that comes into mind, is that the code for JAX-RS and the stateless session beans share the same classes. I should have split that up (and let the JAX-RS classes inject the according session beans - as you recommend it) even if this results in partially tiny classes.

Which application servers, tools or IDEs are you using?

I started development with Glassfish and in production it is still Glassfish. And since I was crazy enough to implement a server-dependent JAAS module for login, my escape possibilities are limited... Locally and for my server's dev environment I'm using Payara. I should align that in a timely manner.
On the other hand I was playing around with other application servers and find them more polished than Glassfish/Payara...
The IDEs: Android Studio for developing the App, IntelliJ for the backend and Eclipse for the BIRT reports. Build tools: Maven for the backend project (because I wanted to) and Gradle for the Android stuff (because I had to). Of course there are many other tools, reminding me that there are nearly no small or trivial software projects out there (especially when you are working on them alone). You have to take care of so many stuff (build & quality environment, database stuff (and integration with other systems), versioning and release process, etc.), that you should always reach your goal with the most possible minimum of complexity and dependencies. Fast deployment and fast unit tests is a key metric. And automate as much and as simple as you can...

You are using the Boundary Control Entity pattern to structure your applications. What were your experiences, challenges and findings so far?

My experiences with BCE are very good. It enforces you to structure your code from the business point of view and not from a technical perspective. That even helps other developers to find their way through the structure more easier. Packages named 'dto' or 'services' say nothing, but business or domain related names show (new) developers clearly the way. Additional benefit: my scroll wheel is happy, too :).
But I used the pattern only for the business-related backend code. The server-centric presentation (and thus part of the backend project) and the Android project are structured slightly different by simply having expressive (again, from business point of view) package names and all topic-related classes are found their according package (without the deeper separation of boundary/control/entity). But classes that are cross-cutting are in the parent package (as it would be for BCE). No Util, Helper or Common packages or classes (bom chicka wah wah ;)

How big is your WAR? On which exernal dependencies are you relying?

4.8 MB. But with tricks. I put several external Jars (like those for Vaadin and BIRT) directly on the application server. Around 850 KB of the total size is my code.
Especially bringing BIRT and the thin WAR approach together is impossible. I thought about externalizing the BIRT stuff into a separate WAR whose services (i.e. report generation) could then be addressed by HTTP/REST... Or maybe I misunderstood the integration of the BIRT runtime somehow...?
(oh boy, this interview creates or reminds me of a lot of To-Dos ;-))

You are an airhacks.com alumni. Do you had any interesting conversations with other attendees (in the extensive breaks :-)

Yes, I already joined several of your workshops and had short but interesting conversations everytime (mostly chewing my food in parallel). And as far I remember all of them were related how to fight the technical or infrastructural complexity beast or dealing with difficult developers, architects, managers, etc that are more interested in creating themselves a monument within the project. None of them was about complaining "Oh, my business is so complex and it's so hard to implement."
Yes, the conversations mirrored my experiences I made with software projects so far, that they are lacking discipline for minimalism on many levels.
And it's a pity that it's often like that...

Victor, big thanks for the interview!


Real World Java EE Workshops [Airport Munich]>

Adam Bien - July 16, 2018 08:52 AM
CDI and plugins, Bean Discovery, Migrations, Async Microservice Communication, Validations with JAX-RS, Serialization---or 52nd airhacks.tv is available

"CDI components as plugins, CDI bean discovery mode recommendations, asynchronous microservice calls, modelling validations with REST, JSON-B and selective serialization, DB migrations with Java EE 7, how to be a happy consultant" , or 52nd airhacks.tv is available:

Any questions left? Ask now: https://gist.github.com/AdamBien/24c3560d05e7bcba9a82af072955a6c4 and get the answers at the next airhacks.tv.

See you at Java EE Workshops at Munich Airport, Terminal 2 or Virtual Dedicated Workshops / consulting. Is Munich's airport too far? Learn from home: airhacks.io.
Real World Java EE Workshops [Airport Munich]>

Adam Bien - July 13, 2018 05:00 AM
From Zero to Hello with Open Liberty 18 Full Profile Java EE 8

How long does it take to install, start "Java EE 7/8 Full Profile" Open Liberty 18 (the opensource version of IBM WebSphere) server, then clone, build and deploy a Java EE application (ping) with Maven 3?

No tricks, no magic, no dependencies:

Also checkout other Java EE "Full Profile" application servers.

See you at Java EE Workshops at Munich Airport, Terminal 2 or Virtual Dedicated Workshops / consulting. Is Munich's airport too far? Learn from home: airhacks.io.


Real World Java EE Workshops [Airport Munich]>

Adam Bien - July 12, 2018 09:23 AM
Generating Swagger / OpenAPI Without External Dependencies

A CRUD JAX-RS 2 (Java EE 7/8) service:


@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
@Path("workshops")
public class WorkshopsResource {

    @GET
    public JsonArray all() {
        return Json.createArrayBuilder().
                add("java").
                add("web").
                build();
    }

    @GET
    @Path("{name}")
    public JsonObject get(@PathParam("name") String name) {
        return null;
    }

    @PUT
    @Path("{name}")
    public void add(@PathParam("name") String name, JsonObject workshop) {

    }

    @DELETE
    @Path("{name}")
    public void remove(@PathParam("name") String name) {

    }
}    

...deployed on MicroProfile compatible application servers (tested with Payara Server 5 Full Profile), emits the following OpenAPI/swagger document from the standardized uri: http://localhost:8080/openapi:


openapi: 3.0.0
info:
    title: Deployed Resources
    version: 1.0.0
servers:
- url: http://localhost:8080/openapi-sample
    description: Default Server.
paths:
    /resources/workshops:
    get:
        operationId: all
        responses:
        default:
            description: Default Response.
            content:
            application/json:
                schema:
                type: object
    /resources/workshops/{name}:
    get:
        operationId: get
        parameters:
        - name: name
        in: path
        required: true
        style: simple
        schema:
            type: string
        responses:
        default:
            description: Default Response.
            content:
            application/json:
                schema:
                type: object
    put:
        operationId: add
        parameters:
        - name: name
        in: path
        required: true
        style: simple
        schema:
            type: string
        requestBody:
        content:
            application/json:
            schema:
                type: object
        responses:
        default:
            description: Default Response.
            content:
            application/json:
                schema:
                type: object
    delete:
        operationId: remove
        parameters:
        - name: name
        in: path
        required: true
        style: simple
        schema:
            type: string
        responses:
        default:
            description: Default Response.
            content:
            application/json:
                schema:
                type: object
components: {}

For the creation of the document above, no additional dependencies, configuration or changes were needed. The example above is a 3.9kB Thin WAR.

Because servers like Payara Server 5 Full Profile or OpenLiberty support Java EE 8 and MicroProfile at the same time, you neither have to change your runtime, nor your lean Java EE 8 build setup:


<project>
<modelVersion>4.0.0</modelVersion>
<groupId>com.airhacks</groupId>
<artifactId>openapi-sample</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<dependencies>
   <dependency>
       <groupId>javax</groupId>
       <artifactId>javaee-api</artifactId>
       <version>8.0</version>
       <scope>provided</scope>
   </dependency>
</dependencies>
<build>
   <finalName>openapi-sample</finalName>
</build>
<properties>
   <maven.compiler.source>1.8</maven.compiler.source>
   <maven.compiler.target>1.8</maven.compiler.target>
   <failOnMissingWebXml>false</failOnMissingWebXml>
</properties>
</project>    
For customizations (coming with the MicroProfile OpenAPI) you will need a single provided dependency to the MicroProfile API:

<dependency>
    <groupId>org.eclipse.microprofile</groupId>
    <artifactId>microprofile</artifactId>
    <version>1.3</version>
    <type>pom</type>
    <scope>provided</scope>
</dependency>	    

Enjoy Java EE 8 + MicroProfile and stay light!

See you at MicroProfile With or Without Jakarta EE, at Munich Airport, Terminal 2
Real World Java EE Workshops [Airport Munich]>

Adam Bien - July 11, 2018 04:56 AM
From JSF and PrimeFaces to WebComponents--A Conversation With Cagatay Civici

An airhacks.fm podcast conversation with Cagatay Civici (@cagataycivici) about starting with Java, interfaces and return statements, IBM RAD JSF, Sun JSF Woodstock, Apache MyFaces, Apache MyFaces Tomahawk, JSF Chart Creator, Apache MyFaces Tobago, Oracle's ADF, YUI, jQuery and JSF, the non-dependency mindset, building complex UI components, Jakarta EE and microprofile, a scientific approach to design, choosing colors and color palletes, ideas for themes, standards and PrimeFaces, keeping up with Angular, React and WebComponents, StencilJS, PrimeFaces NG, an opensource model with commercial support, why "Prime", component sponsorship, performance under pressure and PrimeTek.

Subscribe to airhacks.fm podcast via: RSS iTunes

See you at Effective Progressive-, Offline-, Single Page-, Desktop Apps with Web Standards -- the "no frameworks, no migrations" approach, at Munich Airport, Terminal 2 or webcomponents.training (online).
Real World Java EE Workshops [Airport Munich]>

Adam Bien - July 10, 2018 05:00 AM
From Zero to Hello with WildFly Full 13.0.0.Final

How long does it take to install, start "Java EE 7/8 Full Profile" WildFly 13 (and the largest available WildFly distribution) server, then clone, build and deploy a Java EE application (ping) with Maven 3?

No tricks, no magic, no dependencies:

Also checkout other Java EE "Full Profile" application servers.

See you at Java EE Workshops at Munich Airport, Terminal 2 or Virtual Dedicated Workshops / consulting. Is Munich's airport too far? Learn from home: airhacks.io.


Real World Java EE Workshops [Airport Munich]>

DukeScript - July 07, 2018 06:34 AM
Maven Surefire Testing Matrix

The standard way to test code in Java ecosystem is JUnit. The standard way to harness JUnit by Maven is the surefire plugin. Usually one doesn’t need to do anything to turn the plugin on - the standard Maven jar packaging does it automatically. However, it is possible to do magic with the plugin configuration and that is what this post is about.

JUnit Browser Intermezzo

However, before we dwell into the plugin configuration, let us set the context by introducing the DukeScript JUnit extension - it allows one to write the code once and then test it in different DukeScript environments. Where DukeScript environment is a basically a JVM configured to render HTML in some way. With a simple @RunWith annotation your code can be executed multiple times, in multiple different setups.

Where’s the problem? By default the JUnit Browser extension runs all the tests in a single Java virtual machine. Yet, some of the environments don’t go along well - for example the webkit presenter is using different GTK version than the default Apache JavaFX presenter. When used together - they crash the JVM.

Matrix of Runs

We need to run the surefire plugin multiple times. How can one do that? One needs to configure multiple test executions:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>2.10</version>
    <executions>
        <execution>
            <goals>
                <goal>test</goal>
            </goals>
            <id>default-test</id>
            <phase>test</phase>
            <configuration>
                <classpathDependencyExcludes>
                    <exclude>com.dukescript.presenters:webkit</exclude>
                    <exclude>org.apidesign.bck2brwsr:launcher.http</exclude>
                </classpathDependencyExcludes>
            </configuration>
        </execution>
        <execution>
            <goals>
                <goal>test</goal>
            </goals>
            <id>webkit-test</id>
            <phase>test</phase>
            <configuration>
                <classpathDependencyExcludes>
                    <exclude>org.netbeans.html:net.java.html.boot.fx</exclude>
                    <exclude>org.apidesign.bck2brwsr:launcher.http</exclude>
                </classpathDependencyExcludes>
            </configuration>
        </execution>
        <execution>
            <goals>
                <goal>test</goal>
            </goals>
            <id>bck2brwsr-test</id>
            <phase>verify</phase>
            <configuration>
                <classpathDependencyExcludes>
                    <exclude>org.netbeans.html:net.java.html.boot.fx</exclude>
                    <exclude>com.dukescript.presenters:webkit</exclude>
                </classpathDependencyExcludes>
            </configuration>
        </execution>
    </executions>
</plugin>

There are three execution sections. One overriding the default-test run (as added by the jar packaging), one adding another test run at the same test phase verifying the behavior on webkit presenter. In addition to that there is one more (kind of integration) test run which executes the same code transpiled into a JavaScript. As this step takes longer, it is scheduled for the verify phase. As a result one can:

$ mvn test
# or
$ mvn package

and the code is compiled and tested twice quickly. While one can schedule full verification with

$ mvn verify

Configuring the Matrix

The configuration section of each test run needs to alter the setup somehow - each of the runs is supposed to test slightly different environment, right? One can do that by setting different JVM properties, but our example has chosen a different route: it uses different classpath for each execution!

By default we add all three presenters to the project test classpath:

<dependencies>
    <!-- run tests in JavaFX WebView -->
    <dependency>
        <groupId>org.netbeans.html</groupId>
        <artifactId>net.java.html.boot.fx</artifactId>
        <version>${net.java.html.version}</version>
        <scope>test</scope>
    </dependency>

    <!-- run tests in a webkit presenter -->
    <dependency>
        <groupId>com.dukescript.presenters</groupId>
        <artifactId>webkit</artifactId>
        <version>${presenters.version}</version>
        <scope>test</scope>
    </dependency>

    <!-- run tests in bck2brwsr -->
    <dependency>
        <groupId>org.apidesign.bck2brwsr</groupId>
        <artifactId>launcher.http</artifactId>
        <version>${bck2brwsr.version}</version>
        <scope>test</scope>
    </dependency>
</dependencies>

This makes sure the Maven downloads the necessary artifacts and places them into the local repository. Then, each test execution masks all but one of the presenters using builtin surefire plugin classpathDependencyExcludes directive:

<configuration>
    <classpathDependencyExcludes>
        <exclude>org.netbeans.html:net.java.html.boot.fx</exclude>
        <exclude>org.apidesign.bck2brwsr:launcher.http</exclude>
    </classpathDependencyExcludes>
</configuration>

By doing that there is always only one DukeScript presenter available during individual test execution and the JUnit Browser extension picks that one up.

Test runs are isolated in their own JVM and combination of environments no longer negatively influence each other.

Where's the Matrix?

Nice, but where is the matrix? may be your next question! Well, the above example is taken from the DukeScript definitelytyped project which aims at providing Java API to important JavaScript libraries. There are hundreds of libraries ready and all of them share the same testing setup. As such the configuration of the surefire plugin is done in the master pom.xml in its pluginManagement section.

<build>
    <pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.10</version>
                <configuration>
<!-- .... -->

By extending the configuration of the surefire plugin in the master pom.xml we can enlarge the axis of additional DukeScript environments. By including more submodules one expands the axis of JavaScript libraries to test. The surefire testing matrix grows with every new commit. Try it, contribute too:

Convert your own library! It is easy, read more, fork and pull request.

Adam Bien - July 06, 2018 08:28 AM
Building PWA with Polymer 3, WebComponents and Java EE 8 Backend

I'm starting with the implementation, build and deployment of a Java EE 8 HTTP/JSON endpoint, then scaffold a polymer 3 Progressive Web Application (PWA) with CLI, and finally create a vanilla Custom Element which calls the Java EE 8 backend. From scratch, without tricks or magic. #usetheplatform

In 8 mins:

See you at Structuring Single Page Applications (SPA)s / Progressive Web Applications (PWA)s with WebComponents -- the "no frameworks, no migrations" approach, at Munich Airport, Terminal 2 or webcomponents.training (online).
Real World Java EE Workshops [Airport Munich]>

Adam Bien - July 05, 2018 11:14 AM
Using enums as CDI Events

Java enum can be used as an CDI "command" event:


public enum OrderEvent {
    CREATE, CANCEL;
}

Now you can sent enum instances:


public class OrderProcessor {

    @Inject
    Event<OrderEvent> events;

    public void createOrder() {
        events.fire(OrderEvent.CREATE);
    }

    public void cancelOrder() {
        events.fire(OrderEvent.CANCEL);
    }
}

...and consume them:


public class OrderMetrics {

    //...

    public void onSuccess(@Observes(during = TransactionPhase.AFTER_SUCCESS) OrderEvent event) {
        switch (event) {
            case CREATE:
                //...
                break;
            case CANCEL:
                //...
                break;
        }
    }
    public void onFailure(@Observes(during = TransactionPhase.AFTER_FAILURE) OrderEvent event) {
        switch (event) {
            case CREATE:
                //...
                break;
            case CANCEL:
                //...
                break;
        }
    }
}    

See you at Java EE Workshops at Munich Airport, Terminal 2 or Virtual Dedicated Workshops / consulting. Is Munich's airport too far? Learn from home: airhacks.io.


Real World Java EE Workshops [Airport Munich]>

Adam Bien - July 04, 2018 08:20 AM
When "There is a process already using the admin port 4848", but it is not true

When you try to start Payara 5 / GlassFish with:

asadmin start-domain

...and you get the following error:

There is a process already using the admin port 4848 -- it could be another instance of Payara Server or Payara Micro. Command start-domain failed.

although there is no running Java process and the port is not occupied, you hostname is probably not pingable:

ping $(hostname)

output: Request timeout

Solution:

Add the following line to the /etc/hosts file:

127.0.0.1 [YOUR_NOT_PINGABLE_HOSTNAME]

See you at Java EE Workshops at Munich Airport, Terminal 2 or Virtual Dedicated Workshops / consulting. Is Munich's airport too far? Learn from home: airhacks.io.
Real World Java EE Workshops [Airport Munich]>

Adam Bien - July 03, 2018 10:39 AM
Combining Serverless Functions with CDI 2.0 from Java EE 8

Serverless functions act as a facade / gateway to business logic. With CDI from Java EE 8, plain POJOs can be directly injected to fnproject.io functions and increase productivity:

See you at Java EE Workshops at Munich Airport, Terminal 2 or Virtual Dedicated Workshops / consulting. Is Munich's airport too far? Learn from home: airhacks.io.


Real World Java EE Workshops [Airport Munich]>

Adam Bien - July 02, 2018 07:57 AM
CDI and plugins, Discovery Modes, CompletableFuture and failures, ECB, ReadOnly JPA, Migrations -- or topics for 52nd airhacks.tv

Topics and questions for the 52nd airhacks.tv live show, July 2nd, 6pm:

  1. CDI components as plugins
  2. CDI bean discovery mode recommendations
  3. Dealing with failures in CompletableFuture.allOff
  4. Structuring business applications -- experiences with ECB
  5. Consultancy recommendations
  6. Read-only JPA
  7. How to design validations with REST
  8. Is JSON-B appropriate for selective serialization?
  9. How to implement Flyway Migrations with Java EE
  10. Most important books about programming
Any questions left? Ask now: https://gist.github.com/AdamBien/bfa3a444b6af3316e772f8eaf133f1cb and get the answers at the next airhacks.tv. See you at Java EE Workshops at Munich Airport, Terminal 2 or Virtual Dedicated Workshops / consulting. Is Munich's airport too far? Learn from home: airhacks.io.
Real World Java EE Workshops [Airport Munich]>

Adam Bien - June 29, 2018 04:14 AM
Serverless Java Functions with JSON-P Parameters

fnproject.io Java functions accept primitve Java types per default. In this screencast JSON-P from Java EE 8 is used to serialize and deserialize parameters and return values from Java streams to JsonObjects (in 9mins):

See you at Java EE Workshops at Munich Airport, Terminal 2 or Virtual Dedicated Workshops / consulting. Is Munich's airport too far? Learn from home: airhacks.io.
Real World Java EE Workshops [Airport Munich]>

Adam Bien - June 28, 2018 03:16 PM
Loading ES 6 String Template Literals Dynamically

ES 6 string template literals they are only parsed once at load time. However, with a trick, they can be also dynamically and lazily loaded on-demand:

See you at Single Page Applications (SPAs) -- the "no frameworks, no migrations" approach, at Munich Airport, Terminal 2 or webstandards.training (online).
Real World Java EE Workshops [Airport Munich]>

Adam Bien - June 26, 2018 05:00 AM
MicroProfile: Past, Present and Future - airhacks.fm Podcast

An airhacks.fm conversation with @emilyfhjiang about reducing the footprint with OpenLiberty, OSGi, Apache Aries Apache Aries, the beginnings of MicroProfile.io, OpenLiberty MicroProfile implementation, writing MicroProfile specs, combining Java EE 8 and MicroProfile.io, the added value of Fault Tolerance, Health, Metrics, Configuration, the process of introducing new APIs to MicroProfile, MicroProfile at GitHub, Java EE Concurrency Utilities and MicroProfile, OpenLiberty Guides, commercial support for OpenLiberty and MicroProfile by IBM, Reactive Microprofile, the relation between Jakarta EE and MicroProfile, MicroProfile standardisation.

Subscribe to airhacks.fm podcast via: RSS iTunes

See you at MicroProfile With or Without Jakarta EE, at Munich Airport, Terminal 2.
Real World Java EE Workshops [Airport Munich]>

Adam Bien - June 25, 2018 04:43 AM
MicroProfile + Java EE 8 = Thinner WARs

openliberty already supports Java EE 8 and MicroProfile APIs at the same time.

Payara 5 follows the same approach: one server runtime comes fully loaded with Java EE 8 and MicroProfile 1.3 support. Even Payara Server 4 ships with Java EE 7 and MicroProfile 1.3.

With this (brilliant) move, I'm able to use MicroProfile features on stock application servers without changing the runtime in production. Unfortunately, your pom.xml will grow by 100% from one dependency to two:


<dependency>
    <groupId>javax</groupId>
    <artifactId>javaee-api</artifactId>
    <version>8.0</version>
    <scope>provided</scope>
</dependency>
<dependency>
    <groupId>org.eclipse.microprofile</groupId>
    <artifactId>microprofile</artifactId>
    <version>1.3</version>
    <type>pom</type>
    <scope>provided</scope>
</dependency>

Hence these are only "provided" dependencies, they are not included in a WAR. I built a Java EE 8, MP 1.3 microservice on stage: http://devoxx.pl with Java EE 8 and MP 1.3 features. It came with 11 kB Thin WAR

See you at Java EE Microservices. Is Munich's airport too far? Learn from home: javaeemicro.services.
Real World Java EE Workshops [Airport Munich]>

DukeScript - June 19, 2018 10:17 PM
Kotlin (and MVVM) Everywhere!

We Love Kotlin and JVM!

Our January post about the importance of proper MVVM for Kotlin explained why the Kotlin language is important.

Now it is time to stress the cross-platform nature of the sample project. With kt-mvvm-demo you write your application once and deploy it to desktop, Android, iOS and browser with the help of portable DukeScript presenters.

Android

The sample project comes with classical Android Gradle installDebug task to package your application as an Android .apk file and deploy it to your device or simulator:

$ ANDROID_HOME=/android-sdk/ ./gradlew installDebug
$ ls app/build/outputs/apk/
app-debug.apk

Kt-Mvvm-Demo on Android

iOS

One can package the same code as an iOS .ipa file with the help of Intel’s Multi OS Engine when running on Mac OS X. First of all list your simulators and then use one of them to launch your application:

$ ./gradlew moeListSimulators
...
- DD9904B6-76CD-4F2D-9153-EC7182878897 - iOS 11.4 - iPhone X
...
$ ./gradlew moeLaunch -Pmoe.launcher.simulators=DD9904B6-76CD-4F2D-9153-EC7182878897

Kt-Mvvm-Demo on iOS

Browser

The same application can also be transpiled to JavaScript and executed in the browser. The bck2brwsrShow tasks generates necessary .js files and launches a browser with the application

$ ./gradlew bck2brwsrShow
...
Showing http://localhost:53241/index.html
...
$ ls -l web/build/web/
bck2brwsr.js
index.css
index.html
lib
main.js

The files in web/build/web directory contain everything needed to execute your application and as such they can be deployed to any HTTP server as a static content. Read more.

Kt-Mvvm-Demo in the browser

With Kotlin MVVM API you can write your code once, deploy and display it everywhere (desktop - gradlew run, Android - gradlew installDebug, iOS - gradlew moeLaunch, browser - gradlew bck2brwsrShow) while using the power of Kotlin, its libraries and any other JVM libraries on every target platform.

The JVM Portability

The fact that one can execute the same Kotlin application on all the above platforms is not like the traditional Kotlin.js and Kotlin.native portability. With Kotlin.xxx one only gets the portability of the Kotlin language, but not the libraries.

With the kt-mvvm-demo project you may bring with yourself JVM libraries - e.g. JARs - from your previous life (e.g. written in Java & other JVM languages) that otherwise can’t go with you to the Kotlin js and native worlds.

We love Kotlin on the JVM!

Adam Bien - June 15, 2018 05:41 AM
Private Fields Serialization with JSON-B and JAX-RS 2.1 / Java EE 8

JSON-B from Java EE 8 serializes public fields or properties as default. For private field serialization:


public class Workshop {

    private String name;
    private int duration;

    public Workshop(String name, int duration) {
        this.name = name;
        this.duration = duration;
    }

}    

you will have to implement a PropertyVisibilityStrategy (checkout Java EE 8: Serializing POJOs with JSON-B):


    public class PrivateVisibilityStrategy implements PropertyVisibilityStrategy {
    
        @Override
        public boolean isVisible(Field field) {
            return true;
        }
    
        @Override
        public boolean isVisible(Method method) {
            return false;
        }
    
    }

...pass your custom configuration to the JsonbBuilder and return the instance with a ContextResolver:


    import javax.json.bind.Jsonb;
    import javax.json.bind.JsonbBuilder;
    import javax.json.bind.JsonbConfig;
    import javax.ws.rs.ext.ContextResolver;
    import javax.ws.rs.ext.Provider;
    
    @Provider
    public class JSONConfigurator implements ContextResolver {
    
        @Override
        public Jsonb getContext(Class type) {
            JsonbConfig config = new JsonbConfig().
                    withPropertyVisibilityStrategy(new PrivateVisibilityStrategy());
            return JsonbBuilder.newBuilder().
                    withConfig(config).
                    build();
        }
    }

Now your POJO's private fields are going to be used for JSON-mapping:


@Path("workshops")
public class WorkshopsResource {

    @GET
    public Workshop workshop() {
        return new Workshop("Java EE 8", 42);
    }

}

Result: {"duration":42,"name":"Java EE 8"}

Tested with Payara 5.

See you at Java EE Workshops at MUC Airport, particularly at the Effective Java EE 8 workshop


Real World Java EE Workshops [Airport Munich]>

Adam Bien - June 12, 2018 03:04 PM
Consuming MicroProfile Metrics with Prometheus

In this (free) screencast I created a MicroProfile project with microprofile-essentials-archetype and exposed method runtime statistics and configured prometheus.io (from docklands) to consume the metrics directly:

Also checkout Exposing Business Metrics with MicroProfile.

See you at Java EE Microservices. Is Munich's airport too far? Learn from home: javaeemicro.services.


Real World Java EE Workshops [Airport Munich]>

Adam Bien - June 07, 2018 09:40 AM
From Versioning, Automation and CI to File Upload, MVC, Scopes and Centralized Logging -- 51st airhacks.tv

"Versioning, tagging, branching, automation, CI/CD, autodeployment in production, JAX-RS and file upload, MVC 1.0 vs. servlets and JSPs, Primefaces as module, @Singleton vs. @ApplicationScoped vs. @RequestScoped and JAX-RS, centralized logging, logging vs. metrics and the future of webassembly":

Any questions left? Ask now: https://gist.github.com/AdamBien/bfa3a444b6af3316e772f8eaf133f1cb and get the answers at the next airhacks.tv.

Audio-only version is also available from: airhacks.fm podcast via: RSS iTunes

See you at Java EE Workshops at Munich Airport, Terminal 2 or Virtual Dedicated Workshops / consulting. Is Munich's airport too far? Learn from home: airhacks.io.


Real World Java EE Workshops [Airport Munich]>

Adam Bien - June 06, 2018 06:53 AM
Exposing Business Metrics with MicroProfile 1.3

In this (free) screencast I created a MicroProfile project with microprofile-essentials-archetype and exposed method runtime statistics as well as "business" metrics.

See you at Java EE Microservices. Is Munich's airport too far? Learn from home: javaeemicro.services.


Real World Java EE Workshops [Airport Munich]>

Adam Bien - June 05, 2018 05:42 AM
Building Java EE 8 Applications For Fun -- Interview With LottoRitter

Ulrich, please introduce yourself

I am a passionated software architect and developer with more than 17 years of experiences in different industries and in implementation of mission critical software, that is reliable, performant and highly available.
Currently, I change from employed to self-employed as Java Freelancer and start the first project in June.
You can find me on my Personal website, XING, LinkedIn and GitHub.

I developed the project http://www.lottoritter.de with Christopher Schmidt. He is born in Hamburg/Germany and he is very fascinated by software development. He started with PHP/HTML/CSS in his early years, but later on he focused on JavaSE and JavaEE. He has many years of experience in software development, especially in Java projects.
Christoper can be found on XING, Twitter and GitHub.

What are you building with Java EE?

Christopher and me were building an OpenSource-JavaEE 8 project http://www.lottoritter.de. On this platform, you can "play German Lotto" for fun. You don't spend any money (and unfortunately you cannot win any money :-)). You register via eMail or OAuth (Google, Facebook, Instagram) and then you can 'buy' tickets with a dummy credit card for Lotto 6aus49, EuroJackpot, Gl&uumlcksSpirale and Keno. The drawings of the lottery are fetched via background processes.
You can found the source code here: https://github.com/Lottoritter/lottoritter-platform/

Why you started the project?

We started the project to prove, that you can build cool projects with JavaEE. For the frontend, we use JSF and JavaScript for the ticket-engine. We were developing for 4 month in spare time for the complete platform. So everyone can see, that JavaEE is highly productive. And it was a lot of fun, because we could focus mainly on the business features. Infrastructure like Application Server (we use Payara) and Database (MongoDB Atlas) just works and don't need much administration. The productive environment runs on a small private server in a docker container.

Can you share with us some geeky numbers like e.g. TX per seconds, heap sizes, thinnest WARs etc -- whatever Java EE devs might find interesting.

We did not make marketing, because this has more of a fun project without any profit thinking (we do not have any advertising or web-trackers or whatever). The project is straightforward, so we have no "Microservice"-architecture, but a simple WAR for deploying on the application server. That's it. So we don't have high load or many concurrent transaction with which we can 'boast' about.
For us, it was more interesting to share the code, so that others can reference to it and see, how easy it is to structure the code (thanks to your BCE-package pattern ;-)) and get a project up and running.

How big is your WAR?

It is 26MB all inclusive (Java, additional libraries, HTML, images and so on). But 80% of the size are consumed by third-party-libraries such as OAuth, Primefaces, Database-Driver and their transitive dependencies. The size of the written Java code is around 1 MB (15k real lines of code).

Are you happy with Java EE so far? Is Java EE productive?

Yes, I am extremely happy. The "component" model with EJB and CDI in combination with the Boundary-Control-Entity (BCE) package structure let you write clear business code. Ok, there are framework-classes like a Webfilter and the identity stores for the Java security API (Soteria) and something else like that, but 90% of the code is business related. So it is really productive. As I said before, we implemented this within 4 month in spare time.
Furthermore, it es very easy to introduce CI and to integrate everything to Amazon AWS Elastic Container Service or other platforms.
Perhaps JavaEE is not fancy, but the most business cases in general don't need fancy things. The goal is "make the project run". And it is not a good idea to make things unnecessary complicated. Java and the JavaEE APIs provide you with 90% of what you need to build the features of any general project. I like the smooth integration of the JavaEE-APIs, which is even better in Java EE 8 (see Soteria which is an incredible step forward in making Java security much easier to implement).

Which application servers, tools or IDEs are you using?

I use IntelliJ IDEA for sure ;-). The application runs on Payara 5, because it 'extends' from Glassfish, which is the reference implementation of JavaEE, but Payara is updated frequently and so, it has always the current working versions of the JavaEE-API implementation libraries.
MongoDB as database, because the document centric approach fits much better to the domain-driven-design/model and it makes implementation much simpler. In addition with MongoDB-Morphia as object-document-mapper, it is so easy to write clean code.
It is a standard Maven project, so the project can be build with the 'build pipeline' like mvn clean install && docker build ... && docker run ....

You are using the Boundary Control Entity pattern to structure your applications. What were your experiences, challenges and findings so far?

Yes, I heard of this pattern for the first time in one of your screencasts about 5 years ago. It was so stupid simple, and that's why I really like this pattern. I can structure the code for business aspects, so it is easy to get along with the code. Furthermore, you can design your code exactly like the real world. Lottoritter for example has tickets, shoppingcart, drawings, players and so on, and these business entities are exactly modelled/structured in the code and you find exactly these named packages
The only 'challenge' is, where to put classes with cross-cutting functionality. But with a bit of clear thinking, you always find a proper solution (in my opinion ;-)).

How important are standards for you? Does your application depend on application server specific APIs?

Standards are extremely important for me. They are clearly defined and you can trust on them. It is well documented, you can read the official specification-documents and the documentation for the corresponding implementation. I don't like surprises in software-projects and I want to be sure, that 'technical' things work as described. So standards let me sleep a bit better ;-).
There are no dependencies on application specific APIs. So, as soon as other application servers fully support JavaEE 8 in the future, then this project could be run on other servers as well without changes.
I don't want to waste time dealing with technical problems, but I want to implement valuable business features, for customers and as well as for my personal projects.

Did you had the chance to chat with other attendees during the airhacks.com? If yes, what was the most interesting project / problem / situation in the workshops?

I attended the JavaEE Bootstrap and Effective JavaEE days in March 2013. These two days were really cool. It was interesting to listen to others, who have the same problems at work. Mainly, the acceptance for JavaEE was a main topic. Most managers/decision makers have the J2EE-patterns in mind, with local- and remote-interfaces and all the XML-stuff. But these days are over for years. It is interesting, that even in 2018 (for example, if you talk to Spring developers), they also think of JavaEE as how it was to the J2EE epoch. Many people don't know, that JavaEE has evolved to a real lightweight enterprise application platform.

Which Java EE APIs are you using in your products?

EJB (@Stateless) and CDI are the JavaEE APIs, which I cannot miss. They are the building blocks of the whole application. You recorded a Youtube-Video some years ago about the metrics, which are exposed by every application server since years. So I get these information for free when using EJBs.
In addition, I use JAXB (for JSON to JavaObject conversion between backend and the Javascript-Ticket-engine), JAX-RS for sure ;-), Java Security API (Soteria), which is so smart and useful now (in earlier days, Java Application server security was always very difficult and proprietary to setup).

Ulrich, thank you for the interview!


Real World Java EE Workshops [Airport Munich]>

Adam Bien - June 04, 2018 07:57 AM
Versioning, Tagging, Automation, CI, Logging, MVC 1.0, or 51st airhacks.tv

Topics and questions: https://gist.github.com/AdamBien/dc00f6b83c2430c91533486e72fb4d54 for the 51st airhacks.tv

  • Versioning (internal, production, etc.)
  • Tagging automation
  • To branch or not to branch
  • Using autodeploy for production?
  • Uploading a file with JAX-RS
  • MVC 1.0 thoughts
  • Primefaces as WildFly module or WildFly swarm
  • @Singleton vs. @Stateless
  • Java EE and centralized logging
  • Are separate stacks for logging and monitoring a best practce?
  • Automatically emitting metrics via JAX-RS

Ask questions during the show via twitter mentioning me: http://twitter.com/AdamBien (@AdamBien) or using the hashtag: #airhacks. You can join the Q&A session live each first Monday of month, 6 P.M at airhacks.tv or http://www.ustream.tv/channel/adambien

See you at Java EE Workshops at Munich Airport, Terminal 2 or Virtual Dedicated Workshops / consulting. Is Munich's airport too far? Learn from home: airhacks.io.
Real World Java EE Workshops [Airport Munich]>

APIDesign - Blogs - June 01, 2018 04:02 AM
Bck2Brwsr 0.23: Get Started via Gradle!

After few months the newest version of Bck2Brwsr VM is here. It contains:

It was quite a fun to write Gradle tasks together with Maven and build them by Maven.

Get started with README. Enjoy.

--JaroslavTulach 04:02, 1 June 2018 (UTC)

DukeScript - May 30, 2018 11:51 AM
New High Quality Presenter for Swing and JavaFX

Run your DukeScript application in our new “JXBrowser Presenter” for optimal performance and the latest HTML5 features including WebGL. The evaluation version is now available from our Maven Repository. For details on installing and using the JXBrowser Presenter please check our documentation.

When you build a new DukeScript application, the default presenter for Desktop applications is based on the JavaFX WebView. This presenter is nice for debugging and visual design, but it lacks a lot of modern HTML & CSS features. For example it doesn’t support WebGL or input type=”date”.

For that reason, we’ve supported Webkit and Browser based solutions on different platforms. But this solution doesn’t work for everyone, as the components depend on the OS platform, and they aren’t embeddable in Swing or JavaFX applications, something a lot of our customers rely one.

Now we’ve developed a new presenter that we’ve been using in customer projects for some time. This presenter is based on a current version of Chromium and supports all its latest and greatest features. For the Chromium Integration we’re using the commercial JXBrowser Component, hence the name “JXBrowser Presenter”. It has much better performance than the JavaFX WebView, but is still embeddable in Swing and JavaFX applications.

Checkout the documentation and test our latest and greatest presenter.

Adam Bien - May 26, 2018 05:21 AM
WildFly and JBoss -- A Conversation with Jason Greene, Chief Architect, JBoss EAP

A conversation with Jason Greene @jtgreene about HotJava on Sparc, increasing productivity, Tomcat, OrionServer, JBoss, Jigsaw W3C's Server, JavaServer Web Development Kit, flat network assumptions, SOAP and XML vs. IIOP, grpc, thrift, DTO bloat, Infinispan, Marc Fleury, POJO Cache, JBoss Cache, caching and concurrency, clustering, JBoss/WildFly clustering under the hood, using Infinispan as JMS provider, WildFly 13 provisioning infrastructure, WildFly as a platform, pruning CORBA, the danger of profiles, dying SOAP, WildFly 12 and Java EE 8, Hibernate 6 query optimization, quarterly WildFly releases, EAP release cadence, community enterprise and supported WildFly, EAP for developers, Java EE productivity and the declarative model, Java EE concurrency model, WildFly's killer features, undertow and wildfly.

Subscribe to airhacks.fm podcast via: RSS iTunes

See you at Java EE Workshops at Munich Airport, Terminal 2 or Virtual Dedicated Workshops / consulting. Is Munich's airport too far? Learn from home: airhacks.io.
Real World Java EE Workshops [Airport Munich]>

APIDesign - Blogs - May 22, 2018 07:50 AM
Git on Steroids: Fire Your Integration Guy!

Stefan asked who shall be responsible for integration in the MultiGitRepository setup? Should there be an integration guy? No, its 21st century and we know how to use Git, right? The right tool is called pull request!

As such fire your integration guy!

--JaroslavTulach 07:50, 22 May 2018 (UTC)

NetBeans – Praxis LIVE - May 16, 2018 12:09 PM
Moving 4-ward

The first full release of PraxisLIVE v4 happened earlier this week, and while you might immediately notice some UI improvements (bezier curves in the graph editor caused some excitement!), the primary focus of this release is on the restructuring and … Continue reading

Adam Bien - May 16, 2018 08:44 AM
Simplistic Router With WebStandards

In this screencast I'm using the standard onhashchange event listener to replace a section with content loaded from an external file. It is a simplistic router:

This screencast is bonus material from: webstandards.training. You might also like: webcomponents.training.

See you at Java EE Workshops at Munich Airport, Terminal 2 or Virtual Dedicated Workshops / consulting. Is Munich's airport too far? Learn from home: airhacks.io.
Real World Java EE Workshops [Airport Munich]>