Skip to main content

Vanilla Web Components at SpaceX

by admin at June 07, 2020 06:21 AM

Q:
"Mind blowing. You really broke some established patterns by choosing these technologies. Do you consider to open the sofian repo? And if you considered somewhen during the development to use another well know library?"
A:
"None of that is not established. In fact it's the opposite. Web components are built into the browser. JavaScript, CSS, and HTML are as well."
From: "We are the SpaceX software team, ask us anything!", parent thread

by admin at June 07, 2020 06:21 AM

Visual Studio Code: Java, XML and Quarkus--an airhacks.fm podcast episode

by admin at June 06, 2020 10:27 AM

Subscribe to airhacks.fm podcast via: spotify| iTunes| RSS

The #91 airhacks.fm episode with Fred Bricon (@fbricon) about:
Visual Studio Code (VSC) support for Java, Quarkus, Microprofile and XML
is available for download.

by admin at June 06, 2020 10:27 AM

Kafka, JAX-RS, MicroProfile, JSON-B, GSON, JWT, VSC, NetBeans, Java Fullstack--75th airhacks.tv

by admin at June 04, 2020 09:30 AM

75th airhacks.tv episode started with a few viewers questions and ended answering 20+ topics like:
"Kafka vs. JAX-RS / RPC, thoughts about APIs, JSON-B vs. GSON, Path.of over Paths.get, Java Records, MicroProfile JWT, beginners vs. expert content, best Java fullstack, code coverage, NetBeans in 2020, Visual Studio Setup for Java, screencast configuration, ReactJS / Angular over JSF?, JSON-P vs. JSON-B, security code scanning"

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


by admin at June 04, 2020 09:30 AM

JUnit 5: The Single Dependency You Need

by admin at June 03, 2020 07:21 AM

JUnit 5 requires a single dependency in the pom.xml:

<dependency>
    <groupId>org.junit.jupiter</groupId>
    <artifactId>junit-jupiter</artifactId>
    <version>5.6.2</version>
    <scope>test</scope>
</dependency>

...unfortunately, you will also have to declare the maven-surefire-plugin with version >=2.22.2:


<plugins>
    <plugin>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>2.22.2</version>
    </plugin>
</plugins>

by admin at June 03, 2020 07:21 AM

Hibernate’s ResultTransformer in Hibernate 4, 5 & 6

by Thorben Janssen at June 02, 2020 09:42 PM

The post Hibernate’s ResultTransformer in Hibernate 4, 5 & 6 appeared first on Thorben Janssen.

Hibernate implements JPA’s standardized constructor expressions and @SqlResultSetMappings to map the results of your queries. And it also supports proprietary ResultTransformers. They provide a powerful and flexible way to map the result of your JPQL, Criteria, and native SQL query to a specific object structure. This can be entity or DTO objects, java.util.List or java.util.Map […]

The post Hibernate’s ResultTransformer in Hibernate 4, 5 & 6 appeared first on Thorben Janssen.


by Thorben Janssen at June 02, 2020 09:42 PM

Bruno Hates YAML-Microsoft Loves Java--an airhacks.fm podcast episode

by admin at June 02, 2020 10:28 AM

Subscribe to airhacks.fm podcast via: spotify| iTunes| RSS

The #90 airhacks.fm episode with Bruno Borges (@brunoborges) about:
how YAML helps you to focus on whitespaces, Java at Microsoft, MicroProfile and metrics for cloud-native Java services
is available for download.

by admin at June 02, 2020 10:28 AM

The Payara Monthly Catch for May 2020

by Jadon Ortlepp (Jadon.Ortlepp@Payara.fish) at June 01, 2020 12:00 PM

 

Alot went down in May! notably Java's 25th anniversary and a whole swathe of articles, webinars and podcasts that went with it! It felt like there was a webinar everyday!

Below you will find a curated list of some of the most interesting news, articles and videos from the last month. Cant wait until the end of the month? then visit our twitter page where we post all these articles as we find them! 


by Jadon Ortlepp (Jadon.Ortlepp@Payara.fish) at June 01, 2020 12:00 PM

Kafka over JAX-RS, Spring to MP, JSON to POJO, Java Records, Code Coverage--or 75th airhacks.tv

by admin at June 01, 2020 09:04 AM

Topics (https://gist.github.com/AdamBien/f2487eefd36b718b4d3ee60064ab4e6e) for the 75th airhacks.tv (always first Monday of the month, 8pm CET / CEST):
  1. Kafka over JAX-RS?
  2. Migrations from Spring & AngularJS to JakartaEE/MicroProfile & Web Components
  3. JSON-B vs. GSON and the importance of APIs
  4. Thoughts on JSON to POJO mapping conventions
  5. Path.of over Paths.get
  6. Whats the point of Java Records?
  7. Is it possible to use the same MP JWT configuration on various servers / runtimes?
  8. Beginners vs. "expert" content
  9. The best "fullstack"
  10. Dangerous "Increasing Code Coverage" screencast
  11. NetBeans in 2020/2021
  12. Visual Studio Setup for Java
  13. screencast configuration

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


by admin at June 01, 2020 09:04 AM

Hashtag Jakarta EE #22

by Ivar Grimstad at May 31, 2020 09:59 AM

Welcome to the twenty-second issue of Hashtag Jakarta EE!

The work with Jakarta EE 9 is progressing, and we are looking forward to a milestone release at the end of June. There are so many moving parts in putting such a release together. All help is appreciated!

Here is a Jakarta EE 9 tracking sheet distributed on the Jakarta EE Ambassadors mailing list by Theodor Augustin Dumitrescuheo.

Jakarta MVC has been adopted by SOUJava. We encourage Java User Groups all over the world to participate in the Adopt-a-Spec program.

To wrap it up, here is a recording of a chat I had with Armel Nene on his #OffTheChain podcast last week.

#OffTheChain with Ivar Grimstad

by Ivar Grimstad at May 31, 2020 09:59 AM

Deploy Friday: E05 Open Source and Personal Networking for an Amazing Career

by otaviojava at May 28, 2020 11:54 AM

A Question and Answer session with guests:  Otavio Santana  Bruno Souza  Yara Senger  Robert Douglass

by otaviojava at May 28, 2020 11:54 AM

Java 14+: Java Record JSON Serialization and Deserialization with JSON-B

by admin at May 27, 2020 12:52 PM

To serialize a Java 14 POJR (Plain Old Java Record):

public record Developer(int age, String language) {
}
You can use stock JSON-B Jakarta EE API:

import javax.json.bind.Jsonb;
import javax.json.bind.JsonbBuilder;
import org.junit.jupiter.api.Test;

public class JavaTest {

    @Test
    public void jsonb() {
        Jsonb jsonb = JsonbBuilder.create();
        var developer = new Developer(25, "java");
        var serialized = jsonb.toJson(developer);
        System.out.println("serialized = " + serialized);
        var clone = jsonb.fromJson(serialized, Developer.class);
        System.out.println("clone = " + clone);
    }
}    

Java Record serialization might be not available with all SPI implementations. However, Apache Johnzon supports it out-of-the-box:


<dependency>
    <groupId>org.apache.geronimo.specs</groupId>
    <artifactId>geronimo-jsonb_1.0_spec</artifactId>
    <version>1.1</version>
</dependency>
<dependency>
    <groupId>org.apache.geronimo.specs</groupId>
    <artifactId>geronimo-json_1.1_spec</artifactId>
    <version>1.1</version>
</dependency>        
<dependency>
    <groupId>org.apache.johnzon</groupId>
    <artifactId>johnzon-jsonb</artifactId>
    <version>1.2.6</version>
</dependency>    

See it in action and from scratch in 3 mins:

The above unit test generates the following output:


serialized = {"age":25,"language":"java"}
clone = Developer[age=0, language=null]    
Thanks to @rmannibucau for the commits :-)


by admin at May 27, 2020 12:52 PM

Quickly grow your Java application in the cloud with Platform.sh

by otaviojava at May 26, 2020 12:25 PM

Moving to the cloud and scaling applications is a top priority for many businesses. However, migrating on-premise code to the cloud isn’t always easy, especially because Infrastructure-as-a-Service (IaaS), for example, does not eliminate the maintenance of databases, performing backups, etc. In this webinar you will learn how you can quickly grow your Java application in […]

by otaviojava at May 26, 2020 12:25 PM

Cloud and an Architectural Perspective Between Risk and Services

by otaviojava at May 25, 2020 10:22 AM

In this article, we discuss the various risks associated with different type of application architecture in the cloud. https://dzone.com/articles/cloud-and-an-architectural-perspective-between-ris

by otaviojava at May 25, 2020 10:22 AM

Hashtag Jakarta EE #21

by Ivar Grimstad at May 24, 2020 09:59 AM

Welcome to the twenty-first issue of Hashtag Jakarta EE!

It is tempting to jump a couple of numbers and call this hashtag issue number 25 to match the 25 year anniversary or Java. But I decided that I will stay true to the numbering scheme to avoid confusion and leave the craziness to when we are celebrating 25 years of Jakarta EE…

The Jakarta EE Working Group elections have completed. The newly elected committee members are as follows:

Steering Committee
Participant Member: Martijn Verburg
Committer Member: Arjan Tijms

Specification Committee
Participant Member: Marcelo Ancelmo
Committer Member: Werner Keil

Marketing Committee
Participant Member: Wei Yong Sen
Committer Member: VACANT

Jakarta MVC was approved by the Specification Committee and is now listed among the other Jakarta EE specifications. As soon as the final paperwork has been processed and the project fully provisioned, we will make the initial contribution and immediately start planning for the first release under Jakarta EE which will be Jakarta MVC 1.1.


by Ivar Grimstad at May 24, 2020 09:59 AM

25 Years of Java!

by Ivar Grimstad at May 23, 2020 07:21 AM

25 years and still going strong! Java is everywhere. It is the #1 programming language in the World. And it continues to evolve! Java has been a part of my entire professional career. Let’s get together and celebrate the past 25 years and look ahead for the next 25!

My #movedbyJava timeline

1996: Wrote my first Hello, World! in Java
1998: Started my professional career as a Java programmer
1999: My first JavaOne
2007: Joined the Java Community Process (JCP)
2013: First time presenting at JavaOne
2016: Became Java Champion
2016: Elected into the JCP Executive Committee
2016: Got a Duke tattoo
2020: Still coding Java


by Ivar Grimstad at May 23, 2020 07:21 AM

Jakarta EE 2020 Working Group Committee Elections Results are here!

by Tanja Obradovic at May 20, 2020 07:21 PM

We are very excited to announce the 2020-21 elected representatives!

This year, we used a secure online voting system to elect new members to the three Jakarta EE Working Group committees — Steering, Specification, Marketing and Branding. Email ballots were sent to the company representative for each Jakarta EE member company and to Jakarta EE committer members. The voting period was open May 1and closed on Friday, May 15, 2020. Results are now available!

