Č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 - October 19, 2017 06:13 PM
Deploying, Starting and Scaling a Java EE 7 Payara "Full" Server on OpenShift

Deploying, starting and scaling a Java EE 7 Payara Server Full on CentOS 7, openJDK 8 with the ping healtcheck from Docker hub to openshift in 3:39mins:

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 - October 18, 2017 02:34 PM
"JavaONE" - first podcast episode is available at: airhacks.fm

The airhacks.fm podcast with "JavaONE" 11 mins episode is available.

Subscribe with iTunes or RSS. Hear you soon!


Real World Java EE Workshops [Airport Munich]>

Adam Bien - October 17, 2017 03:50 AM
What is a polyfill?

In the WebStandards igniter workshop I didn't rely on any external library or framework and focussed on web standards only.

Older browsers may not support recent APIs and may require "patching", also known as polyfills. In these 2:20 mins screencast I implement, install and use an imaginary log polyfill:

See you at Java EE Workshops at Munich Airport, Terminal 2 especially at Web (Standards) Apps Essentials


Real World Java EE Workshops [Airport Munich]>

Adam Bien - October 16, 2017 04:26 AM
FDK, FN project, JSF, JSON or 43rd airhacks.tv is available

JavaONE 2017, FDK, fn project, EE4J, Java 18.3, and following topics were covered at the 43rd airhacks.tv:

Any questions left? Ask now: gist.github.com/AdamBien/a232908944dd0b3cad4d0b321fa6ee27 and see in at November, 6th, 6pm CET.

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 - October 13, 2017 07:18 AM
JavaONE 2017: Bloat Removal With Microservices

Microservices are Thin WARs usually exposed via HTTP / JSON / WebSockets. By taking the architectural constraints into account allows us to remove a significant amount of bloat and indirections:

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 - October 12, 2017 05:22 AM
Simplest Possible Java EE 8 Kickstarter

The 0.0.2 version of the javaee8-essentials-archetype:

mvn archetype:generate -DarchetypeGroupId=com.airhacks -DarchetypeArtifactId=javaee8-essentials-archetype -DarchetypeVersion=0.0.2

creates a ready to use 3.5kB Thin WAR project with configured JAX-RS runtime, a resource with a GET endpoint ("/ping"), GlassFish v5 Dockerfile and a shell script which executes the maven and Docker build image and eventually starts the image. The build-and-run cycle takes about ...5 seconds.

See it in action:

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 - October 11, 2017 06:36 AM
Java EE 8: Convenient JsonArray Collector

Java EE 8 with JSON-P 1.1 introduces a java.util.stream.Collector implementation which converts a Collection<JsonObject> into a JsonArray instance:



import java.util.Arrays;
import java.util.List;
import javax.json.Json;
import javax.json.JsonArray;
import javax.json.JsonArrayBuilder;
import javax.json.JsonObject;
import javax.json.stream.JsonCollectors;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
import org.junit.Before;
import org.junit.Test;

public class JSONPTest {

    private List<JsonObject> list;
        
    @Before
    public void init() {
        this.list = Arrays.asList(next(), next());
    }

    public JsonObject next() {
        return Json.createObjectBuilder().
                add("number", System.currentTimeMillis()).
                build();
    }                
    
    @Test
    public void jsonArrayCollector() {
        JsonArray array = this.list.
                stream().
                collect(JsonCollectors.toJsonArray());
        assertThat(array.size(), is(list.size()));
    }
        

In Java EE 7 you would have to either write a custom collector or use a JsonArrayBuilder for the conversion:



