Adam Bien's Weblog

Friday Sep 19, 2014

#2 NetBeans Rocks: Maven, Ant, HTML 5 Support

Disclaimer: No additional plugins or custom configuration were used in this screencast :-)


Special Events: Java 8 with Java EE 7: "More Power with Less Code", 13th October, 2014 and Java EE 7: "Testing and Code Quality", 14th October, 2014

A book about rethinking Java EE Patterns

Thursday Sep 18, 2014

TomEE PluME--Like GlassFish But With Commercial Support

TomEE 1.7.1 Plus with Mojarra and EclipseLink (PLUME) feels like GlassFish 3 (Java EE 7 is not supported yet by TomEE), but comes with commercial support.

TomEE 1.7.1 PLuME is regular TomEE plus with Mojarra and EclipseLink.

I just deployed some JAX-RS, EJB 3, CDI, JSF, JPA (EclipseLink) applications developed on GlassFish to TomEE PluME and it worked without any modifications. TomEE works well with NetBeans 8+ -- just add an existing instance as a Tomcat server and you will be able to deploy straight from NetBeans.

The great story about Java EE is: when one vendor loses its commercial interests, several others (WLP, WildFly) can easily step in. The vendor lock-in is minimal.

See you at Java EE Workshops at Munich Airport (Terminal 2) or on demand and in a location very near you: airhacks.io!


Special Events: Java 8 with Java EE 7: "More Power with Less Code", 13th October, 2014 and Java EE 7: "Testing and Code Quality", 14th October, 2014

A book about rethinking Java EE Patterns

Monday Sep 15, 2014

Unit / Integration Testing the Bean Validation (JSR-303)

First you will need to load both: the Bean Validation and EL SPIs. Hibernate Validator is the Reference Implementation (RI) for Bean Validation, and GlassFish implements the EL JSR:


	   <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-validator</artifactId>
            <version>5.1.2.Final</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.glassfish</groupId>
            <artifactId>javax.el</artifactId>
            <version>3.0.0</version>
            <scope>test</scope>
        </dependency>

Hibernate Validator requires Expression Language dependency. Without the javax.el dependency you will get the following error:


Caused by: javax.validation.ValidationException: HV000183: Unable to load 'javax.el.ExpressionFactory'. Check that you have the EL dependencies on the classpath
	at org.hibernate.validator.messageinterpolation.ResourceBundleMessageInterpolator.(ResourceBundleMessageInterpolator.java:172)
	at org.hibernate.validator.messageinterpolation.ResourceBundleMessageInterpolator.(ResourceBundleMessageInterpolator.java:118)

Now you are ready to launch your Integration Test:


import javax.validation.ConstraintViolation;
import javax.validation.Validation;
import javax.validation.Validator;
import javax.validation.ValidatorFactory;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import org.junit.Before;
import org.junit.Test;

public class ValidationTest {

    private Validator validator;

    @Before
    public void init() {

        ValidatorFactory vf = Validation.buildDefaultValidatorFactory();
        this.validator = vf.getValidator();

    }

    @Test
    public void prereqsMet() {
        Workshop validWorkshop = new Workshop(2, 2, true, 3);
        Set<ConstraintViolation<Workshop>> violations = this.validator.validate(validWorkshop);
        assertTrue(violations.isEmpty());
    }  
}

Strictly speaking it is not a unit test, rather an Integration Test. In Unit Test you would like to test the validator logic only, without any dependencies to the SPI.

See you at Java EE Workshops at MUC Airport, especially at the Java EE 7 / Java 8 Testing day!


Special Events: Java 8 with Java EE 7: "More Power with Less Code", 13th October, 2014 and Java EE 7: "Testing and Code Quality", 14th October, 2014

A book about rethinking Java EE Patterns

Saturday Sep 13, 2014

Java EE Maven Archetype (BCE / ECB) v0.0.4 - EntityManager Mocking and System Test

The 0.0.4 version of Java EE Maven Archetype comes with JPA EntityManager mocking example and dedicated JAX-RS system tests.

Execute the javaee-bce-archetype archetype from the command line and choose version v0.0.4 to create a sample Java EE project with Boundary / Control / Entity (BCE) structure, unit-, integration-, stress-, and system tested:


mvn archetype:generate -Dfilter=com.airhacks:javaee-bce-archetype

The sources of the sample project are also available directly: https://github.com/AdamBien/javaee-bce-pom.

Thanks Dirk Franssen for the pull request!

See you at Java EE / HTML 5 workshops at Airport Munich and each first Monday of the month at 6 P.M. (CET) airhacks.io


Special Events: Java 8 with Java EE 7: "More Power with Less Code", 13th October, 2014 and Java EE 7: "Testing and Code Quality", 14th October, 2014

A book about rethinking Java EE Patterns

Friday Sep 12, 2014

WildFly, Bower, Karma, RequireJS or NetBeans 8.0.1