The elected representatives for the Jakarta EE Committees are:

Committee

Participant Member Candidates

Committer Member Candidates

Steering

Martijn Verburg

Arjan Tijms

Specification

Marcelo Ancelmo

Werner Keil*

Marketing and Brand

Wei Yong Sen*

N/A

* Acclaimed to the role as the only candidate.

For each Participant Representative in the Committees 50% voted, and for the Committer Representative 23% voted.

Congratulations to those who have been elected and thanks to everyone who participated and voted in the election!


by Tanja Obradovic at May 20, 2020 07:21 PM

10 YouTube Channels You Should Follow in 2020

by Thorben Janssen at May 19, 2020 12:00 PM

The post 10 YouTube Channels You Should Follow in 2020 appeared first on Thorben Janssen.

For the last 2 years, I have shared a list of the Java-related YouTube channels that I find the most enjoyable or useful. And based on the popularity of these articles, it seems like I’m not the only one who enjoys watching good lectures and conference talks on YouTube. That’s especially the case in the […]

The post 10 YouTube Channels You Should Follow in 2020 appeared first on Thorben Janssen.


by Thorben Janssen at May 19, 2020 12:00 PM

Evolution of Microservices and the Payara Platform Solution

by Ondrej Mihályi at May 18, 2020 10:19 AM

For some time now there has been an undeniable growth of interest for Microservices. The core concept itself, however, is not that new.


by Ondrej Mihályi at May 18, 2020 10:19 AM

Jakarta EE Community Update May 2020

by Tanja Obradovic at May 17, 2020 03:20 PM

Jakarta EE 2020 Working Group Committee Elections

With just a few days until the Jakarta EE election results are announced on May 21, I want to start this month’s newsletter with a quick update on the overall process.

This year, we used a secure online voting system to elect new members to the three Jakarta EE Working Group committees — Steering, Specification, Marketing and Brand. Email ballots were sent to the company representative for each Jakarta EE member company and to Jakarta EE committer members. The voting period was open May 1-15. Results are tabulated by the system and remain anonymous.

 The table below lists the candidates and provides links to their biographies. Thank you to all candidates for your interest and participation!

Committee

Participant Member Candidates

Committer Member Candidates

Steering

Martijn Verburg

Jeff Zhang

Otavio Santana

Arjan Tijms

Specification

Marcelo Ancelmo

Patrick Huang

Werner Keil*

Marketing and Brand

Wei Yong Sen*

N/A

* Acclaimed to the role as the only candidate.

For a list of the winning candidates, keep an eye on our social media posts, mailing lists, and my June Jakarta EE update blog.

 _________________________________

 Thank you for your participation in the 2020 Jakarta EE Developer Survey

Thank you to everyone who took the time to participate in the 2020 Jakarta EE Developer Survey. We had great community engagement, and received more than 2,100 responses from developers around the world.

With your input, everyone in the Java ecosystem will have a better understanding of how the cloud native world for enterprise Java is unfolding and what that means for their strategies and businesses. And the Jakarta EE community will have a better understanding of developers’ top priorities for future Jakarta EE releases.

Stay tuned for the survey results in late June.

_________________________________

JakartaOne Livestream CN4J Replays Are Available Online

We hosted a very successful JakartaOne Livestream Cloud Native for Java (CN4J) event on May 12, with eight hours of great content, including two keynotes, and seven technical talks.

 The virtual event featured a mix of interesting talks, demos, and thought-provoking discussions focused on enterprise applications implemented using Jakarta EE and Eclipse MicroProfile specifications on Kubernetes. The complete event agenda is available here.

 So far, about 550 people have registered to watch the sessions so we know the topics are resonating with the community. You can check out the complete playlist and register to watch session replays here.  

_________________________________

The Jakarta EE Compatible Products List Is Growing

We’re very pleased to tell you the Apusic AAS Application Server version 10.1, from Kingdee Apusic cloud computing, is now certified as a Jakarta EE 8 full platform compatible product.

 In addition, more and more applications are passing Technology Compatibility Kit (TCK) tests and are well on their way to becoming certified as Jakarta EE 8 compatible products. The Oracle WebLogic Server 14c (14.1.1) is just one great example.

 For a complete list of Jakarta EE 8 compatible products, and access to download links, visit the Jakarta EE Compatible Products webpage.

 ________________________________

 Content Resources for the Jakarta EE Presentations

If you’re creating a Jakarta EE presentation for virtual Java User Group (JUG) meetings, conferences, or other events, feel free to incorporate the information in our Jakarta EE presentation deck. We recently updated the content based on your feedback.

 Also, please let us know when and where the presentation will be made so we can promote the speaker and the event on Jakarta EE channels. You can email me directly, or use this webform to provide the event details.

For additional Jakarta EE content and programs, including Crowdcast (virtual meetup tool)  for JUGs and Jakarta EE update presentations, visit our community folder.

 _________________________________

 Get the Latest Updates on Jakarta EE 9 Progress

Keep an eye out for Steve Millidge’s article in the May community newsletter for updates on Jakarta EE 9 delivery progress. You can also check our progress here

Here is the short summary of great progress the community is making:

  • API Release Candidates available for all specs

  • Milestone implementations for all components 

  • Growing number of component TCKs

  • Eclipse GlassFish 6.0 building

  • “Nucleus” GlassFish runtime booting

  • Jersey, HK2, Grizzly and core kernel capabilities

 For additional insight into Jakarta EE 9, see the:

·      Jakarta EE Platform specification page

·      GitHub page

_________________________________

 Join Community Update Calls

The Jakarta EE community calls are open for everyone! For upcoming dates and connection details, see the Jakarta EE Community Calendar.

 The next call will be June 10 at 11:00 a.m. EDT. The call in May was cancelled due to the JakartaOne Livestream event on May 12, and all key Jakarta EE news were covered in Will Lyons’ keynote.

 We know it’s not always possible to join calls in real time, so here are links to the recordings and presentations:

·       The complete playlist.

·      April 8 call and presentation, featuring Ivar’s update on contributing to Jakarta EE 9, as well as updates on Jakarta EE events, new compatible implementations, the Jakarta EE Developer Survey, election time, and programs for JUGs from Shabnam Mayel, Tanja Obradovic, and Ivar Grimstad.

 _________________________________

 Upcoming Events

With the impact of COVID-19 on events and conferences, we’re focusing on virtual events:

·      On August 29, we’re hosting JakartaOne Livestream Brazil.

·      In September, we’ll be hosting the annual JakartaOne Livestream event and will provide details when they’re available.

_________________________________

 Stay Connected With the Jakarta EE Community

The Jakarta EE community is very active and there are a number of channels to help you stay up to date with all of the latest and greatest news and information. Subscribe to your preferred channels today:

·  Social media: Twitter, Facebook, LinkedIn Group

·  Youtube: Jakarta EE channel

·  Mailing lists: jakarta.ee-community@eclipse.org, jakarta.ee-wg@eclipse.org, project mailing lists

·  Newsletters, blogs, and emails: Eclipse newsletter, Jakarta EE blogs, Hashtag Jakarta EE blog

·  Meetings: Jakarta Tech Talks, Jakarta EE Update, Jakarta Town Hall, and Eclipse Foundation events and conferences

 You can find the complete "Stay connected" list here.

 And, get involved in the Jakarta EE Working Group to help shape the future of open source, cloud native Java.

 To learn more about Jakarta EE-related plans and check the date for the next Jakarta Tech Talk, be sure to bookmark the Jakarta EE Community Calendar.

 _________________________________

 

 


by Tanja Obradovic at May 17, 2020 03:20 PM

Hashtag Jakarta EE #20

by Ivar Grimstad at May 17, 2020 09:59 AM

Welcome to the twentieth issue of Hashtag Jakarta EE!

The web page for the Starter for Jakarta EE is launched! So far, it is pretty limited, but we hope that the community can join us in making start.jakarta.ee the absolutely best place to get started with Jakarta EE.

Please check out our project pages for resources about how to get involved.

Earlier this week, we hosted the JakartaOne Livestream: Cloud Native for Java event. The talks are published on the Jakarta EE Youtube channel.

I also recorded a short video showing how to check the third-party dependencies with a tool called dash-licences. The tool is developed by Wayne Beaton and he describes the background for it in his blog post Revising the Eclipse Due Diligence Process for Third Party Content.

Never Stop Learning

If you’re not tired by now, read this interview of me by Bob Rhubart that was published earlier this week.


by Ivar Grimstad at May 17, 2020 09:59 AM

SonarQube Just Do It!

May 14, 2020 07:56 AM

Code transparency … Yes please…

Recently I gave a small seminar for my current client about Clean Code and Craftsmanship. The group I was talking to
consisted of developers of all levels from junior to senior.

To my complete consternation, when I started talking about tools like PMD / CheckStyle and SonarQube, I found out that
none of them had ever heard of these tools. Not even the Senior developers.

Well this is bad and needs to be fixed!

This article will give a short explanation about what SonarQube is.
It is also a quick guide on how to start working with it.
This will be done with the use of docker because I want to :-)

Prerequisites:

  • docker(-compose)
  • maven
  • java

What is SonarQube?

This is what SonarQube has to say about it.

Continues Inspection
SonarQube provides the capability to not only show health of an application but also to highlight issues newly
introduced. With a Quality Gate in place, you can fix the leak and therefore improve code quality systematically.

How?

SonarQube will analyse your code by analysing it statically. Without knowing the inner workings of your application it will
“look” at your code and search for code constructions that are known to be fragile or just wrong. After the scan
it will generate a report in the form of a browseable website. All issues are explained and you are probably also provided
a possible solution for it.

Example:

Noncompliant code: “for” loop increment clauses should modify the loops’ counters

1
2
3
4
for (i = 0; i < 10; j++) {  // Noncompliant
// ...
i++;
}

Lots of these language constructions can be tested statically and at the point of this writing there are 423 checks done.

Use it yourself

With docker it is very easy to start your own SonarQube service:

1
docker run --rm --name sonarqube -p 9000:9000 -p 9092:9092 sonarqube:alpine

The command provided above will erase all history when stopped, but for learning purposes and demo’s that is fine.
Farther below I will give some more permanent solutions for local use and some hints for enterprise use.

now go to your maven project and run:

1
mvn sonar:sonar -Dsonar.host.url=http://localhost:9000

If maven the tells you that the build was successful, you can go look on localhost:9000 and
be amazed at how good or bad your code is.

Take time

If you are willing to take the time to really look into the found issues (yes even the ‘info’ ones) and willing to
go and fix these issues, you are on the way to becoming a better developer.

Positive effect on a team

The beauty of using a tool like Sonar is that it will also keep history when configured correctly and therefore provide
you with a way of monitoring improvement. If you see improvements and also demonstrate this during sprint reviews, you
will start to notice a marked positive effect on your team. Team members will be more proud of the code they are writing
and become better as a group. Reviews will start to take code quality into account.

Quality Gate

