Č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.
Feeds
[RSS 1.0 Feed] [RSS 2.0 Feed]
[FOAF Subscriptions] [OPML Subscriptions]
Do you blog about NetBeans ? Add your blog to PlanetNetBeans.
Feed Subscriptions
APIDesign - Blogs (feed)
David R. Heffelfinger (feed)
Carsten Zerbst's Weblog (feed)
NetBeans – Michael's blog (feed)
DukeScript (feed)
ProNetBeans (feed)
Paulo Canedo » NetBeans English (feed)
NetBeans – NetBeans Ruminations (feed)
Anchialas' Java Blog (feed)
Category: NetBeans | Software and Science (feed)
Adam Bien (feed)
Inspiration and Expression » Netbeans (feed)
NetBeans – Enrico Scantamburlo (feed)
Bernhard's Weblog (feed)
Michel Graciano's Weblog (feed)
Ramon.Ramos (feed)
Ozone and Programming » netbeans (feed)
netbeans – markiewb's blog (feed)
Netbeans – Gualtiero Testa (feed)
netbeans – James Selvakumar’s Blog (feed)
NetBeans – nB gUru (feed)
netbeans – Newsintegrator Blog (feed)
NetBeans – Praxis LIVE (feed)
NetBeans – TechAshram (feed)
Netbeans – There's no place like 127.0.0.1 (feed)
Need to find a title (feed)
Roger Searjeant's blog (feed)
NetBeans – John O'Conner (feed)
Anuradha (feed)
Netbeans6/6.5 my best practices (feed)
Java Evangelist John Yeary (feed)
Neil's Dev Stuff (feed)
Shanbag's Blog (ರಜತ ಲೋಕ) (feed)
Computer says null; (feed)
NetBeans Adventures, Java and more (feed)
NetBeans Community Docs Blog (feed)
Van Couvering Is Not a Verb (feed)
The Netbeans Experience (feed)
NbPython/ jpydbg / pymvs (feed)
Manikantan's Netbeans (feed)
Wade Chandler's Programming Blog (feed)
Devlin's Lab (feed)
Big Al's Blog (feed)
Code Snakes (feed)
In perfect (spherical) shape (feed)
Diego Torres Milano's blog (feed)
Vroom Framework (feed)
Messages from mrhaki (feed)
Jeff's Blog (feed)
Oliver Wahlen's Blog (feed)
Shuttle between Galaxies (feed)
Welcome to my live... (feed)
Devel Blog (feed)
diamond-powder (feed)
Antonio's blog (feed)
Where's my Blog?!

Powered by:    Planet

Last updated:
July 21, 2017 08:02 AM
All times are UTC

Sponsored by
sponsored by Oracle

visit NetBeans website
Adam Bien - July 12, 2017 09:57 AM
Security, Functional Java, React, TX, Docker Swarm, Dying MVC or 40th airhacks.tv

40th airhacks.tv is available (thanks to the 101 live viewers for the interactions):

Any questions left? The queue for the 41th airhacks.tv at August, 7th, 6pm CET is open: https://gist.github.com/AdamBien/90205a0717635f090c661bf2d24d4fe5

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 09, 2017 09:37 AM
SimpleDateFormat, Java and Taligent Object-Oriented Operating System

The source of the class SimpleDateFormat comes with unusual copyright information:


(C) Copyright Taligent, Inc. 1996 - All Rights Reserved
(C) Copyright IBM Corp. 1996-1998 - All Rights Reserved

According to Wikipedia, Taligent "...is the name of an object-oriented operating system, and the company that was dedicated to producing it."

After the efforts to build an object-oriented operating system failed, in 1995 Taligent became part of IBM and:

"...Taligent also created a set of Java- and JavaBeans-based development tools called WebRunner, a groupware product based on Lotus Notes called Places for Project Teams, and licensed various technologies to Sun which are today part of Java, as well as to Oracle Corporation and Netscape..."

Therefore: Java has also its roots in an object-oriented OS.

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 07, 2017 09:57 AM
DerbyDB start fails on Docker -- Problem and Solution

An attempt to start DerbyDB 10.10.2.0 delivered with Glassfishv5 or recent Payara (asadmin start-database) will fail with:

 
Starting database in Network Server mode on host 0.0.0.0 and port 1527.
Unable to start database.  Please check log in /glassfish5/glassfish/databases/derby.log.

The derby.log contains the following exceptions:


Thu Jul 06 16:20:06 UTC 2017 : Security manager installed using the Basic server security policy.
java.lang.reflect.InvocationTargetException
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at com.sun.enterprise.admin.cli.optional.DerbyControl.invokeNetworkServerControl(DerbyControl.java:158)
	at com.sun.enterprise.admin.cli.optional.DerbyControl.main(DerbyControl.java:245)
