Adam Bien's Weblog

Thursday Nov 20, 2014

Free Article: "Structuring Complex JavaFX 8 Applications for Productivity"

With the article "Structuring Complex JavaFX 8 Applications for Productivity" I tried to answer as many Java FX / afterburner questions, as only possible.

Particularly I focussed in the article on the combination of WYSIWYG editor, Convention over Configuration and Dependency Injection in a multi-view scenario.

Thanks for reading!, see you at airhacks.com, or if you have questions at: airhacks.tv


NEW workshop: Microservices with Java EE 7 and Java 8, January 26th, 2015, Airport Munich

A book about rethinking Java EE Patterns

Wednesday Nov 19, 2014

Java EE 7 Bootstrap Is Available ...Online

Three times a year I deliver a series of Java EE 7 / Java 8 Workshops called airhacks.com (there are some seats left for December :-)). I get more and more requests to deliver the standard set workshops in other locations, but I'm a Singleton and Singletons do not scale.

Now the Java EE 7 Bootstrap course is available online. From annotations over DI, Bean Validation, CDI, EJB to UI. 22 modules are waiting for you.

My personal goal was to keep the course as short as only possible--sometimes I re-recorded the modules multiple times to shorten them. The whole course takes 3 hours of continuous coding with a few sketches. Originally I thought about 1h, so I missed the target a bit...

If you are more interested in specific topics / internal workshops, checkout Dedicated Online Workshops.

If you have questions, see you at airhacks.tv.

See you at Java EE Workshops at Munich Airport, Terminal 2!


NEW workshop: Microservices with Java EE 7 and Java 8, January 26th, 2015, Airport Munich

A book about rethinking Java EE Patterns

Saturday Nov 15, 2014

Unorthodox Enterprise Practices With Java EE 7 and Java 8 at JavaOne 2014

See you at Java EE Workshops at Munich Airport, Terminal 2, particularly at: Effective Java EE 7 or each first Monday of the month at 6 P.M. CET: http://airhacks.tv!


NEW workshop: Microservices with Java EE 7 and Java 8, January 26th, 2015, Airport Munich

A book about rethinking Java EE Patterns

Thursday Nov 13, 2014

Upcoming Free JUG / Java EE Events

  1. Belfast JUG: Europa Ballroom at 5:30pm on Monday, 17 November Java EE Patterns, Anti-Patterns & Cool New Features
  2. Munich, 2nd December, NetBeans Day, 9 AM - 6 PM From AngularJS to Java EE Backend (of course fully microservices compatible :-))
  3. Tricity JUG, 4th December, Gdansk (register) Building Reasonable Java EE 7 Apps on Java 8 called "Microservices" A follow-up of the Nano services talk in Malmö and the "Pico Services" talk at devoxx 2014
  4. Any questions left? See you at: 1st December, 6 P.M. CET: 9th Airhacks Questions & Answers, also see archive http://airhacks.tv Ask here, or comment on this post.

See you at Java EE Workshops at Munich Airport, Terminal 2 or online course: airhacks.io!


NEW workshop: Microservices with Java EE 7 and Java 8, January 26th, 2015, Airport Munich

A book about rethinking Java EE Patterns

Tuesday Nov 11, 2014

Using Jackson in TomEE As JAXB-JSON Provider

Jackson is fast JSON processor with nice default behavior, e.g. single element collections are represented as JSON arrays, and there are no wrapping elements.

Because the default is already reasonable, there is no additional configuration needed. The provider can be specified directly in the /src/main/webapp/WEB-INF/openejb-jar.xml descriptor:


<openejb-jar xmlns="http://www.openejb.org/openejb-jar/1.1" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:schemaLocation="http://www.openejb.org/openejb-jar/1.1">
    <pojo-deployment  class-name="jaxrs-application">
        <properties>
            cxf.jaxrs.providers = com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider
        </properties>
    </pojo-deployment>
</openejb-jar>

In addition the jackson dependency needs to be declared in the pom.xml:

<dependency>
	<groupId>com.fasterxml.jackson.jaxrs</groupId>
	<artifactId>jackson-jaxrs-json-provider</artifactId>
	<version>2.4.3</version>
</dependency>

A better solution would be to install jackson directly on the server (/apache-tomee-plus-1.7.1/lib), what would keep your WAR skinny.

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


NEW workshop: Microservices with Java EE 7 and Java 8, January 26th, 2015, Airport Munich

A book about rethinking Java EE Patterns

Monday Nov 10, 2014

Configuring The JSON Default Provider (jettison) in TomEE

TomEE comes with Jettison and cxf as standard JAXB and JAX-RS providers. Jettison is "chatty" and might require some tweaking.

To tweak Jettison in a WAR deployment, you will have to provide two configuration files:

The first src/main/webapp/WEB-INF/resources.xml configures the JSON provider:


<?xml version="1.0"?>
<resources>
    <Service id="jsonProvider" class-name="org.apache.cxf.jaxrs.provider.json.JSONProvider">
        dropRootElement=true
        supportUnwrapped = true
        dropCollectionWrapperElement=true
    </Service>