When you have a level of quality reached where you are comfortable you don’t want to loose it. This is the moment you
can introduce the use of a quality gate. This is a level of quality you can define for your project and if the code does
not meet the requirements set by the Quality Gate the build will fail. So that is the moment that Code quality might
fail the build. A very powerful thing and one that raises the maturity level of the team significantly.

More advanced examples

Local with database

If you are done with the above provided commands and you want a more permanent solution for your local projects but don’t
want to have to create a complete pipeline just for your hobby projects…

We need a database image and the sonar image.

Here the docker-compose.yml file containing the two images and their connections

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
version: "3"

services:
sonarqube:
image: sonarqube
ports:
- "9000:9000"
networks:
- sonarnet
environment:
- SONARQUBE_JDBC_URL=jdbc:postgresql://database:5432/sonar
volumes:
- sonarqube_conf:/opt/sonarqube/conf
- sonarqube_data:/opt/sonarqube/data
- sonarqube_extensions:/opt/sonarqube/extensions
- sonarqube_bundled-plugins:/opt/sonarqube/lib/bundled-plugins

database:
image: postgres
networks:
- sonarnet
environment:
- POSTGRES_USER=sonar
- POSTGRES_PASSWORD=sonar
volumes:
- postgresql:/var/lib/postgresql
# This needs explicit mapping due to https://github.com/docker-library/postgres/blob/4e48e3228a30763913ece952c611e5e9b95c8759/Dockerfile.template#L52
- postgresql_data:/var/lib/postgresql/data

networks:
sonarnet:
driver: bridge

volumes:
sonarqube_conf:
sonarqube_data:
sonarqube_extensions:
sonarqube_bundled-plugins:
postgresql:
postgresql_data:

This image creates volumes for all stuff needed to be saved.

Lets start it up.

1
docker-compose up -d

You can leave of the -d if you want to see what’s happening. It will start in the foreground and not in ‘detached’ mode.

Now if you stop the containers it will preserve the state of your database in the volumes defined.

To stop the containers go back to your docker-compose.yml file and do:

1
docker-compose down

And if you want to loose all your data (volumes) too:

1
docker-compose down -v

Pipeline

If you use tools like Jenkins to control your pipeline it is very useful to add SonarQube as part of the pipeline setup.
If you do not have control over the pipeline environment, you should ask the Ops guys to install Sonar for you. If you do have
control over the pipeline, it is a very good idea to make it part of it. It will make code quality something as part of your
daily life. Jenkins has good integration for tools like sonar and configuring it is not the obstacle it might seem.

Just maven

You don’t have to do anything to have sonar working for maven. It is one of the default plugins (it is that important yes!) and always available
for all projects. You just have to tell it where sonar ‘lives’ and this can be done through the command line (see above).
If you want to just be able to do mvn sonar:sonar you can tell maven where sonar lives by editing the $HOME/.m2/settings.xml file
by adding the following piece of code to it:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<profiles>
<profile>
<id>sonar</id>
<properties>
<!--<sonar.jdbc.url>jdbc:postres://localhost:3306/sonar</sonar.jdbc.url>-->
<!--<sonar.jdbc.driver>com.mysql.jdbc.Driver</sonar.jdbc.driver>-->
<!--<sonar.jdbc.username>sonar</sonar.jdbc.username>-->
<!--<sonar.jdbc.password>xxxxx</sonar.jdbc.password>-->
<!-- SERVER ON A REMOTE HOST -->
<sonar.host.url>http://localhost:9000</sonar.host.url>
</properties>
</profile>
</profiles>
<activeProfiles>
<activeProfile>sonar</activeProfile>
</activeProfiles>

some lines have been commented out. This is because in the form I provided above (docker-compose.yml) you don’t need to tell maven
where the database is because it already knows. If you choose to install a database native on your machine and sonar to (without docker)
you can enable these lines and adjust them to conform to your needed settings.

Conclusion

Not doing these kinds of code checks as a developer is robbing you of a learning experience and the opportunity of an extra
review. The static code checker does not get tired or is under pressure. It will just check your code and help you become
better and your code too.

So SonarQube … Just do it!


May 14, 2020 07:56 AM

Your 2 best options to fix Hibernate’s MultipleBagFetchException

by Thorben Janssen at May 12, 2020 12:00 PM

The post Your 2 best options to fix Hibernate’s MultipleBagFetchException appeared first on Thorben Janssen.

You probably learned that you should use FetchType.LAZY for all of your associations. It ensures that Hibernate initializes an association when you use it and doesn’t spend any time getting data you don’t need. Unfortunately, this introduces a new issue. You now need to use a JOIN FETCH clause or an EntityGraph to fetch the […]

The post Your 2 best options to fix Hibernate’s MultipleBagFetchException appeared first on Thorben Janssen.


by Thorben Janssen at May 12, 2020 12:00 PM

Migrate from GlassFish to Payara Server Enterprise

by Jadon Ortlepp (Jadon.Ortlepp@Payara.fish) at May 11, 2020 02:30 PM

Migrating from GlassFish to Payara Server can be a simple and straightforward process, made even simpler with the help of our 'GlassFish to Payara Server Migration Guide'.


by Jadon Ortlepp (Jadon.Ortlepp@Payara.fish) at May 11, 2020 02:30 PM

Workshops: Reactive Apps with Quarkus and OpenShift

by Niklas Heidloff at May 11, 2020 01:19 PM

In the context of cloud-native applications the topic ‘reactive’ becomes more and more important, since more efficient applications can be built and user experiences can be improved. If you want to learn more about reactive functionality in Java applications, read on and try out the sample application and the two new workshops.

Benefits of reactive Applications

In order to demonstrate benefits of reactive applications, I’ve developed a sample application with a web interface that is updated automatically when new data is received rather than pulling for updates. This is more efficient and improves the user experience.

The animation shows how articles can be created via curl commands in the terminal at the bottom. The web application receives a notification and adds the new article to the page.

Another benefit of reactive systems and reactive REST endpoints is efficiency. This scenario describes how to use reactive systems and reactive programming to achieve faster response times. Especially in public clouds where costs depend on CPU, RAM and compute durations this model saves money.

The project contains a sample endpoint which reads data from a database in two different versions, one uses imperative code, the other one reactive code. The reactive stack of this sample provides response times that take less than half of the time compared to the imperative stack: Reactive: 793 ms – Imperative: 1956 ms.

Workshops

I’ve written two workshops which demonstrate and explain how to build reactive functionality with Quarkus and MicroProfile and how to deploy and run it on OpenShift. You can use Red Hat OpenShift on IBM Cloud or you can run OpenShift locally via Code Ready Containers.

The sample used in the workshops leverages heavily Quarkus which is “a Kubernetes Native Java stack […] crafted from the best of breed Java libraries and standards”. Additionally Eclipse MicroProfile, Eclipse Vert.x, Apache Kafka, PostgreSQL, Eclipse OpenJ9 and Kubernetes are used.

Workshop: Reactive Endpoints with Quarkus on OpenShift

This workshop focusses on how to provide reactive REST APIs and how to invoke services reactively. After you have completed this workshop, you’ll understand the following reactive functionality:

  • Reactive REST endpoints via CompletionStage
  • Exception handling in chained reactive invocations
  • Timeouts via CompletableFuture
  • Reactive REST invocations via MicroProfile REST Client

Open Workshop

Workshop: Reactive Messaging with Quarkus on OpenShift

This workshop focusses on how to do messaging with Kafka and MicroProfile. After you have completed this workshop, you’ll understand the following reactive functionality:

  • Sending and receiving Kafka messages via MicroProfile
  • Sending events from microservices to web applications via Server Sent Events
  • Sending in-memory messages via MicroProfile and Vert.x Event Bus

Open Workshop

Next Steps

To learn more, check out the other articles of this blog series:

The post Workshops: Reactive Apps with Quarkus and OpenShift appeared first on Niklas Heidloff.


by Niklas Heidloff at May 11, 2020 01:19 PM

Hashtag Jakarta EE #19

by Ivar Grimstad at May 10, 2020 12:09 PM

Welcome to the nineteenth issue of Hashtag Jakarta EE!

This week, we got a new project proposal for a Jakarta EE Specification!

We finally got around to it and created the project proposal for Jakarta MVC. The proposal is to transfer MVC 1.0 (JSR 371) to Jakarta EE. Eclipse Krazo is already transferred, so this will complete the exercise and bring MVC over where it belongs with the other Jakarta EE specifications.

As soon as the project has been approved, we will release Jakarta MVC 1.1 under the JESP pretty quickly. This release will not include any code changes, and therefore still be in the javax.* namespace. Java EE references will be removed from the specification document and be replaced by Jakarta EE counterparts. The release will be published with the Jakarta EE maven coordinates.

The next step after this is to move everything from javax.* to jakarta.*. This will result in Jakarta MVC 2.0 that will be released simultaneously with, or directly after, Jakarta EE 9.

By doing it this way, and not jumping directly into the namespace change directly with the first release, we ensure that the specification is aligned with all the recent platform releases:

MVC 1.0 -> Java EE 8
Jakarta MVC 1.1 -> Jakarta EE 8
Jakarta MVC 2.0 -> Jakarta EE 9

For Jakarta EE 10, it would be natural to aim for getting Jakarta MVC included in the Web Profile.

In the end, I will remind you about the ongoing elections to the Jakarta EE working group. If you are eligible to vote, you have received information about how to proceed in your mail. The bios of all the candidates are available in the Jakarta EE Community Drive.


by Ivar Grimstad at May 10, 2020 12:09 PM

Connect Payara Micro to External JMS Broker by Deploying a RAR file

by Ondrej Mihályi at May 08, 2020 12:15 PM

Payara Micro is a lightweight middleware platform for containerized Jakarta EE application deployments, but it still provides a lot of APIs and functionality for developers. On top of all Jakarta EE Web Profile APIs, Payara Micro also supports a additional Jakarta EE APIs, and it also provides the same MicroProfile, Payara, and JCache APIs as our complete application platform, Payara Server. In this article, we’ll show you how to make use of Jakarta Messaging (JMS) in Payara Micro to send and receive messages to and from a JMS broker.


by Ondrej Mihályi at May 08, 2020 12:15 PM

Considerations When Migrating from Wildfly to Payara Server

by Jadon Ortlepp (Jadon.Ortlepp@Payara.fish) at May 06, 2020 12:15 PM

Migrating applications from WildFly to Payara Server can be a simple and straightforward process because both servers rely on the Jakarta EE (Java EE) specifications. However, there are differences in many areas because many Java EE APIs in WildFly and Payara Server are implemented by different components. Moreover, the configuration of certain aspects like external resources, high-availability and deployment is not covered by any specification and is, in fact, very different in both servers. Although Payara Server offers similar features as WildFly, they are often based on different technologies and concepts, and often also use different terminology. Therefore, before going into migration from WildFly to Payara Server, we’ll provide you with an overview of similar features and concepts that exist in both WildFly and Payara Server.