Caused by: java.lang.ExceptionInInitializerError
	at java.lang.Class.forName0(Native Method)
	at java.lang.Class.forName(Class.java:264)
	at org.apache.derby.impl.drda.NetworkServerControlImpl.startNetworkServer(Unknown Source)
	at org.apache.derby.impl.drda.NetworkServerControlImpl.blockingStart(Unknown Source)
	at org.apache.derby.impl.drda.NetworkServerControlImpl.executeWork(Unknown Source)
	at org.apache.derby.drda.NetworkServerControl.main(Unknown Source)
	... 6 more
Caused by: java.lang.ClassCastException: java.io.IOException cannot be cast to java.lang.RuntimeException
	at org.apache.derby.iapi.services.io.FileUtil.limitAccessToOwnerViaACLs(Unknown Source)
	at org.apache.derby.iapi.services.io.FileUtil.limitAccessToOwner(Unknown Source)
	at org.apache.derby.impl.services.stream.SingleStream.PBmakeFileHPW(Unknown Source)
	at org.apache.derby.impl.services.stream.SingleStream.run(Unknown Source)
	at java.security.AccessController.doPrivileged(Native Method)
	at org.apache.derby.impl.services.stream.SingleStream.makeFileHPW(Unknown Source)
	at org.apache.derby.impl.services.stream.SingleStream.createDefaultStream(Unknown Source)
	at org.apache.derby.impl.services.stream.SingleStream.makeStream(Unknown Source)
	at org.apache.derby.impl.services.stream.SingleStream.boot(Unknown Source)
	at org.apache.derby.impl.services.monitor.BaseMonitor.boot(Unknown Source) 
    (...)

The exception is related to the issues: DERBY-6410 and DERBY-6503

Fix: update DerbyDB: recent versions are running on Docker without any issues, checkout docker image: Docklands DerbyDB image.

GlassFish v5, as well as, recent Payara Server (Issue #1738), are delivered with an old DerbyDB version. Thankfully the DerbyDB version can be easily upgraded just by overriding the folders: payara41/javadb glassfish5/javadb with the recent DerbyDB version. See e.g. the Docker image: Payara With DerbyDB.

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, 2017 05:44 AM
Payara Server "Full", Autodeployment and Docker

Payara server comes with disabled autodeployment feature, what makes deployments at start in containerized environments, like Docker or clouds, more challenging.

Fortunately, Payara Server 172 introduced the --postbootcommandfile flag.

asadmin commands like e.g. deploy can be read from a file specified with the postbootcommandfile flag and executed after successful Payara's start, e.g.: asadmin start-domain --verbose --postbootcommandfile commands.txt. The postbootcommandfile feature makes deployments at boottime even more predictable.

All Payara-related docklands Dockerfiles are using the "postbootcommandfile" feature already. Also the hub.docker.com/u/airhacks/ airhacks/payara and airhacks/payara-derby were updated.

To start a Thin WAR (=kB) microservice, you only have to write these two lines in a Dockerfile:

        
        FROM airhacks/payara
        COPY ./target/micro.war ${DEPLOYMENT_DIR}
        
    

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 - July 03, 2017 07:29 AM
JASPIC, Lambdas, React, TX, JSF, MVC, JSON, Microservices, Docker Swarm, Threads or Questions for the 40th airhacks.tv

Topics for the 40th airhacks.tv at July, 3rd, 6pm CET:

  1. JASPIC for securing Java EE 7 applications
  2. Thoughts on lambdas and more functional Java
  3. Thoughts on AWS lambdas :-)
  4. The size of ReactJs -- and possible optimizations
  5. Thoughts on custom servlet login module
  6. How to handle transactions in Thin WARs
  7. Primefaces as "one stop" solution
  8. REST as communication "protocol" between Thin WARs
  9. WebSockets vs. Long Polling
  10. JSONObject as DTO and inheritance issues
  11. Microservices and Jenkins
  12. Opinions on Docker Swarm
  13. Threads and EJBs
  14. Is MVC dying (everywhere)?
  15. Programmatically deploy and undeploy Java EE applications

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]>

Adam Bien - June 30, 2017 10:06 AM
Unorthodox Enterprise Practices--at JavaOne 2015

Removing bloat with Java EE 7 (a JavaOne 2015 session):

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 - June 29, 2017 11:03 PM
Transpile Plain Java into JavaScript

DukeScript is all about smooth communication between Java and JavaScript. It comes with no surprise that one can use the DukeScript infrastructure to easily transpile Java code into JavaScript and run it in a browser. Here is a quick how-to:

Start from command line

Of course, if you are an IDE junkie, you may prefer a visual way of getting started, but to prove that it is really just a matter of a few commands, let’s set everything up from a command line. Install Java, install Maven and invoke:

$ mvn archetype:generate \
  -DarchetypeGroupId=com.dukescript.archetype \
  -DarchetypeArtifactId=knockout4j-archetype \
  -DarchetypeVersion=0.17 \
  -Dwebpath=client-web \
  -DgroupId=org.your.test \
  -DartifactId=runjavainbrowser \
  -Dversion=1.0-SNAPSHOT