NetBeans IDE 8.0.1 is available for download and contains:

  1. Modularity and enterprise features for JavaScript via RequireJS
  2. Support for debugging JavaScript files with Karma
  3. Node.JS and Bower modules can be installed directly within the IDE
  4. Grunt tasks available in the popup menu for web projects
  5. Built-in support for: GlassFish 4.1, Tomcat 8.0.9, WildFly, and WebLogic 12.1.3
  6. Latest PrimeFaces framework bundled in the IDE
  7. GIT and Java tools improvement

All the features above are available without any additional plugin :-)

See the entire feature list.


Special Events: Java 8 with Java EE 7: "More Power with Less Code", 13th October, 2014 and Java EE 7: "Testing and Code Quality", 14th October, 2014

A book about rethinking Java EE Patterns

Thursday Sep 11, 2014

HTML5, WebSockets and Java EE 7 -- Screencast

A simplest possible example for HTML - Java EE 7 communication using WebSockets.

See also other screencasts at: http://tv.adam-bien.com or subscribe to http://www.youtube.com/user/bienadam.

See you at Java EE Workshops at Munich's Airport, particularly at the Java EE User Interfaces or / and Java EE 7 and HTML 5 workshops!


Special Events: Java 8 with Java EE 7: "More Power with Less Code", 13th October, 2014 and Java EE 7: "Testing and Code Quality", 14th October, 2014

A book about rethinking Java EE Patterns

Wednesday Sep 10, 2014

GlassFish 4.1 Is Ready For Download

GlassFish 4.1 is available for download.

Checkout the release notes for fixes / features.

See you at Java EE Workshops at MUC Airport or on demand and in a location very near you: airhacks.io!


Special Events: Java 8 with Java EE 7: "More Power with Less Code", 13th October, 2014 and Java EE 7: "Testing and Code Quality", 14th October, 2014

A book about rethinking Java EE Patterns

Saturday Sep 06, 2014

Recordings Of The 6th Airhacks Q&A

Thanks for watching live (79 attendees), all the interactions, particularly from the IRC #airacks channel and twitter.

Any questions left? Then join the conversation at each first Monday of the month at 6 P.M. live. No registration or any other commitment required.

Also checkout: "Timisoara JUG Session: Hacking Opinionated JavaFX / Java 8 Apps" at 16th October, 5.30 P.M CET: http://www.ustream.tv/channel/adambien.

See also other screencasts at: http://tv.adam-bien.com or subscribe to http://www.youtube.com/user/bienadam.

See you at Java EE Workshops at MUC Airport or on demand and in a location very near you: airhacks.io!


Special Events: Java 8 with Java EE 7: "More Power with Less Code", 13th October, 2014 and Java EE 7: "Testing and Code Quality", 14th October, 2014

A book about rethinking Java EE Patterns

Friday Sep 05, 2014

Java 8 + Java EE 7: POJO to JsonObject Conversion

With Java 8 a java.util.List of domain objects can be easily converted into a javax.json.JsonArray using a Collector created by the Collectors utility. javax.json.JsonObject and javax.json.JsonArray have to be created with the corresponding builder, what makes a Collector implementation necessary:


 public JsonArray allAsJson() {
		
        Collector<JsonObject, ?, JsonArrayBuilder> jsonCollector
                = Collector.of(Json::createArrayBuilder, JsonArrayBuilder::add,
                        (left, right) -> {
                            left.add(right);
                            return left;
                        });
        return all().stream().map(Registrations::convert).
                collect(jsonCollector).build();

    }
	
    static JsonObject convert(Registration registration) {
        return Json.createObjectBuilder().
                add("price", registration.getTotalPrice()).
                add(CONFIRMATION_ID, registration.getId()).build();
    }


The snippet above is a part of the https://github.com/AdamBien/javaee-bce-archetype Java EE 7 / Java 8 sample project and can be easily installed using: mvn archetype:generate -Dfilter=com.airhacks:javaee-bce-archetype.

See you at Java EE Workshops at Munich Airport or on demand and in a location very near you: airhacks.io!


Special Events: Java 8 with Java EE 7: "More Power with Less Code", 13th October, 2014 and Java EE 7: "Testing and Code Quality", 14th October, 2014

A book about rethinking Java EE Patterns

Wednesday Sep 03, 2014

Building Nanoservices with Java 8 and JavaEE 7

Microservices were yesterday. Now talk about nanoservices:

Stay tuned: Picoservices are around the corner! :-)

Thanks to foocafe.org for the invitation and perfect organization!

See you at Java EE Workshops at Munich Airport or on demand and in a location very near you: airhacks.io!


Special Events: Java 8 with Java EE 7: "More Power with Less Code", 13th October, 2014 and Java EE 7: "Testing and Code Quality", 14th October, 2014

A book about rethinking Java EE Patterns

realworldpatterns.com
...the last 150 posts
...the last 10 comments
Links
License