by Jadon Ortlepp (Jadon.Ortlepp@Payara.fish) at May 06, 2020 12:15 PM

Deploy Friday: E03 Moving enterprise Java applications to the cloud

by otaviojava at May 05, 2020 01:02 PM

A Question and Answer session with guests: Otavio Santana Elder Moraies Ivar Grimstad Rudy De Busscher Robert Douglass

by otaviojava at May 05, 2020 01:02 PM

The best way to fetch an association defined by a subclass

by Thorben Janssen at May 05, 2020 12:38 PM

The post The best way to fetch an association defined by a subclass appeared first on Thorben Janssen.

EntityGraphs and JOIN FETCH clauses provide an easy and efficient way to fetch an entity and initialize its associations. But if you try to use it with a domain model that uses inheritance, you will quickly run into an issue: You can’t use this approach in a polymorphic query to fetch an association that’s defined […]

The post The best way to fetch an association defined by a subclass appeared first on Thorben Janssen.


by Thorben Janssen at May 05, 2020 12:38 PM

The Payara Monthly Catch for April 2020

by Jadon Ortlepp (Jadon.Ortlepp@Payara.fish) at May 04, 2020 01:10 PM

 

With the lock downs raging on, more events are being cancelled and postponed. The upside is many have also pivoted to being virtual and many advocates are now pumping out interesting webinars and videos. The quality of content has also certainly not diminished, so read on dear reader!

Below you will find a curated list of some of the most interesting news, articles and videos from this month. Cant wait until the end of the month? then visit our twitter page where we post all these articles as we find them! 


by Jadon Ortlepp (Jadon.Ortlepp@Payara.fish) at May 04, 2020 01:10 PM

Hashtag Jakarta EE #18

by Ivar Grimstad at May 03, 2020 09:59 AM

Welcome to the eighteenth issue of Hashtag Jakarta EE!

In the following video, you can watch an interview I did with Martijn Verburg regarding his nomination to the Jakarta EE Steering Group representing London Java Community.

“Vote for the voice of the Java Community, vote for Martijn!”

When talking about YouTube, I have been busy recording a couple of tech tips for how to sign off your Git commits when contributing to Eclipse Foundation projects. All these tips are collected in a Playlist in the Studio Jakarta EE YouTube channel.

For convenience, I have listed a summary of the commands I used in the video here.

# rebase
git rebase -i [hash of the commit before the one you want to fix]

# replace the word 'pick' with 'edit', save

# add signed-off comment to the commit
git commit --amend -s

# continue the rebase
git rebase --continue

# finally force push the updated commits
git push origin [your branch] --force

And we’re not done with YouTube just yet. This week, we launched the Jakarta EE YouTube channel.

How is this different from Studio Jakarta EE, you may wonder…

The answer to that is that I don’t know yet. It may make sense to merge them sometime in the future. Or keep them apart since the type of content may be a little different. My idea with the Studio Jakarta EE channel is to have a lightweight platform for Jakarta EE related content of varying types, such as interviews, tech tips, live streams, panels, trip reports from conferences, etc. So please, go ahead and subscribe to both. That way you are sure not to miss out on anything.


by Ivar Grimstad at May 03, 2020 09:59 AM

Rich web application on pure Java with Vaadin and Quarkus

April 28, 2020 09:00 PM

Recently I wrote about REST API with Eclipse Microprofile and Quarkus - and it is very useful for the microservices development, but from time to time every backend Java developer needs for the UI. With Vaadin web framework you can write UI 100% in Java without getting bogged down in JS, HTML, and CSS.

Quarkus provides Servlet and Websocket support as well, so there is no any blockers to run web application.
To bootstrap Quarkus from the scratch you can visit code.quarkus.io and select build tool you like and extensions you need. In our case we need for:

  • Undertow Servlet
  • Undertow WebSockets

With Vaadin 8 dependencies my build.gradle looks pretty clear:

plugins {
    id 'java'
    id 'io.quarkus'
}
repositories {
     mavenLocal()
     mavenCentral()
}
dependencies {
    compile 'com.vaadin:vaadin-server:8.10.3'
    compile 'com.vaadin:vaadin-push:8.10.3'
    compile 'com.vaadin:vaadin-client-compiled:8.10.3'
    compile 'com.vaadin:vaadin-themes:8.10.3'
    implementation 'io.quarkus:quarkus-undertow-websockets'
    implementation 'io.quarkus:quarkus-undertow'
    implementation enforcedPlatform("${quarkusPlatformGroupId}:${quarkusPlatformArtifactId}:${quarkusPlatformVersion}")
}

group 'org.kostenko'
version '1.0.0-SNAPSHOT'

compileJava {
    options.encoding = 'UTF-8'
    options.compilerArgs << '-parameters'
}

Now we able to create com.vaadin.ui.UI

@Theme("dashboard")
public class MyUI extends UI {

    @Override
    protected void init(VaadinRequest vaadinRequest) {
      ...
    }

    /**
     * VaadinServlet configuration
     */
    @WebServlet(urlPatterns = "/*", name = "MyUIServlet", asyncSupported = true, initParams = {
        @WebInitParam(name = "org.atmosphere.websocket.suppressJSR356", value = "true")}
    )
    @VaadinServletConfiguration(ui = MyUI.class, productionMode = false)
    public static class MyUIServlet extends VaadinServlet {
    }
}

Put Vaadin static files to the /src/main/resources/META-INF/resources/VAADIN and run quarkus in dev mode as usual ./gradlew quarkusDev:

Listening for transport dt_socket at address: 5005
__  ____  __  _____   ___  __ ____  ______
 --/ __ \/ / / / _ | / _ \/ //_/ / / / __/
 -/ /_/ / /_/ / __ |/ , _/ ,< / /_/ /\ \   
--\___\_\____/_/ |_/_/|_/_/|_|\____/___/   
2020-04-29 09:49:37,718 WARN  [io.qua.dep.QuarkusAugmentor] (main) Using Java versions older than 11 to build Quarkus applications is deprecated and will be disallowed in a future release!
2020-04-29 09:49:38,389 INFO  [io.und.servlet] (Quarkus Main Thread) Initializing AtmosphereFramework
2020-04-29 09:49:38,579 INFO  [io.quarkus] (Quarkus Main Thread) Quarkus 1.4.1.Final started in 0.995s. Listening on: http://0.0.0.0:8080
2020-04-29 09:49:38,579 INFO  [io.quarkus] (Quarkus Main Thread) Profile dev activated. Live Coding activated.
2020-04-29 09:49:38,579 INFO  [io.quarkus] (Quarkus Main Thread) Installed features: [cdi, servlet, undertow-websockets]
2020-04-29 09:49:46,423 WARNING [com.vaa.ser.DefaultDeploymentConfiguration] (executor-thread-1)                                                                                                                                                             
=================================================================                                                                                                                                                                                            
Vaadin is running in DEBUG MODE.
Add productionMode=true to web.xml to disable debug features.
To show debug window, add ?debug to your application URL.
=================================================================

Example application I did based on vaadin/dashboard-demo that uses nicely looking and responsive Valo theme

quarkus + vaadin