</resources>

In the /src/main/webapp/WEB-INF/openejb-jar.xml descriptor, you only have to refer to the earlier defined configuration:


<openejb-jar xmlns="http://www.openejb.org/openejb-jar/1.1" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:schemaLocation="http://www.openejb.org/openejb-jar/1.1">
    <pojo-deployment  class-name="jaxrs-application">
        <properties>
            cxf.jaxrs.providers = jsonProvider
        </properties>
    </pojo-deployment>
</openejb-jar>

TomEE greatly simplifies the configuration--checkout the CXF standalone example as reference / comparison.

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


NEW workshop: Microservices with Java EE 7 and Java 8, January 26th, 2015, Airport Munich

A book about rethinking Java EE Patterns

Friday Nov 07, 2014

8th Airhacks.tv Q & A Uploaded -- JSF, Scopes, Persistence and Spring vs. Java EE

Most questions so far answered under one hour: the 8th airhacks.tv.

See airhacks.tv for past episodes.

Any questions left? Then join the conversation at each first Monday of the month at 6 P.M. live, and ask questions commenting / pulling on github or write comments on this blog.

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


NEW workshop: Microservices with Java EE 7 and Java 8, January 26th, 2015, Airport Munich

A book about rethinking Java EE Patterns

Friday Oct 31, 2014

Scheduler, DataSources, Microservices, JSF and JS, Beeing Optimismtic or Questions For the 8th airhacks.tv

Lets start with some news first: airhacks Q & A got a dedicated website http://airhacks.tv with an archive of the past shows.

Now to the questions for the November (3rd November, Monday, 6 P.M. CET) edition of the http://airhacks.tv show:

  1. Question about ejb scheduler vs java ee batch processing. What are pros and cons when using batch processing over ejb scheduler ? Marek
  2. Question about multi datasource and EJB. What is the best way to deal with EJBs which need to use a specific database for caller/user? Should I use
    Interceptors? Should I use injection with request scoped? Wesley
  3. Statement: “You forgot to say one advantage of Spring over JEE. Spring you can deploy on any container.” Mauricio
  4. ‘How do you manage deployed microservices (status, healthchecks, restarting) locally and on servers?’ Tomek
  5. ’How do you use Docker (what setup) locally and on servers? Tomek
  6. Does JSF play well with JavaScript frameworks? [Edward]
  7. Why It Is Impossible To Automatically Handle javax.persistence.OptimisticLockException? “…I had even more finding on optimisticLockException. I had encounter this
    exception and my solution was pretty straight forward which was just retry and
    it works fine with my design and the data were good. The catch is, recently I added a new table which has a relationship to the row
    which was throwing the optimisticLockException. I noticed that the entry in the second table was not created because of this exception. However the record data consistency was maintained because of the retry. But I loose an important
    information in my related table. Does anyone have suggestion on what to do with this kind of scenario?…” [Anuj]
  8. can you share some updates on how to do high availability JEE apps in light of
    JEE7 and tackling session stored data Ahmed
  9. We will also cover the extensive gist comments

Do you have any additional questions? Ask now, or wait a month :-)

The best of all: you can ask the questions live, during the show using the chat: http://www.ustream.tv/channel/adambien, twitter (hashtag "#airhacks") or (the best option): using channel ##airhacks on http://freenode.net.

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 Airport, Terminal 2 or on demand and in a location very near you: airhacks.io!


NEW workshop: Microservices with Java EE 7 and Java 8, January 26th, 2015, Airport Munich

A book about rethinking Java EE Patterns

Saturday Oct 25, 2014

Enterprise Nashorn with Java 8 at JavaOne 2014

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 Airport or on demand and in a location very near you: airhacks.io!


NEW workshop: Microservices with Java EE 7 and Java 8, January 26th, 2015, Airport Munich

A book about rethinking Java EE Patterns

Friday Oct 24, 2014

JAX-RS: Returning A List Of Instances, Problem and Solution

Wrapping a list of instances with a Response:


    @GET
    public Response workshops() {
        List<Workshop> workshops = ...//a list of entities
        return Response.ok(workshops).build();
    }


Leads to a type loss carried by the Collection and the following (or similar) exception:


MessageBodyWriter not found for media type=application/json, type=class java.util.Arrays$ArrayList, 
genericType=class java.util.Arrays$ArrayList

JAX-RS comes with GenericEntity which carries the generic type. You only have to wrap the Collection with the GenericEntity to solve the problem:


import javax.ws.rs.core.GenericEntity;
//...
  @GET
    public Response workshops() {
        List<Workshop> workshops = ...//a list of entities
        GenericEntity<List<Workshop>> l
        ist = new GenericEntity<List<Workshop>>(workshops) {
        };
        return Response.ok(list).build();
    }

See you at Java EE Workshops at Munich Airport, particularly at: Effective Java EE 7!


NEW workshop: Microservices with Java EE 7 and Java 8, January 26th, 2015, Airport Munich

A book about rethinking Java EE Patterns

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