$ cd runjavainbrowser
$ mvn install -DskipTests

and that is it! Just three shell commands and you have all the environment you need!

Write Your Code!

Let’s open the DataModel.java that contains the main logic and let’s add there some Java code.

$ vi client/src/main/java/org/your/test/DataModel.java

there are few methods annotated with @Function annotation. They are ready to be invoked when a button on the HTML page is pressed. Let’s modify one of them:

@Function static void turnAnimationOn(Data model) {
    model.setMessage("I can run Java in any browser!");
}

Of course you can put much more logic into the Java method - most of the core Java is supported. Now let’s try it. Rebuild and launch in a browser:

$ mvn install -DskipTests
$ mvn -f client-web/pom.xml bck2brwsr:show

When the browser page is opened, press the Start button and congratulations: your first Java code has been successfully transpiled to JavaScript and executed in a browser!

So Easy! Where’s the Catch?

Just a few simple steps and my Java code is running in the browser. Is everything so easy, or is there a hidden catch?

Of course, the transpiling has some limitations. It doesn’t support all Java APIs, but it shall be good enough for running Java algorithms in the browser and perform client side validations, computations, etc.

Moreover there is something really special: DukeScript project doesn’t provide the transpiling technology - we are just using it with the goal to make writing portable Java applications easy. As with any other system (Android, desktop, iOS) we always choose the best JVM available on the system. However, in case of plain browsers, there are two very good choices: Bck2Brwsr VM and TeaVM. With DukeScript infrastructure you can easily choose between any of them - e.g. no vendor lock-in and your choice to select the better JVM for your tasks. To try TeaVM just execute:

$ mvn -f client-web/pom.xml -Pteavm install -DskipTests bck2brwsr:show

What is better: Bck2Brwsr or TeaVM?

What transpiling technology is better? Depends on your needs. Each of them has its benefits. TeaVM compiles the whole application into a single JavaScript file. Bck2Brwsr produces one JavaScript file per JAR file - e.g. comes with better support for modularity. Bc2Brwsr can execute as complex applications as Javac in the browser, but is intentionally singlethreaded. TeaVM can simulate threads and comes with better in browser debugger integration.

The choice is yours. DukeScript projects is just proud to offer you two alternative transpiling solutions.

Packaging for Web

When your application is running, it is time to package it for the web. Again, it is easy. Execute following commands:

$ mvn -f client-web/pom.xml package -DskipTests
$ unzip -v client-web/target/runjavainbrowser-web-1.0-SNAPSHOT-bck2brwsr.zip
public_html/index.css
public_html/index.html
public_html/lib/emul-0.19-rt.js
public_html/lib/net.java.html.boot-1.3.js
public_html/lib/ko4j-1.3.js
public_html/lib/runjavainbrowser-js-1.0-SNAPSHOT.js
public_html/lib/net.java.html.sound-1.3.js
public_html/lib/runjavainbrowser-1.0-SNAPSHOT.js
public_html/lib/net.java.html-1.3.js
public_html/lib/net.java.html.json-1.3.js
public_html/bck2brwsr.js
public_html/runjavainbrowser.js

and you can see that a ZIP file has been created for you and is ready to be uploaded to your web server and used from your HTML pages. Alternatively you can do the same with TeaVM:

$ mvn -f client-web/pom.xml package -Pteavm -DskipTests
$ unzip -v /home/devel/tmp/transpile/runjavainbrowser/client-web/target/runjavainbrowser-web-1.0-SNAPSHOT-teavm.zip
public_html/index.css
public_html/index.html
public_html/teavm.js

and upload or use the single teavm.js file containing all your transpiled Java code.

Development and Testing

The power of DukeScript is in high portability of the applications. As such it is suggested to develop your application on desktop with a JavaFX WebView component - then all the goodies like no redeploys or easy Java and HTML debugging work. Once your application is running, you can then just transpile it.

Should there be any differences between desktop and transpiled version, the best is to write and execute a unit test - if it behaves differently between the standard Java on desktop and the one running in the browser, please contact our support and send us the test case - we are always ready to help.

Enjoy Java in a browser done in the DukeScript way!

Adam Bien - June 22, 2017 08:20 AM
Java EE -- The Competitive Advantage For Startups

At the infoshare.pl 2017 conference in Gdansk I got 30 minutes time to explain why Java EE is happily used by startups with live hacking. Deployment to Amazon Cloud (AWS) included:

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 16, 2017 01:54 PM
Don't Push and Pull!

It is hard to push and pull at once in real life and people tend to know it. Yet I have witnessed many attempts that try to put both approaches into the same API at the same time and pretend those are equal. Small advice from a former API designer: don't do it!

For a longer advice please see the pull vs. push essay.

--JaroslavTulach 13:54, 16 June 2017 (UTC)