Current solution limitations and workaround:

  • Latest Vaadin version (14+) does not work from the box and needs for custom Quarkus extensions like moewes/quarkus-vaadin-lab and there is still no official one :(
  • Vaadin CDI doesn't work as expected, so to access your CDI beans from the UI components you should use CDI.current().select(Bean.class).get();
  • By default Quarkus removes CDI beans from the runtime if no one @Inject them. Use io.quarkus.arc.Unremovable annotation for keep beans you need.
  • In case java.lang.IllegalStateException:Unable to configure jsr356 at that stage. ServerContainer is null - provide org.atmosphere.websocket.suppressJSR356 VaadinServlet parameter as was shown in the code snippet above
  • Quarkus native mode doesn't work

Described example application source code available on GitHub


April 28, 2020 09:00 PM

Managing Transactions with Spring and Spring Data JPA

by Thorben Janssen at April 28, 2020 12:06 PM

The post Managing Transactions with Spring and Spring Data JPA appeared first on Thorben Janssen.

Spring Boot and Spring Data JPA make the handling of transactions extremely simple. They enable you to declare your preferred transaction handling and provide seamless integration with Hibernate and JPA. The only thing you need to do is to annotate one of your methods with @Transactional. But what does that actually do? Which method(s) should […]

The post Managing Transactions with Spring and Spring Data JPA appeared first on Thorben Janssen.


by Thorben Janssen at April 28, 2020 12:06 PM

Advanced Administration & Maintenance of Payara Server

by Jadon Ortlepp (Jadon.Ortlepp@Payara.fish) at April 28, 2020 11:30 AM

After you've got familiar with administering Payara Server, having configured your domain and deployed your applications, you might find it useful to get some more information on features supporting maintenance of your domain in the longer term.  If you are not quite there yet, have a look at our resources page or our getting started page.


by Jadon Ortlepp (Jadon.Ortlepp@Payara.fish) at April 28, 2020 11:30 AM

The most frequently asked questions about Java, Cloud, PaaS and Platform.sh

by otaviojava at April 27, 2020 06:32 PM

1 What is cloud computing? That is an easy one, briefly, that is somebody else’s computer. 2 Why should I move my project to the cloud? As a software company, you don’t care about the hardware. The goal is to run your application and focus on your business, which means you don’t need to buy […]

by otaviojava at April 27, 2020 06:32 PM

Jakarta EE Meets NoSQL at the cloud age

by otaviojava at April 27, 2020 11:31 AM

Payara eBook Payara Platform and PaaS with Platform.sh Payara GitHub code Cloud Native Architecting Cloud Native Applications: Design high-performing and cost-effective applications for the cloud What is cloud-native? The modern way to develop software Cloud Native Development Patterns and Best Practices: Practical architectural patterns for building modern, distributed cloud-native systems Cloud Native Transformation: Practical Patterns […]

by otaviojava at April 27, 2020 11:31 AM

Hashtag Jakarta EE #17

by Ivar Grimstad at April 26, 2020 09:55 AM

Welcome to the seventeenth issue of Hashtag Jakarta EE!

The nomination period for the Jakarta EE Working group elections has closed. Now, it is up to the candidates to convince you why they should get YOUR vote. To help with this, I have offered each candidate a short Studio Jakarta EE interview.

“Vote for experience and continuity, vote for Werner!”
“Vote for real world experience, vote for Arjan!”

Next week, I will be conducting interviews with more of the candidates. So, tune in to Studio Jakarta EE to learn more about the candidates before casting your vote!

At the end of this hashtag, I want to remind you of the Jakarta EE 2020 Developer Survey.


by Ivar Grimstad at April 26, 2020 09:55 AM

Easy ways to bring your Java Microservices to the Cloud

by Jadon Ortlepp (Jadon.Ortlepp@Payara.fish) at April 24, 2020 09:05 AM

All companies are software companies, and businesses will always experience the challenge of keeping integrations between users and applications scalable, productive, fast, and of high quality. To combat this, cloud, microservices, and other modern solutions come up more and more in architectural decisions. Here is the question: Is Java prepared to deal with these diverse concepts in a corporate environment?


by Jadon Ortlepp (Jadon.Ortlepp@Payara.fish) at April 24, 2020 09:05 AM

Easy way to bring your Java Microservices to the cloud with Payara and Platform.sh Webinar

by otaviojava at April 22, 2020 11:05 AM

Topic Easy way to bring your Java Microservices to the cloud with Payara and Platform.shDescription: All companies are software companies, and businesses will always experience the challenge of keeping integrations between users and applications scalable, productive, fast, and of high quality. To combat this, cloud, microservices, and other modern solutions come up more and more […]

by otaviojava at April 22, 2020 11:05 AM

Using Payara Server with Docker

by Jadon Ortlepp (Jadon.Ortlepp@Payara.fish) at April 22, 2020 09:36 AM

Docker is a platform which makes it easier to create, deploy and run your applications using containers. A container bundles all the software needed to run it. By packaging the required dependencies, it makes it easy to run it on any machine, regardless of small configuration differences. This article will explain more about introducing Docker. 


by Jadon Ortlepp (Jadon.Ortlepp@Payara.fish) at April 22, 2020 09:36 AM

Cloud-native with Payara and Platform.sh

by otaviojava at April 21, 2020 12:37 PM

This article discusses how to create your first REST project with Payara Micro, and then move that project to Platform.sh using the Maven Archetype. Reference: https://dzone.com/articles/payara-and-paas-with-platformsh

by otaviojava at April 21, 2020 12:37 PM

Take the 2020 Jakarta EE Developer Survey now!

by Tanja Obradovic at April 20, 2020 08:45 PM

Jakarta EE Working Group and Eclipse Foundation are always excited to hear from you and learn about your cloud native journey! We have launched the 2020 Jakarta EE Developer Survey and look forward to your input as it will help with further plans for the future of Jakarta EE. 

Please let us know about your next steps for cloud native development as well as your choices for architectures, technologies, and tools as cloud native resources mature.  Based on the information collected, the Jakarta EE community will have a better understanding of developers’ top priorities for future Jakarta EE releases.

The survey will be open till April 30th! It takes less than 10 minutes to complete! Take the Jakarta EE 2020 Survey now!


by Tanja Obradovic at April 20, 2020 08:45 PM

Getting Started with Payara Server

by Jadon Ortlepp (Jadon.Ortlepp@Payara.fish) at April 20, 2020 01:49 PM

Using Payara Server for the first time?

We’ve put together this step-by-step “Getting Started Guide” to help you with everything you need to successfully install and put Payara Server to work for you, including:


by Jadon Ortlepp (Jadon.Ortlepp@Payara.fish) at April 20, 2020 01:49 PM

DTO: Hipster or Deprecated?

by otaviojava at April 20, 2020 12:21 PM

The purpose of this article is to talk a little bit about the usefulness of DTO and address this question. References: https://dzone.com/articles/dto-hipster-or-deprecated

by otaviojava at April 20, 2020 12:21 PM

Developing a GraphQL client on MicroProfile with Quarkus

by Jean-François James at April 20, 2020 09:52 AM

Following the release of MicroProfile GraphQL 1.0, Phillip Krüger has recently published an article introducing what is GraphQL and how to develop a server. Here, we propose to focus on the client-side and illustrate how to interact with a GraphQL endpoint using Java in a JakartaEE and MicroProfile context. This article is backed by a […]

by Jean-François James at April 20, 2020 09:52 AM

Hashtag Jakarta EE #16

by Ivar Grimstad at April 20, 2020 07:46 AM

Welcome to the sixteenth issue of Hashtag Jakarta EE!

I know, it’s Monday and I am one day late…I usually publish these Hashtags on Sundays. My excuse this time is that it was such beautiful weather and I was busy preparing my boat for the season. Totally slipped my mind, but here we go!

Have you nominated yourself to the Jakarta EE Elections yet? If you haven’t, there is still time. The nomination period ends on April 24, 2020.

Serving on one of the Jakarta EE committees is an excellent opportunity to increase your knowledge about governance in general and Jakarta EE specifically. It is the best way to influence the direction forward and be a part of shaping the future of Jakarta EE. Who knows, it may even boost your career!

I also want to remind you of the Jakarta EE 2020 Developer Survey. If you haven’t done so already, take 8 minutes to complete the survey today.


by Ivar Grimstad at April 20, 2020 07:46 AM

Jakarta EE Meets NoSQL at the cloud age Webinar

by otaviojava at April 14, 2020 11:50 AM

Tue, 14 Apr, 2020 18:00 CEST / 09:00 AM PDT Let’s be honest: the amount of data collected by applications nowadays is growing at a scary pace. Many of them need to handle billions of users generating and consuming data at an incredible speed. Maybe you are wondering how to create an application like this? […]

by otaviojava at April 14, 2020 11:50 AM

Jakarta EE Community Update April 2020

by Tanja Obradovic at April 13, 2020 02:33 PM

We hope this update finds everyone healthy and safe in these uncertain times. Despite the challenges we’re all facing during the COVID-19 pandemic, there’s still quite a bit going on in the Jakarta EE community that I’d like to tell you about.

 The 2020 Jakarta EE Developer Survey Is Open April 6-30

Please take a few minutes (less than 10!) to add your voice to the 2020 Jakarta EE Developer Survey.

This year, we’re asking you to tell us more about your next steps for Java and cloud native development as well as your choices for architectures, technologies, and tools as cloud native resources for Java mature.

With this updated information, everyone in the Java ecosystem will have a better understanding of how the cloud native world for enterprise Java is unfolding and what that means for their strategies and businesses. And the Jakarta EE community will have a better understanding of developers’ top priorities for future Jakarta EE releases.

We encourage everyone in the Jakarta EE community to complete the survey!

_________________________________

 JakartaOne Livestearm CN4J Is On May 12 - Save the Date

We welcome everyone to join the JakartaOne Livestream Cloud Native for Java (CN4J) virtual conference on May 12 from 9:00-17:00 EDT.

This virtual event is a mix of expert talks, demos, and thought-provoking sessions focused on enterprise applications implemented using Jakarta EE and Eclipse MicroProfile specifications on Kubernetes.

_________________________________

 April Is Jakarta EE Elections Month - nomination period is extended!

Throughout the month of April, we’ll be running elections for Jakarta EE committees. Please see our list of current committee members  and consider running. Self-nominations are welcomed!

Nomination Period:  March 30 - April 24, 2020

Nominations may be sent to elections@eclipse.org, with the subject line of "Jakarta EE Working Group Elections".

Election Period:  May 1 -  May 15, 2020

Winning Candidates Announced:  May 21, 2020  

Jakarta EE Working Group Committees are looking for nominations for the following

Steering Committee

One seat for Participant Members

One seat for Committer Members

Specification Committee

One seat for Participant Members

One seat for Committer Members

Marketing and Brand Committee

One seat for Participant Members

One seat for Committer Members

If any questions please get in touch with me and/or send an email to workinggroups@eclipse-foundation.org.

_________________________________

Virtual Meetings for Java User Groups and a New Spec Adopter

Now that our Java User Groups (JUGs) can’t meet in person, we’ve created a space where they can meet virtually using Crowdcast. Access is free and we’ll promote your sessions through our channels.

 All of the information you need to access the Crowdcast subscription and book a time slot is posted here. Start with the instructions in the file Crowdcast for JUGS.pdf.

 For a look at upcoming virtual events, visit the Jakarta EE for JUGs Crowdcast page.

 I’m also very pleased to tell you the Pernambuco JUG is the most recent JUG to adopt a Jakarta EE specification. Welcome!

 Let’s keep the momentum going. For more information, about the adopt-a-spec program and instructions to sign up, click here.  

_________________________________

The Primeton AppServer v7 Is Now Jakarta EE-Compatible

Our list of products that provide full platform compatibility with Jakarta EE 8 continues to grow and now includes the Primeton AppServer v7.

 For a list of all full platform and web profile compatible products, visit the Jakarta EE Compatible Products page.

 _________________________________

 Join Jakarta EE Mailing Lists to Stay Informed

We now have all of the Jakarta EE mailing lists in one place, so it’s easy to find the ones you’re most interested in.

 With more than 25 Jakarta EE mailing lists to choose from, you can stay up to date on the latest developer discussions on a wide range of Jakarta EE topics — from bean validation to web sockets.

 Check out the full list and subscribe to discussions here.

 _________________________________

 Our Jakarta Developer Advocate Goes Online in Studio Jakarta EE

Ivar Grimstad, the Jakarta EE developer advocate at the Eclipse Foundation, is posting helpful and informative online content for the Jakarta EE community on the Studio Jakarta EE Youtube channel.

 Visit the site and subscribe today to hear the latest from Ivar.

 _________________________________

 We’re Making Progress on Jakarta EE 9

You can check the progress we’re making on Jakarta EE 9 here. We’re attempting to get a release candidate out this week for Platform and Web Profile APIs! Join the community update call for more information.

 For additional insight into Jakarta EE 9, check out the:

·      Jakarta EE Platform specification page

·      GitHub page

_________________________________

 Jakartification of Oracle Specs: We Always Welcome Your Help!

Thanks to everyone who has been helping us Jakartify the Oracle specifications. We’re making progress, but we still need helping hands. Now that we have the copyright for all of the specifications that Oracle contributed, there’s a lot of work to do.

 To help you get started:

·      The Specification Committee created a document that explains how to convert Java EE specifications to Jakarta EE.

·      Ivar Grimstad provided a demo during the community call in October. You can view it here.

_________________________________

Eclipse MicroProfile Will Have its Own Working Group

After many months of debate, Eclipse MicroProfile is set to create its own Working Group independent of Jakarta EE and is developing the Eclipse MicroProfile Working Group Charter.

A parallel discussion on technical alignment between Jakarta EE and Eclipse MicroProfile is ongoing. While the MicroProfile community made a decision in terms of the alignment (pull model), the Jakarta EE community has not yet made its decision.

 Please make sure you’re subscribed to the Jakarta community mailing list to provide your input.

_________________________________

 Join Community Update Calls

Every month, the Jakarta EE community holds a community call for everyone in the Jakarta EE community. For upcoming dates and connection details, see the Jakarta EE Community Calendar.

 This month’s call is on April 8 at 11:00 a.m. DST using this meeting link.

 We know it’s not always possible to join calls in real time, so here are links to the recordings and presentations:

·      The complete playlist.

·      March 18 call and presentation, featuring Kevin Sutter’s update on the Jakarta EE 9 plan and progress, as well as updates on Jakarta EE events, new compatible implementations, new working group members, and programs for JUGs from Shabnam Mayel, Tanja Obradovic, and Ivar Grimstad.

 _________________________________

 Upcoming Events

With the impact of COVID-19 on events and conferences, we’re focusing on virtual events.

 ·      In early May, we’ll be participating in the IBM Think Digital Event Experience. Eclipse Foundation Executive Director, Mike Milinkovich, is participating in a panel discussion, Ivar Grimstad is leading a session, and Paul Buck and Emily Jiang are involved in a master class.

·      In late April, we’ll be attending the Red Hat Summit 2020 Virtual Experience.

 _________________________________

 Stay Connected With the Jakarta EE Community

The Jakarta EE community is very active and there are a number of channels to help you stay up to date with all of the latest and greatest news and information. Tanja Obradovic’s blog summarizes the community engagement plan, which includes:

·  Social media: Twitter, Facebook, LinkedIn Group

·  Mailing lists: jakarta.ee-community@eclipse.org  and jakarta.ee-wg@eclipse.org

·  Newsletters, blogs, and emails: Eclipse newsletter, Jakarta EE blogs, monthly update emails to jakarta.ee-community@eclipse.org

·  Meetings: Jakarta Tech Talks, Jakarta EE Update, Jakarta Town Hall, and Eclipse Foundation events and conferences

 Subscribe to your preferred channels today. And, get involved in the Jakarta EE Working Group to help shape the future of open source, cloud native Java.

To learn more about Jakarta EE-related plans and check the date for the next Jakarta Tech Talk, be sure to bookmark the Jakarta EE Community Calendar.

 

 


by Tanja Obradovic at April 13, 2020 02:33 PM

Hashtag Jakarta EE #15

by Ivar Grimstad at April 12, 2020 10:59 AM

Welcome to the fifteenth issue of Hashtag Jakarta EE!

The nomination period for the Jakarta EE Working group elections has been extended until April 24, 2020. The adjusted election schedule is therefore like this:

Nomination Period: March 30 – April 24, 2020
Election Period: May 1 – May 15, 2020
Winning Candidates Announced: May 21, 2020

The elections were covered in the April Jakarta EE Community Call, where we also talked about how to contribute to Jakarta EE 9.

…and, please remember to take the Jakarta EE Developer Survey if you haven’t done so already.


by Ivar Grimstad at April 12, 2020 10:59 AM

Jakarta EE 2020 Developer Survey

by Ivar Grimstad at April 09, 2020 11:55 AM

It’s finally here! The annual Jakarta EE 2020 Developer Survey is out. Make sure to use this opportunity to make your voice heard!

This is the third Jakarta EE Developer Survey. The survey last year had more than 1,700 responses from individuals around the World. Let’s beat that number this year! It provides valuable insight into the state of the community to better understand the top priorities for future Jakarta EE releases.

The survey takes less than 10 minutes to complete, so don’t hesitate! Take the Jakarta EE 2020 Survey now!


by Ivar Grimstad at April 09, 2020 11:55 AM

2020 Jakarta EE Developer Survey Available

by Will Lyons at April 07, 2020 02:44 PM

The 2020 Jakarta EE Developer Survey, sponsored by the Jakarta EE Working Group is now available.  The survey will be open until April 30, and I encourage you to participate. 

This is the third year of this survey, which is intended to help the Java developer community better enable the understand trends, requirements and priorities for development of enterprise applications.  Last year we had over 1700 respondents to the survey which were reported here. This year's survey focuses heavily on trends in cloud native development, and we expect it provide helpful insights for developers, enterprises and vendors as they plan the evolution of their applications and application infrastructure.   It will certainly help the Jakarta EE community set priorities for the coming year.

So please complete the survey by April 30, and make you voice heard.   It should take less than 10 minutes to complete, may be interesting for you, and your participation will be greatly appreciated.  Thanks! 


by Will Lyons at April 07, 2020 02:44 PM

Add Your Voice to the 2020 Jakarta EE Developer Survey

by Mike Milinkovich at April 07, 2020 12:02 PM

Our third annual Jakarta EE Developer Survey is now open and I encourage everyone to take a few minutes and complete the survey before the April 30 deadline. Your input is extremely important.

With your feedback, the entire Java ecosystem will have a better understanding of the requirements, priorities, and perceptions in the global Java developer community. This understanding enables a clearer view of the Java industry landscape, the challenges Java developers are facing, and the opportunities for enterprise Java stakeholders in the cloud native era.

The Jakarta EE Developer Survey is one of the Java industry’s largest developer surveys. Since the survey’s inception, we’ve received thousands of responses from developers around the world, including 1,700 responses in 2019 — a clear indication the Java developer community recognizes the value of the survey results.

Last year, we were able to share critical insight into the state of cloud native innovation for enterprise Java development globally, including expected growth rates for Java apps in the cloud as well as leading architectures, applications, and technologies. We were also able to share the community’s top priorities for Jakarta EE.

This year, we’re asking developers to tell us more about their next steps for Java and cloud native development and their choices for architectures, technologies, and tools as cloud native resources for Java mature.

With this updated information, platform vendors, enterprises, and individual developers in the Java ecosystem will have a better understanding of how the cloud native world for enterprise Java is unfolding and what that means for their strategies and businesses. And the Jakarta EE community at the Eclipse Foundation will have a better understanding of the community’s top priorities for future Jakarta EE releases.

The Jakarta EE Developer Survey is your opportunity to add your voice to the global Java ecosystem and we’re counting on our entire community to help us gain the broadest possible view of the state of cloud native technologies in the context of enterprise Java. Best of all, this year we’ve organized the survey so it takes less than 10 minutes to complete!

To access the survey, click here.


by Mike Milinkovich at April 07, 2020 12:02 PM

Load huge amount of data with Jakarta EE Batch

March 24, 2020 10:00 PM

Processing huge amount of data is a challenge for every enterprise system. Jakarta EE specifications provides useful approach to get it done through Jakarta Batch (JSR-352):

Batch processing is a pervasive workload pattern, expressed by a distinct application organization and execution model. It is found across virtually every industry, applied to such tasks as statement generation, bank postings, risk evaluation, credit score calculation, inventory management, portfolio optimization, and on and on. Nearly any bulk processing task from any business sector is a candidate for batch processing.
Batch processing is typified by bulk-oriented, non-interactive, background execution. Frequently long-running, it may be data or computationally intensive, execute sequentially or in parallel, and may be initiated through various invocation models, including ad hoc, scheduled, and on-demand.
Batch applications have common requirements, including logging, checkpointing, and parallelization. Batch workloads have common requirements, especially operational control, which allow for initiation of, and interaction with, batch instances; such interactions include stop and restart.

One of the typical use case is a import data from different sources and formats to internal database. Below we will design sample application to import data, for example, from json and xml files to the database and see how well structured it can be.

Using Eclipse Red Hat CodeReady Studio plugin, we can easily design our solution diagram:
import batch diagram

Jakarta Batch descriptor in this case will looks like:
META-INF/batch-jobs/hugeImport.xml:

<?xml version="1.0" encoding="UTF-8"?>
<job id="hugeImport" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/jobXML_1_0.xsd" version="1.0">
    <step id="fileSelector" next="decider">
        <batchlet ref="fileSelectorBatchlet">
            <properties>
                <property name="path" value="/tmp/files2import"/>
            </properties>
        </batchlet>
    </step>
    <decision id="decider" ref="myDecider">
        <next on="xml" to="xmlParser"/>
        <next on="json" to="jsonParser"/>
    </decision>
    <step id="xmlParser" next="chunkProcessor">
        <batchlet ref="xmlParserBatchlet"/>
    </step>
    <step id="jsonParser" next="chunkProcessor">
        <batchlet ref="jsonParserBatchlet"/>
    </step>
    <step id="chunkProcessor">
        <chunk>
            <reader ref="itemReader"/>
            <processor ref="itemMockProcessor"/>
            <writer ref="itemJpaWriter"/>
        </chunk>
        <partition>
            <plan partitions="5"></plan>
        </partition>
    </step>
</job>

So, now we need to implement each brick above and try to keep each batchlet independent as much as possible. As you can see from above our sample job consist from:

  • fileSelector - batchlet do file selection based on supported by configuration file extension
  • decider - decision maker, responsible for choosing right parser
  • xml\jsonParser - parser batchlets, responsible for file parsing to a list of items
  • chunkProcessor - items processing chunk(reader, optional processor and writer) with partitioning to boost performance

Before start with implementation, let's design useful solution to share state between steps. Unfortunately, Jakarta Batch Specification does not provide job scoped CDI beans yet (JBeret implementation does, specification doesn't). But we able to use JobContext.set\getTransientUserData() to deal with the current batch context. In our case we want to share File and Queue with items for processing:

@Named
public class ImportJobContext {
    @Inject
    private JobContext jobContext;

    private Optional<File> file = Optional.empty();
    private Queue<ImportItem> items = new ConcurrentLinkedQueue<>();

    public Optional<File> getFile() {
        return getImportJobContext().file;
    }
    public void setFile(Optional<File> file) {
        getImportJobContext().file = file;
    }
    public Queue<ImportItem> getItems() {
        return getImportJobContext().items;
    }

    private ImportJobContext getImportJobContext() {
        if (jobContext.getTransientUserData() == null) {
            jobContext.setTransientUserData(this);
        }
        return (ImportJobContext) jobContext.getTransientUserData();
    }
}

Now we can inject our custom ImportJobContext to share type-safe state between batchlets. First step is search file for processing by provided in step properties path:

@Named
public class FileSelectorBatchlet extends AbstractBatchlet {

    @Inject
    private ImportJobContext jobContext;

    @Inject
    @BatchProperty
    private String path;

    @Override
    public String process() throws Exception {
        Optional<File> file = Files.walk(Paths.get(path)).filter(Files::isRegularFile).map(Path::toFile).findAny();
        if (file.isPresent()) {
            jobContext.setFile(file);
        }
        return BatchStatus.COMPLETED.name();
    }
}

After we need to make decision about parser, for example, based on extension. Decider just returns file extension as string and then batch runtime should give control to the corresponding parser batchlet. Please, check <decision id="decider" ref="myDecider"> section in the XML batch descriptor above.

@Named
public class MyDecider implements Decider {

    @Inject
    private ImportJobContext jobContext;

    @Override
    public String decide(StepExecution[] ses) throws Exception {
        if (!jobContext.getFile().isPresent()) {
            throw new FileNotFoundException();
        }
        String name = jobContext.getFile().get().getName();
        String extension = name.substring(name.lastIndexOf(".")+1);
        return extension;
    }
}

ParserBatchlet in turn should parse file using JSON-B or JAXB depends on type and fill Queue with ImportItem objects. I would like to use ConcurrentLinkedQueue to share items between partitions, but if you need for some other behavior here, you can provide javax.batch.api.partition.PartitionMapper with your own implementation

@Named
public class JsonParserBatchlet  extends AbstractBatchlet {

    @Inject
    ImportJobContext importJobContext;