        @Test
        public void toJsonArrayConversion() {
            JsonArrayBuilder builder = Json.createArrayBuilder();
            this.list.forEach(builder::add);
            JsonArray array = builder.build();
            assertThat(array.size(), is(list.size()));
        }    
See you at Java EE Workshops at Munich Airport, Terminal 2 and especially at Java EE 8 on Java 9. Is Munich's airport too far? Learn from home: airhacks.io.
Real World Java EE Workshops [Airport Munich]>

Java Evangelist John Yeary - October 10, 2017 01:42 PM
JAX-RS 2.0 Tip of the Day: Using MOXy and Forms Example on GlassFish 5.0

Glass Fish
I have been tasked with doing some JAX-RS coding during my day job. I wanted to update my skills for JAX-RS which is one of my favorite technologies. I specifically use Jersey which I find very well done and easy to use. As a number of you may know... I am a GlassFish fan too (one just needs to look at my banner). I decided to use my trusty NetBeans 8.2 install to write a quick example.

MOXy is enabled by default if you add the dependency to your Maven project.


This is a great feature, and I wanted to give it a spin instead of using Jackson, or Jettison. The usage was as simple as adding a @XmlRootElement annotation to the model class. The rest was handled automagically.

The entire project including a war file are available on Github: jaxrs-form-data-parameters.

A simple platform independent file is used to setup the application.


We set up web resource (service) to handle our requests.


That's it! You now have a JAX-RS Web Service. The project runs successfully on GlassFish 5.0 (.war file on GitHub).

NOTE: MOXy has some issues running on GlassFish 4.1, 4.1.1, and 4.2.

Adam Bien - October 10, 2017 05:57 AM
Java EE: Heavyweight or Lightweight? A Continuous Measurement Session from JavaONE

Are Java EE 7 "full profile" application servers lightweight or heavyweight compared to a "hello world" Java SE nano service? In this session we try to answer the question in a Continuous Measurement / Continuous Profiling style:

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 - October 09, 2017 07:28 AM
JavaONE 2017 News, SSO, Serverside vs. Client, Testing JAX-RS, Logging, Versioning, Overengineering or 43rd airhacks.tv

Questions for the 43rd airhacks.tv:

  1. JavaONE 2017 News: keynotes, impressions, EE4J, project FN, Java 18.3
  2. Dynamic JMS listeners
  3. SSO, timeout and JWT
  4. Serverside rendering vs JavaScript UI
  5. openJDK vs. Oracle JDK in Docker
  6. User properties and Keycloak
  7. Testing JAX-RS with Keycloak
  8. 2 EARs one EJB jar problem
  9. Java EE and logging
  10. JSF conversations with architects
  11. Java EE versioning strategies
  12. User-friendly URIs in MVC / Ozark
  13. Optimistic and pessimistic locking
  14. Ideas for overengineering Pet Projects
  15. WildFly Datasource configuration in Docker
  16. @RequestScope with @Suspended
  17. Implementing a batch job
  18. POJO and JsonObject serialization in Java EE
  19. Qualifier instantiation in Java EE
  20. JPA-level security
  21. bind vs. self / this in JavaScript

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


Real World Java EE Workshops [Airport Munich]>

Adam Bien - October 08, 2017 03:49 AM
Introducing the Java Function Developer Kit / fnproject.io

The opensource project fnproject.io is a "serverless", multi-language cloud-like environment which was introduced at JavaONE 2017.

In this 6 min screencast I create a Maven 3, dependency-less, plain Java SE project from scratch, create a Java class with a single method (aka "the function") and deploy it to the fnproject.io ("local cloud") using the Java Function Developer Kit (FDK) / Java runtime:

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 - October 07, 2017 04:05 PM
JavaONE 2017: Java People Faces (JPF) 2017.10 -- LIghtening Interviews

A series of lightening interviews with "Java People" at JavaONE 2017 in San Francisco:

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 - October 05, 2017 03:36 AM
Java EE 8: Serializing POJOs with JSON-B

Java EE 8 comes with JAXB-like, declarative JSON-binding JSON-B (JSR-367). In this screencast a POJO is serialized to JSON using custom PropertyVisibilityStrategy:

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 - October 04, 2017 04:53 AM
Injecting Classes in Java SE with Java EE 8 and CDI 2.0

Java EE 8 (CDI 2.0) dependency works with plain Java SE:

See you at Java EE Workshops at Munich Airport, Terminal 2, particularly at Java EE 8 on Java 9


Real World Java EE Workshops [Airport Munich]>

Adam Bien - October 03, 2017 04:43 AM
Persistent Collections, FDK, Serverless, EE4j, Kubernetes, Opensource -- or JavaONE 2017 Keynote

JavaONE keynote announcements / news:

  • Intel announced the availability of Persistent Collections for Java - datastructures persisted in non-volatile memory (=specific hardware).
  • Intel introduces Vector API Developer Program. Java gets new APIs for faster Vector operations without involving the JNI.
  • Everything Java EE related is going to be opensourced. Code name: EE4J. Full name: Eclipse Enterprise for Java @EclipseEE4J
  • Oracle invests (=manpower) in kubernetes / Java integration
  • A container native, serverless platform: fnProject was opensourced on stage: fn Project
  • Fn Java Functions Developer Kit (FDK) was announced: FDK
  • Java is going to be released every 6 months ("release train"). Next release is 18.3 (March, 2018)
  • Release 18.3 will contain the Local-Variable Type Inference (var list = new ArrayList<String&bt()) Project Amber is the language feature incubator project.
  • Oracle Java is going to be completely opensourced. There will be no differences between openJDK and Oracle JDK.

It was one of the best and most interesting JavaONE keynotes. Even the sponsor slot (Intel) was funny and came with developer-relevant information.

Any questions left? Ask here and checkout 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 - October 02, 2017 02:45 AM
Java 9: Nashorn Scripting / Automation Improvement

Nashorn's $EXEC built-in function was extended to support Java's System.out and System.err as parameters:


#!/usr/bin/jjs -fv
var cmd = "mvn clean install"
var System = Java.type("java.lang.System");
$EXEC(cmd, System.in, System.out, System.err);

The code above executes Maven and "streams" the output in real time into the console. With Java 9 Nashorn is even more useful for cross-platform automation of OS-level tasks.

Docklands Dockerfiles come with Nashorn script: build.js.

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 - October 01, 2017 02:09 PM
Configuring WildFly/JBoss via CLI

The WildFly comes with a Command Line Interface which can be used for deployment as well configuration:

Checkout related posts: "Configuring WildFly via JMX" and "Transaction Monitoring with WildFly"

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 - September 30, 2017 01:20 PM
Java 9: Executing fallbacks with Optional::or

Java 9 comes with an additional Optional.or method with the following functionality:

"If a value is present, returns an Optional describing the value, otherwise returns an Optional produced by the supplying function."

The method Optional::or is useful for the implementation of fallback logic. The example below return an Integer with the value 42:


import java.util.Optional;
import static org.junit.Assert.assertNotNull;
import org.junit.Test;

public class OptionalTest {

    @Test
    public void or() {
        int message = this.answer().
                map(Integer::parseInt).
                or(this::defaultAnswer).
                get();
        assertThat(message, is(42));
    }

    public Optional<String> answer() {
        return Optional.ofNullable(null);
    }

    public Optional<Integer> defaultAnswer() {
        return Optional.of(42);
    }
}    

The method answer returns null, therefore the method map is not executed. The (fallback) or branch is executed instead and returns directly the 42 as integer.

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 - September 29, 2017 04:32 AM
Asynchronous Browser Push with HTTP/2, Servlets 4.0 and Java EE 8

In this screencast I'm pushing proactively and asynchronously content to the browser with Servlet 4.0, Java EE 8 and HTTP/2:

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 - September 28, 2017 06:46 AM
Java EE 8 Essentials Archetype (maven quickstart) released

The maven quickstart "wizard" for Thin WARs / zero dependencies, Java EE 8 projects is available:


mvn archetype:generate -DarchetypeGroupId=com.airhacks -DarchetypeArtifactId=javaee8-essentials-archetype -DarchetypeVersion=0.0.1

The archetype's source is available at: https://github.com/AdamBien/javaee8-essentials-archetype.

May your WARs be thin!

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 - September 27, 2017 10:05 AM
JavaScript Server-Sent Events Client For Java EE 8 Backend

In this screencast I'm writing an ES 6 / JavaScript client which receives Server-Sent Events emitted by a Java EE 8 / GlassFish v5 application:

Interested in lean webapps? Checkout: WebStandards Igniter online workshop or WebApps Essentials workshop at MUC Airport.

Interested in lean services? Checkout: 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 - September 26, 2017 06:28 AM
Configuring WildFly via JMX

The WildFly application server can be easily (=without typos) configured using JMX tools like jconsole (used in this screencast) or jvisualvm with MBeans browser:

See you at Java EE Workshops at Munich Airport, Terminal 2, especially at Java EE troubleshooting, performance and monitoring 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 - September 25, 2017 04:38 AM
Docklands: GlassFish v5 (Java EE 8) Docker Image

The GlassFish v5 (Java EE 8) release image is available from docklands [Dockerfile].

To launch GlassFish v5 execute: docker run -p 8080:8080 -p 4848:4848 --name gf airhacks/glassfish:v5

GlassFish v5 image with Ping was updated as well and can be launched with: docker run -d -p 8080:8080 --name ping airhacks/glassfish-ping.

The following screencast demonstrates a Thin WAR deployment into Docker.

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 - September 24, 2017 04:52 AM
Scheduler and Business Logic Separation

Splitting a scheduler:


@Startup
@Singleton
public class Reminder {