Adam Bien - June 16, 2017 08:07 AM
Building and Running a Fullstack Java EE ThinWAR in Oracle Container Cloud Service ...in 7 Minutes

7 minutes are sufficient to:

  1. Create Java EE 7 application (single JAX-RS endpoint) from scratch with Maven 3
  2. Build an executable Docker image based on CentOS 7, openJDK 8, GlassFishv5 and a ThinWAR (the app from above). The glassfishv5 file was used from: https://github.com/AdamBien/docklands
  3. Push the executable image to public docker registry: http://hub.docker.com/u/airhacks/
  4. Create a service in Oracle Container Cloud Service: https://cloud.oracle.com/container

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 14, 2017 05:31 AM
Beautiful Java EE, JWT, EAR cases, Dynamic Serialization, @Asynchronous Testing or 39th airhacks.tv is online

39th airhacks.tv is available:

Any questions left? File the your questions now https://gist.github.com/AdamBien/37e7dde8f2ef447edfa04354b9819b7d or see you in MUC at: http://workshops.adam-bien.com.


Real World Java EE Workshops [Airport Munich]>

netbeans – markiewb's blog - June 13, 2017 10:48 PM
Java code formatting done right across different IDEs

http://blog.exxeta.com/java/2017/06/13/java-code-formatting-done-right-across-different-ides/


DukeScript - June 11, 2017 09:23 AM
Spice your Android app with Web Components!

Developing an Android application with Android Studio and in a need to talk to an HTML/web component? Then this article is for you. It gives a step by step description of how to add any web component into your application. We show how to communicate with it in the same language that you use for the native part of your application.

Let’s get started…

Setting the Project up

First of all you need Android Studio (can be downloaded from here). At the time of writing this tutorial version of 2.3.1 of Android Studio was used. The steps shall however be general enough to be applicable to any version. Let’s create a new project with an empty activity:

New Project in Android Studio Target devices Empty activity

Let’s put two buttons, one text area and most importantly a WebView component to the activity:

Design Activity

So far we’ve been using standard Android Studio tools. Now the time has come to turn the WebView into chart renderer. To do so, let’s use the DukeScript Presenter for Android and the charts library. Select File/Project Structure menu item and in the Dependencies tab add these two libraries as shown on following picture:

Project Dependencies

The project setup is finished. Now we can start writing the real application code.

The Code

First of all we need an HTML page to be displayed in the WebView. The page doesn’t have to be complex - it can contain just a single <canvas> element that will span over the area of a WebView.

Create assets directory. Right click app, choose New/Folder/Assets Folder and create your HTML file in that folder. Call it chart.html and put the following content to it:

<h1>Hello from DukeScript!</h1>

<canvas id="chart" width="300" height="300"></canvas>

Prepare the WebView for Java Access

The next step is to load the page into our WebView component and initialize the view for access from Java. This is done in the onCreate method of our MainActivity class:

import com.dukescript.presenters.Android;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    WebView web = (WebView) findViewById(R.id.web);

    onWeb = Android.configure(null, web, "file:///android_asset/chart.html", false);
}

The configure method initiates loading of the provided HTML page and returns an Executor that can be used to modify content of the page from Java any later time. Let’s store it in a field called onWeb.

Modify the HTML Content

There can be multiple WebView components in each activity. When using any API that needs access to the HTML context, it is important to select the WebView one intents to work with. This is done by using the previously returned Executor instance.

import net.java.html.charts.Chart;
import net.java.html.charts.Color;
import net.java.html.charts.Config;
import net.java.html.charts.Values;

onWeb.execute(new Runnable() {
    @Override
    public void run() {
        chart = Chart.createBar(
            new Values.Set("left", Color.valueOf("red"), Color.valueOf("magenta")),
            new Values.Set("left", Color.valueOf("blue"), Color.valueOf("violet"))
        );
        chart.getData().add(new Values("state", 1, 1));
        chart.applyTo("chart");
    }
});

The example is using the Charts API for Java provided as one subproject of the whole DukeScript effort. First of all we use the onWeb instance of Executor associated with our WebView to enter the right context. Then we create new instance of bar chart (other types of charts like line, pie, doughnut, radar, polar are also available as the documentation showcases). We prepare some initial values and add them to the chart. Then we bind the chart to an existing <canvas> element on the page using applyTo method.

Web Component in Android app

That’s it. When you execute your application, you shall see the chart taking most of your screen.

Congratulation. You have just successfully used a Web Component in your Android application - and please note: without a single line of JavaScript!

Reacting to Events

Showing static HTML content is a nice initial step, but of course, the goal is to make it live. The android activity we designed contains two buttons - let’s connect them with the chart!

Button left = (Button) findViewById(R.id.left);
left.setOnClickListener(onWeb(new View.OnClickListener() {
    @Override
    public void onClick(View view) {
        chart.getData().set(0, new Values("state", ++leftCount, rightCount));
    }
}));