    @Override
    public String process() throws Exception {

        List<ImportItem> items = JsonbBuilder.create().fromJson(
                new FileInputStream(importJobContext.getFile().get()),
                new ArrayList<ImportItem>(){}.getClass().getGenericSuperclass());

        importJobContext.getItems().addAll(items);
        return BatchStatus.COMPLETED.name();
    }
}

ItemReader then will looks as simple as possible, just pool item from the Queue:

@Named
public class ItemReader  extends AbstractItemReader {

    @Inject
    ImportJobContext importJobContext;

    @Override
    public ImportItem readItem() throws Exception {

        return importJobContext.getItems().poll();
    }
}

And persist time...

@Named
public class ItemJpaWriter  extends AbstractItemWriter  {

    @PersistenceContext
    EntityManager entityManager;

    @Override
    public void writeItems(List<Object> list) throws Exception {
        for (Object obj : list) {
            ImportItem item = (ImportItem) obj;
            entityManager.merge(item);
        }
    }
}

Actually, this is it! Now we able to easily extend our application with new parsers, processors and writers without any existing code changes, - just describe new (update existing) flows over Jakarta Batch descriptor.
Of course, Jakarta Batch specification provides much more helpful functionality than i have covered in this post (Checkpoints, Exception Handling, Listeners, Flow Control, Failed job restarting etc.), but even it enough to see how simple, power and well structured it can be.

Note! Wildfly Application Server implements Jakarta Batch specification through the batch-jberet subsystem. By default last one configured to use only 10 threads.

<subsystem xmlns="urn:jboss:domain:batch-jberet:2.0">
    ...
    <thread-pool name="batch">
        <max-threads count="10"/>
        <keepalive-time time="30" unit="seconds"/>
    </thread-pool>
</subsystem>

So, if you are planing intensive usage of Batch runtime - feel free to increase this parameter:

/subsystem=batch-jberet/thread-pool=batch/:write-attribute(name=max-threads, value=100)

Described sample application source code available on GitHub


March 24, 2020 10:00 PM

LazyInitializationException – What it is and the best way to fix it

by Thorben Janssen at March 20, 2020 08:01 PM

The post LazyInitializationException – What it is and the best way to fix it appeared first on Thorben Janssen.

The LazyInitializationException is one of the most common exceptions when working with Hibernate. There are a few easy ways to fix it. But unfortunately, you can also find lots of bad advice online. The proclaimed fixes often replace the exception with a hidden problem that will cause trouble in production. Some of them introduce performance […]

The post LazyInitializationException – What it is and the best way to fix it appeared first on Thorben Janssen.


by Thorben Janssen at March 20, 2020 08:01 PM

Slow SQL logging with JPA and Wildfly

March 19, 2020 10:00 PM

Recently I wrote about Logging for JPA SQL queries with Wildfly. In this post I'll show you how to configure logging for slow SQL queries.

Wildfly uses Hibernate as JPA provider. So, to enable slow sql feature you just need to provide hibernate.session.events.log.LOG_QUERIES_SLOWER_THAN_MS property in your persistence.xml :

<properties>
    ...
    <property name="hibernate.session.events.log.LOG_QUERIES_SLOWER_THAN_MS" value="25"/>
    ...
</properties>    

To log slow queries to separate file, please configure logging like:

/subsystem=logging/periodic-rotating-file-handler=slow_sql_handler:add(level=INFO, file={"path"=>"slowsql.log"}, append=true, autoflush=true, suffix=.yyyy-MM-dd,formatter="%d{yyyy-MM-dd HH:mm:ss,SSS}")
/subsystem=logging/logger=org.hibernate.SQL_SLOW:add(use-parent-handlers=false,handlers=["slow_sql_handler"])

Note!
Described above functionality available since Hibernate version 5.4.5, but latest for today Wildfly 19 uses Hibernate version 5.3. Fortunately, if you can't wait to enjoy the latest version of Hibernate, you can use WildFly feature packs to create a custom server with a different version of Hibernate ORM in few simple steps:

Create provisioning configuration file (provision.xml)

<server-provisioning xmlns="urn:wildfly:server-provisioning:1.1" copy-module-artifacts="true">
    <feature-packs>
	<feature-pack
		groupId="org.hibernate"
		artifactId="hibernate-orm-jbossmodules"
		version="${hibernate-orm.version}" />
	<feature-pack
		groupId="org.wildfly"
		artifactId="wildfly-feature-pack"
		version="${wildfly.version}" />
    </feature-packs>
</server-provisioning>

Create gradle build file (build.gradle)

plugins {
  id "org.wildfly.build.provision" version '0.0.6'
}
repositories {
    mavenLocal()
    mavenCentral()
    maven {
        name 'jboss-public'
        url 'https://repository.jboss.org/nexus/content/groups/public/'
    }
}
provision {
    //Optional destination directory:
    destinationDir = file("wildfly-custom")

    //Update the JPA API:
    override( 'org.hibernate.javax.persistence:hibernate-jpa-2.1-api' ) {
        groupId = 'javax.persistence'
        artifactId = 'javax.persistence-api'
        version = '2.2'
    }
    configuration = file( 'provision.xml' )
    //Define variables which need replacing in the provisioning configuration!
    variables['wildfly.version'] = '17.0.0.Final'
    variables['hibernate-orm.version'] = '5.4.5.Final'
}

Build custom Wildfly version

gradle provision

Switch to a different Hibernate ORM slot in your persistence.xml

<properties>
    <property name="jboss.as.jpa.providerModule" value="org.hibernate:5.4"/>
</properties>

Enjoy!


March 19, 2020 10:00 PM

Jakarta EE Community Update March 2020

by Tanja Obradovic at March 11, 2020 04:47 PM

Welcome to the latest Jakarta EE update. We have a number of initiatives underway and many great opportunities to get involved with Jakarta EE, so I’ll get right to it.

The Adopt-A-Spec Program for Java User Groups Is Now Live

We encourage all Java User Groups (JUGs) to adopt a Jakarta EE spec. You’ll find the instructions to sign up, along with more information about the program, here.

We’re very pleased to tell you that the Madras JUG in India and the SouJava JUG in Brazil are the first JUGs to adopt a Jakarta EE specification.

It’s Now Even Easier to Get Involved with Jakarta EE!

We welcome you to get involved and we made it simpler for you to join! Please see below to learn more about the steps to become a contributor and a committer. 

For details about specification project committer agreements, check out Wayne Beaton’s blog post on the topic.

We welcome everyone who wants to get involved with Jakarta EE!

Great progress on Jakarta EE 9

Work on Jakarta EE 9 is now underway and you can check the progress we’re making here. Will attempt to get an RC out this week for Platform and Web Profile APIs!

For additional insight into Jakarta EE 9, check out the:

·  Jakarta EE Platform specification page

·  GitHub page

Alignment With MicroProfile Specs Is up to Us

After a recent MicroProfile Hangout discussion, it was decided that MicroProfile will produce specs and other communities, including Jakarta EE, can determine how they want to adopt them.

 You can find a summary of the discussion by John Clingan in the thread MicroProfile Working Group discussion – Push vs pull on the MicroProfile mailing list.

 If you’d like to join MicroProfile discussions, check out the calendar here.

 CN4J Day at KubeCon Amsterdam Is Postponed

With the postponement of the KubeCon + CloudNativeCon event, we’ve also postponed CN4J Day, which was originally planned for March 30. We’ll let you know when the event is rescheduled as soon as we can.

 In the meantime, you can follow updates about KubeCon rescheduling and get more information about what the postponement means for your involvement here.

Jakartification of Oracle Specs: We always welcome your help!

Thanks to everyone who has been helping us Jakartify the Oracle specifications. We’re making progress, but we still need helping hands. Now that we have the copyright for all of the specifications that Oracle contributed, there’s a lot of work to do.

To help you get started:

·  The Specification Committee created a document that explains how to convert Java EE specifications to Jakarta EE.

Ivar Grimstad provided a demo during the community call in October. You can view it here

Join Community Update Calls

Every month, the Jakarta EE community holds a community call for everyone in the Jakarta EE community. For upcoming dates and connection details, see the Jakarta EE Community Calendar.

Our next call is Wednesday, March 18 at 10:00 a.m. EST using this meeting link.

We know it’s not always possible to join calls in real time, so here are links to the recordings and presentations:

·  The complete playlist.

·  February 12 call and presentation, featuring Wayne Beaton’s update on enabling individual participation in Jakarta EE, Shabnam Mayel’s update on enabling JUG participating, and Ivar Grimstad’s update on Jakarta EE 9.

February Event Summary

February was a busy month for events:

·  FOSDEM. Eclipse Foundation Executive Director, Mike Milinkovich, presented to a full room at this unique, free event in Brussels. For more insight, read Ivar’s blog.

·  Devnexus. We hosted a Cloud Native for Java Meetup for more than 100 participants at this conference organized by the Atlanta JUG. We also had a Jakarta EE booth in the community corner of the exhibition hall. This is an awesome event for Java developers with 2,400 attendees and world-class speakers. Here’s a photo to inspire you to attend next year.

 

·  JakartaOne Livestream - Japan. The first Livestream event in Japanese was a success with 211 registered participants. You can watch the replay here.

·  ConFoo. Ivar spoke at the 18th edition of this event in Montreal, Canada. For more information, read Ivar’s blog.

Stay Connected With the Jakarta EE Community

The Jakarta EE community is very active and there are a number of channels to help you stay up to date with all of the latest and greatest news and information. Tanja Obradovic’s blog summarizes the community engagement plan, which includes:

·  Social media: Twitter, Facebook, LinkedIn Group

·  Mailing lists: jakarta.ee-community@eclipse.org and jakarta.ee-wg@eclipse.org

·  Newsletters, blogs, and emails: Eclipse newsletter, Jakarta EE blogs, monthly update emails to jakarta.ee-community@eclipse.org, and community blogs on “how are you involved with Jakarta EE”

·  Meetings: Jakarta Tech Talks, Jakarta EE Update, Jakarta Town Hall, and Eclipse Foundation events and conferences

Subscribe to your preferred channels today. And, get involved in the Jakarta EE Working Group to help shape the future of open source, cloud native Java.

Bookmark the Jakarta EE Community Calendar to learn more about Jakarta EE-related plans and check the date for the next Jakarta Tech Talk.

 


by Tanja Obradovic at March 11, 2020 04:47 PM

Firebase push notifications with Eclipse Microprofile Rest Client

March 04, 2020 10:00 PM

Nowadays Push notifications is a must have feature for any trend application. Firebase Cloud Messaging (FCM) is a free (at least in this moment) cross-platform solution for messages and notifications for Android, iOS and Web applications.

firebase, push, microprofile, rest client

To enable push notification on client side you should create Firebase project and follow the manual or examples. From the server side perspective all you need to send push notification is:

  • Server key - will be created for your firebase project
  • Instance ID token - id of specific subscribed instance (instance destination id)