    @Inject
    CoffeeBrewer brewer;

    @Schedule(minute = "*/30", hour = "*")
    public void remind() {
        this.brewer.brew();
    }
}    

...and the business logic:


@Stateless
public class CoffeeBrewer {

    public void brew() {
        this.boil();
        this.grind();
        this.deliver();
        this.pay();
    }

    void boil() {}
    void grind() {}
    void deliver() { }
    void pay() {}
}        

...into separate classes (dedicated boundary and control) allows the application server to inject proxies. Proxying comes with following benefits:

  1. Fine grained transaction management: business logic (CoffeeBrewer) can use declarative transactions as usual
  2. Monitoring: application server will expose monitoring statistics for both classes
  3. Interception: individual interceptors can be use on both: the scheduler as well as the business logic
  4. Less noise: dynamic/flexible Schedulers require additional configuration logic. With scheduler / business logic separation, the business logic class remains unaffected and clean.
  5. Easier unit testing: there is no scheduling code in the business logic

...and the downside? You have to write one more class...

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 - September 22, 2017 08:26 AM
Transaction Monitoring with WildFly

The WildFly Java EE application server comes with extensive monitoring capabilities. In this screencast I'm monitoring the number of commits and rollbacks of a deployed Java EE application:

See you at: Tuning and troubleshooting Java EE 7 applications


Real World Java EE Workshops [Airport Munich]>

Adam Bien - September 21, 2017 04:59 AM
Java 8: Catching Integer Overflows

In Java the addition: Integer.MAX_VALUE + Integer.MAX_VALUE results in -2 without complaining. The following unit test passes:

    
        @Test
        public void addWithOverflow() {
            int result = Integer.MAX_VALUE + Integer.MAX_VALUE;
            assertThat(result, is(-2));
        }
    

Java 8 allows you to catch the overflows as ArithmeticException instances by using the Math.addExact (multiplyExact, subtractExact etc.) method.

The following test also passes:

    
        @Rule
        public ExpectedException expected = ExpectedException.none();
    
        @Test
        public void addWithOverflowAndCatch() {
            expected.expect(ArithmeticException.class);
            expected.expectMessage(containsString("integer overflow"));
            Math.addExact(Integer.MAX_VALUE, Integer.MAX_VALUE);
        }    

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 - September 18, 2017 07:17 AM
WebStandards Igniter On-Demand Workshop

80+ episodes of continuous HTML 5, CSS 3, JavaScript (ES 6/7) coding workshop is available: webstandards.training. Only vanilla WebStandards, without any external frameworks or dependencies, were used.

Are you already building, or still migrating? Learn once, apply anywhere :-):

See you also at: WebStandards Igniter Workshop at Munich Airport, Terminal 2 or Virtual Dedicated Workshops / consulting.
Real World Java EE Workshops [Airport Munich]>

Adam Bien - September 14, 2017 04:51 AM
42nd airhacks.tv is available -- The Answer to all questions included

The airhacks.tv 42nd episode with "The Answer to all questions" is available:

Any questions left? Ask now or suggest a topic: https://gist.github.com/AdamBien/ec94900a3efd5d621bf4f00cc8a0dbac.

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 - September 11, 2017 05:54 AM
Early Autumn Java (EE) / Web Events

See you soon at:


Real World Java EE Workshops [Airport Munich]>

NetBeans – Michael's blog - September 10, 2017 08:19 PM
Using WebSockets with Java EE, part 2.3

Technical aspects of the WebSocket protocol WebSockets in a Java EE 7 application JSF 2.3 and WebSocket As mentioned before, I divided part two into a couple of sub parts. Today I’ll finish with WebSockets in a Java EE 7. If we want the user to choose a different chat room which is operated on […]