This is a typical Android code. It locates your component and attaches a listener to it. When the click is triggered, it accesses the data of existing chart and modifies them by increasing either left or right column in the chart.

Your Charts web component is now alive - again without any use of JavaScript and fully integrated into your Android application.

Reacting to Web Component Events

Of course, not only native Android components influence the web components. In a real application web components can also influence the native ones. Here is an example showing how that can be achieved:

chart.addChartListener(onUi(new ChartListener() {
    @Override
    public void chartClick(ChartEvent chartEvent) {
        if (chartEvent.getValues() == null || chartEvent.getValues().length != 2) {
            return;
        }
        final String msg = "Red is " + chartEvent.getValues()[0] + " blue is " + chartEvent.getValues()[1];
        TextView text = (TextView) findViewById(R.id.text);
        text.setText(msg);
    }
}));

When creating your chart, you can attach a listener to it. It gets triggered when a click on the chart is detected and is called back with an event object providing information about the location of the click. In response of such click, we can locate our text view (another native component) and change its text property.

Summary

We have successfully enhanced our native Android application with a web based component - in this case a bar chart - and have done so without a line of JavaScript. This is possible thanks to DukeScript Presenter for Android and its configure method that allows you to turn any WebView in your application into a full featured DukeScript presenter.

There is a lot of innovation happening in the HTML landscape. DukeScript project gives you access to all of that from inside of your Android application and while using the same language that you use for the rest of your application.

Where to go from here?

Check the Android.configure documentation to understand possible embedding alternatives.

Read the overview javadoc page to see available Java APIs that have already been prepared and documented by the DukeScript documentation project. Choose from charts, maps, JQuery, knockout, canvas, SVG, and more…

Get the sources of here-in presented application, clone, fork, enhance. See the GitHub project.

Talk back. Contact us via forums, twitter or support channels.

Enjoy

Enjoy web components inside of your Android app done the proper Java way!

DukeScript - June 07, 2017 08:11 AM
Version 1.3 of Mobile Presenters

The presenters are the soul of any DukeScript system. They help you to code in Java (or other JVM based language) and render in HTML - on Android, iOS, desktop, etc. Here comes a short note about them.

Version 1.3 has just been uploaded to Maven central, and its javadoc has been published too.

Check the javadoc for the Android class - it comes with a new advice how to embed DukeScript views into your existing Android applications.

Spice your Android apps with DukeScript!

Adam Bien - June 06, 2017 08:56 AM
Java EE Application Servers Are Not Suitable To Host Microservices

Due to low footprint, fast startup and low runtime overhead ("The Overhead Of Java EE Application Servers"), deploying multiple WARs into one application server instance running on a single JVM does not save a considerable amount of resources unless you have to deal with Netflix-like scale (ten thousands of dynamic VMs).

You could manage multiple WAR-microservices on a shared application server, but this approach would come with serious disadvantages:

  1. Less Isolation: A misbehaving WAR can influence other microservices
  2. Complicated Monitoring: it is harder to monitor the activity of a single WAR
  3. Less Stability: a redeployment of a WAR could influence others (memory leaks, classloader leaks)
  4. Less scalability: it is harder to scale a single process, than multiple processes
  5. More complex CI / CD: an executable image will contain multiple microservices and requires coordination between teams

Java EE Application Servers are not suitable to host multiple microservices. The way to go is to ship exactly one Thin WAR ("Thin WARs, Java EE 7, Docker and Productivity") with one application server instance and consider the OS, JVM, applicaton server and the Thin WAR as the executable unit.

A Java EE microservice architecture is about multiple application servers hosting exactly one WAR ("Why Not One Application Per Server?) communicating with each other. Using a single application server instance as a microservice runtime is too brittle, too complicated and hard to justify with numbers.

See you at Java EE Microservices where we build Java EE Thin WARs, and Java EE CI/CD, Testing and Quality workshop where the Thin WARs get automatically deployed.
Real World Java EE Workshops [Airport Munich]>

APIDesign - Blogs - June 06, 2017 08:54 AM
Just Code

Is it JustCode that matters in a project or do projects need more? Is it necessary to have a bug tracking system or can we embed everything in the code? Is it better to keep snapshot of an API in the code or track it independently with additional tools?

Check my JustCode essay to see the benefits and drawbacks of both approaches.

--JaroslavTulach 08:54, 6 June 2017 (UTC)

Adam Bien - June 05, 2017 08:25 AM
2017 Free Summer Java Events, Workshops and Sessions

  1. Free: Oracle Code Brussels, 6th June, 9 AM, Enterprise java.net: A Slideless Keynote
  2. Devoxx Krakow, 21th June, Session: "Build To Last: From Frontend To Backend #slideless #talk"
  3. 27th-29th June, airhacks.com: Java EE 7 (and a bit 8) Bootstrap (very few seats available), Effective (very few seats available) and Java EE CI, CD (Jenkins 2 Pipelines), Testing and Quality Workshops at Munich's Airport, Terminal 2. workshops.adam-bien.com
  4. Free: July 18th, Munich (location TBD), evening event: "Pragmatic Architectures With Microservices" follow up meeting in Munich. This time #slideless (one slide recap).

...or see you at airhacks.io or airhacks.tv.


Real World Java EE Workshops [Airport Munich]>

Adam Bien - June 05, 2017 07:56 AM
EAR Use Cases, JSF Modularization Again, JWT, CRUD Generators, Subset Entity Serialization, @Asynchronous Testing, Fat WARs, or 39th airhacks.tv

Topics (gist) for the 39th airhacks.tv, June 5th, 5 pm CET (one hour earlier):

  1. News
  2. Follow up JSF modularization
  3. Beautiful Java EE frontends
  4. JWT Authentication With Java EE
  5. Java EE CRUD Code Generators / bootstrap Frameworks
  6. Are there still use cases for EARs?
  7. Serializing a dynamic subset of fields / properties
  8. JPA with WildFly
  9. Testing @Asynchronous methods
  10. Fat WARs -- if you really need them
  11. Use Cases and experiences with Java EE Batch
  12. Multitenancy with JPA
  13. Opinions about Multiple WARs, one server, one DB

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]>