Firebase provides https://fcm.googleapis.com/fcm/send endpoint and very simple HTTP API like

{
    "to": "<Instance ID token>",
    "notification": {
      "title": "THIS IS MP REST CLIENT!",
      "body": "The quick brown fox jumps over the lazy dog."
      }
}

So, let's design simple Microprofile REST client to deal with above:

@Path("/")
@RegisterRestClient(configKey = "push-api")
public interface PushClientService {

    @POST
    @Path("/fcm/send")
    @Produces("application/json")
    @ClientHeaderParam(name = "Authorization", value = "{generateAuthHeader}")
    void send(PushMessage msg);

    default String generateAuthHeader() {
        return "key=" + ConfigProvider.getConfig().getValue("firebase.server_key", String.class);
    }
}
public class PushMessage {

    public String to;
    public PushNotification notification;

    public static class PushNotification {
        public String title;
        public String body;
    }
}

and application.properties

# firebase server key
firebase.server_key=<SERVER_KEY>
# rest client
push-api/mp-rest/url=https://fcm.googleapis.com/

Actually, this is it! Now you able to @Inject PushClientService and enjoy push notifications as well.

@Inject
@RestClient
PushClientService pushService;
...
pushService.send(message);

If you would like to test how it works from client side perspective, - feel free to use Test web application to generate instance ID token and check notifications delivery.

Described sample application source code with swagger-ui endpoint and firebase.server_key available on GitHub


March 04, 2020 10:00 PM

Jersey 2.30.1 has been released

by Jan at March 01, 2020 11:21 PM

It has been a while since we have released Jersey 2.30. On the client-side, we introduced new PreInvocationInterceptor, PostInvocationInterceptor, and InvocationBuilderListener interfaces. We made the default Rx client using the AsyncInvoker (unlike the RxInvokerProvider). We worked hard to make the Apache HttpClient … Continue reading

by Jan at March 01, 2020 11:21 PM

Optimize your code for Quarkus

by Jean-François James at February 24, 2020 05:18 PM

My previous article, was about running a JakartaEE/MicroProfile application with minimum changes. My purpose was to keep the Java code as standard as possible so that it can keep running on other implementations such as OpenLiberty, Payara, KumuluzEE, TomEE. This article proposes an alternative: how to optimize your code for Quarkus? It turns out that […]

by Jean-François James at February 24, 2020 05:18 PM

Well secured and documented REST API with Eclipse Microprofile and Quarkus

February 19, 2020 10:00 PM

Eclipse Microprofile specification provides several many helpful sections about building well designed microservice-oriented applications. OpenAPI, JWT Propagation and JAX-RS - the ones of them.
microprofile, jwt, openapi, jax-rs
To see how it works on practice let's design two typical REST resources: insecured token to generate JWT and secured user, based on Quarkus Microprofile implementation.

Easiest way to bootstrap Quarkus application from scratch is generation project structure by provided starter page - code.quarkus.io. Just select build tool you like and extensions you need. In our case it is:

  • SmallRye JWT
  • SmallRye OpenAPI

I prefer gradle, - and my build.gradle looks pretty simple

group 'org.kostenko'
version '1.0.0'
plugins {
    id 'java'
    id 'io.quarkus'
}
repositories {
     mavenLocal()
     mavenCentral()
}
dependencies {
    implementation 'io.quarkus:quarkus-smallrye-jwt'
    implementation 'io.quarkus:quarkus-smallrye-openapi'
    implementation 'io.quarkus:quarkus-resteasy-jackson'    
    implementation 'io.quarkus:quarkus-resteasy'
    implementation enforcedPlatform("${quarkusPlatformGroupId}:${quarkusPlatformArtifactId}:${quarkusPlatformVersion}")
    testImplementation 'io.quarkus:quarkus-junit5'
    testImplementation 'io.rest-assured:rest-assured'
}
compileJava {
    options.compilerArgs << '-parameters'
}

Now we are ready to improve standard JAX-RS service with OpenAPI and JWT stuff:

@RequestScoped
@Path("/user")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Tags(value = @Tag(name = "user", description = "All the user methods"))
@SecurityScheme(securitySchemeName = "jwt", type = SecuritySchemeType.HTTP, scheme = "bearer", bearerFormat = "jwt")
public class UserResource {

    @Inject
    @Claim("user_name")
    Optional<JsonString> userName;

    @POST
    @PermitAll
    @Path("/token/{userName}")
    @APIResponses(value = {
        @APIResponse(responseCode = "400", description = "JWT generation error"),
        @APIResponse(responseCode = "200", description = "JWT successfuly created.", content = @Content(schema = @Schema(implementation = User.class)))})
    @Operation(summary = "Create JWT token by provided user name")
    public User getToken(@PathParam("userName") String userName) {
        User user = new User();
        user.setJwt(TokenUtils.generateJWT(userName));
        return user;    
    }

    @GET
    @RolesAllowed("user")
    @Path("/current")
    @SecurityRequirement(name = "jwt", scopes = {})
    @APIResponses(value = {
        @APIResponse(responseCode = "401", description = "Unauthorized Error"),
        @APIResponse(responseCode = "200", description = "Return user data", content = @Content(schema = @Schema(implementation = User.class)))})
    @Operation(summary = "Return user data by provided JWT token")
    public User getUser() {
        User user = new User();
        user.setName(userName.get().toString());
        return user;
    }
}

First let's take a brief review of used Open API annotations:

  • @Tags(value = @Tag(name = "user", description = "All the user methods")) - Represents a tag. Tag is a meta-information you can use to help organize your API end-points.
  • @SecurityScheme(securitySchemeName = "jwt", type = SecuritySchemeType.HTTP, scheme = "bearer", bearerFormat = "jwt") - Defines a security scheme that can be used by the operations.
  • @APIResponse(responseCode = "401", description = "Unauthorized Error") - Corresponds to the OpenAPI response model object which describes a single response from an API Operation.
  • @Operation(summary = "Return user data by provided JWT token") - Describes an operation or typically a HTTP method against a specific path.
  • @Schema(implementation = User.class) - Allows the definition of input and output data types.

To more details about Open API annotations, please refer to the MicroProfile OpenAPI Specification.

After start the application, you will able to get your Open API description in the .yaml format by the next URL http://0.0.0.0:8080/openapi or even enjoy Swagger UI as well by http://0.0.0.0:8080/swagger-ui/ :
microprofile, openapi, swagger-ui

Note By default swagger-ui available in the dev mode only. If you would like to keep swagger on production, - add next property to your application.properties

quarkus.swagger-ui.always-include=true

Second part of this post is a JWT role based access control(RBAC) for microservice endpoints. JSON Web Tokens are an open, industry standard RFC 7519 method for representing claims securely between two parties and below we will see how easy it can be integrated in your application with Eclipse Microprofile.

As JWT suggests usage of cryptography - we need to generate public\private key pair before start coding:

# Generate a private key
openssl genpkey -algorithm RSA -out private_key.pem -pkeyopt rsa_keygen_bits:2048

# Derive the public key from the private key
openssl rsa -pubout -in private_key.pem -out public_key.pem

Now we are able to generate JWT and sign data with our private key in the, for example, next way:

public static String generateJWT(String userName) throws Exception {

    Map<String, Object> claimMap = new HashMap<>();
    claimMap.put("iss", "https://kostenko.org");
    claimMap.put("sub", "jwt-rbac");
    claimMap.put("exp", currentTimeInSecs + 300)
    claimMap.put("iat", currentTimeInSecs);
    claimMap.put("auth_time", currentTimeInSecs);
    claimMap.put("jti", UUID.randomUUID().toString());
    claimMap.put("upn", "UPN");
    claimMap.put("groups", Arrays.asList("user"));
    claimMap.put("raw_token", UUID.randomUUID().toString());
    claimMap.put("user_bane", userName);

    return Jwt.claims(claimMap).jws().signatureKeyId("META-INF/private_key.pem").sign(readPrivateKey("META-INF/private_key.pem"));
}

For additional information about JWT structure, please refer https://jwt.io

Time to review our application security stuff:
@RequestScoped - It is not about security as well. But as JWT is request scoped we need this one to work correctly;
@PermitAll - Specifies that all security roles are allowed to invoke the specified method;
@RolesAllowed("user") - Specifies the list of roles permitted to access method;
@Claim("user_name") - Allows us inject provided by JWT field;

To configure JWT in your application.properties, please add

quarkus.smallrye-jwt.enabled=true
mp.jwt.verify.publickey.location=META-INF/public_key.pem
mp.jwt.verify.issuer=https://kostenko.org

# quarkus.log.console.enable=true
# quarkus.log.category."io.quarkus.smallrye.jwt".level=TRACE
# quarkus.log.category."io.undertow.request.security".level=TRACE

And actually that is it, - if you try to reach /user/current service without or with bad JWT token in the Authorization header - you will get HTTP 401 Unauthorized error.

curl example:

curl -X GET "http://localhost:8080/user/current" -H "accept: application/json" -H "Authorization: Bearer eyJraWQiOiJNRVRBLUlORi9wcml2YXRlX2tleS5wZW0iLCJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJzdWIiOiJqd3QtcmJhYyIsInVwbiI6IlVQTiIsInJhd190b2tlbiI6IjQwOWY3MzVkLTQyMmItNDI2NC1iN2UyLTc1YTk0OGFjMTg3MyIsInVzZXJfbmFtZSI6InNlcmdpaSIsImF1dGhfdGltZSI6MTU4MjE5NzM5OSwiaXNzIjoiaHR0cHM6Ly9rb3N0ZW5rby5vcmciLCJncm91cHMiOlsidXNlciJdLCJleHAiOjkyMjMzNzIwMzY4NTQ3NzU4MDcsImlhdCI6MTU4MjE5NzM5OSwianRpIjoiMzNlMGMwZjItMmU0Yi00YTczLWJkNDItNDAzNWQ4NTYzODdlIn0.QteseKKwnYJWyj8ccbI1FuHBgWOk98PJuN0LU1vnYO69SYiuPF0d9VFbBada46N_kXIgzw7btIc4zvHKXVXL5Uh3IO2v1lnw0I_2Seov1hXnzvB89SAcFr61XCtE-w4hYWAOaWlkdTAmpMSUt9wHtjc0MwvI_qSBD3ol_VEoPv5l3_W2NJ2YBnqkY8w68c8txL1TnoJOMtJWB-Rpzy0XrtiO7HltFAz-Gm3spMlB3FEjnmj8-LvMmoZ3CKIybKO0U-bajWLPZ6JMJYtp3HdlpsiXNmv5QdIq1yY7uOPIKDNnPohWCgOhFVW-bVv9m-LErc_s45bIB9djwe13jFTbNg"

Source code of described sample application available on GitHub


February 19, 2020 10:00 PM

Back to the top

Submit your event

If you have a community event you would like listed on our events page, please fill out and submit the Event Request form.

Submit Event