NetBeans – Enrico Scantamburlo - June 04, 2017 12:55 AM
Programmatically install a module in a NetBeans Platform Application

Since we developed a new feature for my company software, I was asked to automatically install the help module for this one. The only way to do it was to install the module programmatically because we couldn’t add a dependency since all the help modules sit in a different suite.

You can find a copy of the code on my Github repository.

First of all, I added an Installer to my module because I wanted to check if the module was installed or not at the when the application starts.

To add an Installer, just right click on your module in the Project View and select New/Other…, in the popup window that appears select Module Development on the left and Installer / Activator on the right, continue with the wizard and NetBeans will create one file called Installer.java with a restore() method that will be called every time the application starts.

The first thing I do is to refresh the application module list because it might happen that the application does know new modules are available yet.

// I refresh the module list
for (UpdateUnitProvider provider : UpdateUnitProviderFactory.getDefault().getUpdateUnitProviders(false)) {
    try {
        provider.refresh(handle, true);
    } catch (IOException ex) {
        LOGGER.log(Level.SEVERE, null, ex);
    }
}

Then I search for my module UpdateUnit, an UpdateUnits represents something we want to install or update.

  • List<UpdateUnit> updateUnits = UpdateManager.getDefault().getUpdateUnits();
    UpdateUnit moduleUpdateUnit = null;
    for (UpdateUnit updateUnit : updateUnits) {
         final String codeName = updateUnit.getCodeName();
         if (MODULE_CNB.equals(codeName)) {
             moduleUpdateUnit = updateUnit;
            break;
        }
    }
    

    I ask if there are any updates available, in this case, the module is not installed so the platform will install it.

    List<UpdateElement> availableUpdates = moduleUpdateUnit.getAvailableUpdates();
    UpdateElement update = pickLatest(availableUpdates);
    

    Finally, I can start the real installation: I create an OperationContainer which will take care of the operation.
    Some notes here:

  • The InstallSupport doDownload() methods take three parameters: the ProgressHandle,  a boolean to install the module for all users or only for the current one and a second boolean that allows setting the user dir as a fallback. I’d highly recommend setting the last argument to true.
  • The Restarter allows restarting the platform immediately or setting it to being restarted later, I prefer the former because is less invasive. In my company application, all modules require restarting before being installed for safety reasons.
    OperationContainer<InstallSupport> container = createForInstall();
    container.add(Collections.singleton(update));
    
     InstallSupport support = container.getSupport();
     try {
         Validator v = support.doDownload(handle, true, true);
         InstallSupport.Installer i = support.doValidate(v, handle);
         Restarter r = support.doInstall(i, handle);
         if (r != null) {
             support.doRestartLater(r);
             setModuleInstalled();
         }
     } catch (OperationException ex) {
         LOGGER.log(Level.SEVERE, null, ex);
     }
    

    Here there are some useful links:

  • NetBeans Update Centers content management process
  • NetBeans Architecture Answers for Auto Update Services module
  • Class OperationContainer<Support>

 


The image was designed by FreePik

NetBeans – Michael's blog - May 30, 2017 08:41 PM
Hunting session is open

Do you like hunting for bugs? Or confirming that NetBeans can be used without serious bugs? Then participate the Apache NetBeans (Incubating) IDE Community Acceptance Testing (NetCAT) program for NetBeans 9.0. Become one of the first who work with the upcoming version of this great Open Source IDE. Read the NetCAT FAQ [1] and join […]

Adam Bien - May 23, 2017 08:15 AM
Setting Timeout For JAX-RS / TomEE CXF Client

The name of the "read" and "connection" timeout properties is not standardized in Java EE 7. For TomEE / CXF clients you will have to use the "CXF-proprietary" names:


import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;

Client client = ClientBuilder.newClient();
client.property("http.connection.timeout", 500L);
client.property("http.receive.timeout", 500L);

The name differs in Jersey (used in GlassFish / Payara), but the semantics are the same.

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 - May 19, 2017 09:33 AM
Java EE (and Docker) Quickstart

  1. Create a Thin WAR Java EE project. Name it "micro".
  2. Create a Dockerfile in project folder with the following content:
                
                FROM airhacks/wildfly
                COPY ./target/micro.war ${DEPLOYMENT_DIR}                
                
            

    Also airhacks/payara, airhacks/tomee images are available from https://hub.docker.com/u/airhacks/. The docker files are maintained in https://github.com/AdamBien/docklands.

  3. Perform build from project folder: mvn package && docker build -t airhacks/micro .
  4. Run the project: docker run -d -p 8080:8080 --name micro airhacks/micro

See it in action: https://www.youtube.com/watch?v=P6Bk3Eiz3kE.

Behind the scenes:

  1. CentOS 7, JDK 1.8, the chosen application server (WildFly, Payara, TomEE) is going to be downloaded the first time (~560 MB, see https://youtu.be/hoqJdH87e7g) from https://hub.docker.com/u/airhacks/.
  2. All subsequent builds will only rebuild the Thin WAR -- it will take milliseconds. The smaller the WAR, the higher the productivity: https://youtu.be/5N4EUDhrkec
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 - May 15, 2017 12:44 PM
Gartner and Java EE, BCE, Modular JSF, Monitoring, JAX-RS Refactoring or 39th airhacks.tv

55 mins, 125 live attendees, ~20 topics ranging from Gartner and Java EE, BCE architecture, modular JSF, monitoring, REST refactoring, how to learn Java EE (see all topics), or the 38th airhacks.tv episode is available:

Any questions left? A fresh question queue is setup. Ask now: https://gist.github.com/AdamBien/b1a66dafdae21c0c40d647f05f44e57c and see you at June, 5th, 2017, 6 pm 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]>

NetBeans – Michael's blog - May 13, 2017 10:10 PM
Impressions from Tenerife II

I took a snapshot down into a Aloa Vera or similar plant. The camera automatically focused onto the ground and the picture shows very clear a leaf at the bottom of this plant. Then I manually focused on that little animal I discovered there. Two photos taken from the same position, showing very different details. […]

Adam Bien - May 11, 2017 11:37 AM
Java EE (and Microservice) Quickstart

  1. Create Thin WAR project with: mvn archetype:generate -Dfilter=com.airhacks:javaee7-essentials-archetype. (see: Setting Up Java EE 7 Projects With Maven 3)

    Result: 24 lines of pom.xml. The pom.xml only conatins a single dependency to Java EE 7 API. In real world projects you will only need to add test dependencies like JUnit or Mockito. The file beans.xml (one tag), was created to enable Depenency Injection (DI) everywhere and the annotated class JAXRSConfiguration activates JAX-RS under the resources uri. The generated Thin WAR project is a production ready template for Java EE / Microservices / Thin WARs.
  2. Create a JAX-RS resource, like .e.g.
            
        import javax.ws.rs.GET;
        import javax.ws.rs.Path;
        
        @Path("message")
        public class HelloResource {
    
            @GET
            public String message() {
                return "works!";
            }       
        }
    
    
  3. Perform mvn package and copy the Thin WAR ./target/[NAME].war (~4 kB) into the autodeploy / deploy folder of Java EE 6 / 7 / 8 application server of your choice.
  4. ...or download NetBeans "Java EE Edition", open the project, and click "run".
  5. Open the browser with: http://localhost:8080/[NAME]/resources/message

Use a full profile Java EE application servers (Payara, WildFly, TomEE, WebLogic, Websphere Liberty Profile). The download size varies between 55 MB and 200 MB. The runtime overhead is around 50 MB RAM (see live memory profiling: "The (RAM) Overhead Of Java EE Application Servers").

For mainstream (microservices) projects there is no further tuning, configuration or optimization required.

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 - May 08, 2017 04:33 AM
Gartner, BCE, Modular JSF, Firehose, Translations, Favorite Application Server, GET Refactoring or Questions for 38th airhacks.tv

Questions (gist) for the 38th airhacks.tv, May, 8th, 7pm (exceptionally one hour later):

  1. Java EE 8 and Oracle Code Conference News
  2. Gartner and obsolete Java EE
  3. BCE and loggers, custom validators and "helpers"
  4. Wider topic: what are helper classes?
  5. Modular JSF?
  6. Firehose: performance and scalability considerations
  7. Storing / caching translations
  8. Refactoring GET endpoints with query params
  9. Dealing with Jackson "Unknown Properties"
  10. My favorite application servers
  11. Cross cutting libs (e.g. JCache) and docker
  12. CDI Events and generic types
  13. IBM, RedHat and Project Jigsaw
  14. How to approach effectively Java EE
  15. Application servers, connection pools and clustering

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]>

DukeScript - May 07, 2017 04:51 PM
Can DukeScript Ecosystem Benefit from Java9?

Today we’ve got engaged into particularly interesting discussion: Can DukeScript benefit from Java9? Java9 is feature freezed and it’s release date seem to be unstoppable: thus it is really the right time to look at its features and analyze how an independent and extremely portable project like DukeScript could benefit from the new major Java release. Here are few things that crossed our minds.

Modularity - Meaning Small

DukeScript systems are designed to be heavily portable. They fit into your phone, iPad or even a browser. As such it seams fine that Java9 defines so called java.base module - e.g. the smallest independent deployment unit one can use when bundling a Java9 application. That is indeed good.

On the other hand the smallest unit still has more than three thousand of classes. E.g. it is not as small as it could be: for example when running DukeScript in a browser, it is possible to reduce the application to less than 1000 of classes - so there is still a room for improvement. But at least the Java maintainers are heading in the right direction.

JShell

It is common in the world of browsers that developers have an interactive console: a place to evaluate its queries while the program is running. JShell brings the same possibilities into Java9 and thus also into DukeScript based applications.

In theory we could give you the same console as JavaScript programmers have, but let you code in Java. Let you talk directly to your application: use for example typed JQuery to manipulate with DOM elements.

One question remains: is such feature what you want and need?

Something Else

There is said to be 55 new features in the up-coming release of Java9. We don’t see all of them to directly fit into the charter of DukeScript, but we may be missing something: What is your favorite feature and how it could enhance DukeScript?

Question for You!

How would you like us enhance DukeScript to benefit from Java9 features? Let us know: either by twitter or by participating in the discussion below.

Thanks for helping to make DukeScript better.

APIDesign - Blogs - May 05, 2017 04:08 PM
Midlife Crisis of an API Designer

I have to admit I am currently at a midlife crisis. I dedicated my last twenty years to promotion of a proper API design. I wrote TheAPIBook, I tried to propagate the principles of good APIDesign and modularity wherever I could. However I am tired...

Because it is always the same. Why do I have ask: where is your Usecase? What this method is good for? What do you actually want to achieve with this method/class/type? Have you considered the difference between APIvsSPI aspects of your design? Do you have a unit test? Is your proposed change BackwardCompatible? Do you have an evolution story for your design? Is your solution optimized for your comfort or comfort of users of your API? And so on and so on... People should read TheAPIBook before attempting to design an API, but they don't and they make the same mistakes again and again.

I got so disgust that I feel sick, physically sick, when I have to think about API design. Last weekend Toni asked me to review an API he is creating and showed me what he has. I starred at him, then at the code and at him, etc. for three minutes before I could say a word. Then I had to apologize and describe my current MidlifeCrisis.

When I look at an API these days, all I see is the wasted potential the API could have, but it doesn't and never will, because the amount of investment I would have to do to educate the API stakeholder is so huge, that I just don't want to make it.

Anyway, if you have an API that you'd like me to improve, let me know. If I see real interest in proper API design my disgust and MidlifeCrisis may go away...

--JaroslavTulach 16:08, 5 May 2017 (UTC)

Adam Bien - April 24, 2017 10:06 AM
GlassFish v5 (Java EE 8 RI)--Docker Image Is Available

GlassFish v5 ea (Java EE 8) builds available for download: http://download.oracle.com/glassfish/5.0/index.html

The nightly build is also available from docklands as glassfish5 and glassfish5-ping Dockerfiles.

Binary images are directly available from the public docker registry: https://hub.docker.com/u/airhacks/.

To start glassfishv5 perform docker run -d -p 8080:8080 --name glassfishv5 airhacks/glassfish-ping

The ping should be availabe after ~3 secs under: http://localhost:8080/ping.

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

netbeans – markiewb's blog - April 23, 2017 12:34 PM
NetBeans: How to simplify copy/paste Java code from online tutorials

Some months ago I created a small useful NetBeans plugin, which allows to you to save time when pasting code samples from online tutorials. Today I used it again and I still find it very useful in this specific context. And it saves you time. That is why I want to report about it.

What is the feature? You can copy the Java source code of whole classes from a tutorial and paste it via Menu|Edit|Paste to new file. Either the package declaration of the Java class is taken in account or the Java class is placed in the correct package. This depends on the selected node and it is documented included screencasts at https://github.com/markiewb/nb-paste-to-new-file.

That sounds familiar? Yes, this feature already exists natively in Eclipse JDT and Intellij IDEA.

Give it a try, when using NetBeans! Happy coding.

BTW: I am still looking for maintainers for my plugins! Because of time issues, I will not bugfix nor implement features anymore. Support your favorite IDE and by contribution to your favorite plugin!

PasteToNewJavaFile