Showing posts with label Java EE. Show all posts
Showing posts with label Java EE. Show all posts

4 September 2026

Jakarta EE components overview

Jakarta EE is the successor of Java Enterprise Edition. The name change follows the transition of the governance from Oracle to the Eclipse organisation. Jakarta EE9 is simply taking over from Java EE 8 without functional changes. It changes package namespaces to jakarta.* and  removes some obsolete API's. You can find the Java EE evolution up to Java EE8 in an earlier post. From Jakarta EE9 the components are evolving.

Jakarta EE release9 1011
year2020 2022 2025
Requires Java SE81117
Activation2.02.1
Annotations2.0.0 2.1 3.0
Authentication2.0.0 3.03.1
Authorization2.0.0 2.13.0
Jakarta Batch2.0.0 2.1.0
Concurrency2.0.0 3.02.1
Connectors2.0.0 2.1.0
Contexts and Dependency Injection3.04.04.1
Data

1.0
Enterprise Beans4.0
Expression Language4.0.05.0.0 6.0
Faces3.0.0 4.04.1
Interceptors2.0 2.12.2
JSON Binding2.0.0 3.0.0
JSON Processing2.0.02.1
Mail2.0.02.1
Messaging3.0.03.1.0
(Server) Pages3.03.1.0 4.0
Persistence3.0 3.1 3.2
RESTful Web Services3.0 3.14.0
Security2.03.04.0
Servlet5.06.06.1
Standard Tag Library2.0.0 3.0.0
Transactions2.0.0
(Bean) Validation3.0
3.1
WebSocket2.0 2.12.2
XML Binding3.0 4.0X
XML Web Services3.0 4.0 X
XML Web Services (SOAP with Attachments)2.0 3.0 X

If a cell is empty in the above table, the version is the same as in the previous release.

An X means a specification is removed.

30 August 2018

Glassfish console log timestamps

By default glassfish does not add timestamps to console logging messages and that allways leaves me wondering wether I'm looking at an old message or a new one.
To add timestamps edit $GLASSFISH_INSTALL/glassfish/domains/domain1/config/logging.properties
Replace domain1 with the domain your domainin the above,  if you are not using the default domain.
change:
java.util.logging.ConsoleHandler.formatter=com.sun.enterprise.server.logging.UniformLogFormatter
to:
java.util.logging.ConsoleHandler.formatter=java.util.logging.SimpleFormatter

The default format is fine for me, but you can customize the format using:
java.util.logging.SimpleFormatter.format="your %format string"

The javadoc contains some format string examples.
Then (re)start the server.

23 August 2018

Java EE component versions overview (updated)

The table below lists the components in latest versions of the Java Enterprise Edition.
Many of the Java EE projects live on github.
After Java EE8, Java EE is moving to the EE4J project (Eclipse Enterprise For Java) aka Jakarta.

  • I put the most important changes in red.
  • Components with a [version number] between brackets are  proposed for removal in a future release.
  • An x indicates a technology is removed from the specification
    • JSR's are shown as hyperlinked numbers.
    • SE indicates that an API was moved to the standard edition 
      • eventually followed with the version number
      • Java SE version history is in a separate post 
      • These API's will be removed from Java SE again with Java 11
    • Web technologies are in a separate post
    • EJB history is in a separate post
    • I added some application servers at the bottom of the table. 
    Technologies151
    J2EE 1.4

    2003
    244
    Java EE5

    2006
    316
    Java EE6

    2009
    342
    Java EE7

    4/2013
    366
    Java EE8
    Java SE59 1.4176 5270 6336 7337 8
    EJB153 2.1220 3.0318 3.1345 3.2
    Servlet/JSP2.42.53.03.14.0
    EE Management77 1.0



    JMS 914 1.1

    343 2.0368 2.1
    JTA 9071.01.1
    1.2
    JavaMail 9191.31.41.51.6
    Connector (JCA)112 1.51.5322 1.61.7
    Java Activation Framework (JAF) 9251.01.1SE:1.1.1
    Web Services 1091.11.21.3
    1.4
    Web Services Metadata 181
    2.0SESE:2.1
    JAX-WS (SOAP) 101 JAX-RPC 1.1 224 2.0SE:2.0SE:2.2
    JAX-RS (REST)

    311 1.1
    339 2.0370 2.1
    JAXB 222
    2.0SE:2.2
    JSON-P  353 1.03741.1
    JSON-B 367
     1.0
    JAXR (UDDI Registry)1.0
    [1.0]x
    SOAP w attachments (SAAJ) 671.21.3SE
    StAX 173
    1.0SE
    JMX1.2SESE
    container authorisation (JACC) 1151.01.11.41.5
    container authentication (JASPIC) 196

    1.01.1
    Security 375



    1.0
    Common annotations 250
    1.01.11.21.3
    Java Persistence (JPA)
    1.0317 2.0338 2.12.2
    Bean Validation

    303 1.0349 1.1380 2.0
    Managed Beans

    1.0
    Interceptors
    1.01.11.2
    CDI for Java EE

    299 1.0346 1.1365 2.0
    DI for Java 330

    1.0
    Concurrency utilities 236


    1.0
    State management 350


    1.0
    Batch  352


    1.01.1
    Servers
    Sun JSAS89.1
    Glassfish23 (12/09)4 (5/13)5 (9/17)
    JBoss / WildFly457 (7/11)8 (2/14)12 (2/18)
    IBM Websphere678 (6/11)9 (10/17)
    Oracle Weblogic91012.1.1
    (12/11)
    12.2.1 (11/15)
    Apache Geronimo123 (7/12)-
    Apache Tommee+

    1.5 (9/12)7 (3/16)
    • J2EE 1.3(2001) introduced
      • Message Driven  Beans
      • Local interfaces
    • Profiles are a subset of the spec.
      • Java EE Web profile (only profile currently defined)
        • contents
          • java SE
          • web technologies, JTA, common annotations, JPA, validation, managed beans, interceptors, CDI, DI
          • EJB Lite
            • Stateless, Stateful, and Singleton session beans
              • asynchronous session beans (EJB 3.2)
            • only local EJB interfaces or no interfaces
            • interceptors
            • security
            • transactions
            • non persistent timer only (EJB 3.2)
            • No Message Driven beans and remote invocation.
          • JAX-RS (Java EE7)
        • implemented by
          • Resin 4
          • Apache TomEE 

        7 June 2018

        Java EE web technology version history (updated)


        JSR numbers are included as links.
        Servers are webcontainers.Take care, web containers do not include JSF. You have to add it yourself or use an enterprise application server. Enterprise application servers are included in the
        complete Java EE version overview.

        Java EEservletJSP     ELJSTLJSF    WebSocketMVCServer       What’s new
        2.1
        1.0

        iPlanet
        jetty 1
        ServletContext, RequestDispatcher
        1.2
        2.2
        1.1
        tomcat 3.3
        jetty 3
        war
        1.3
        53 2.3
        53 1.2
        tomcat 4.1
        jetty 4
        filters
        1.4
        154 2.4
        152 2.0
        1.0
        52 1.1
        tomcat 5.5
        jetty 5
        5
        2.5
        245 2.1
        2.1
        1.2
        127 1.2

        tomcat 6
        jetty 6
        annotations
        6
        315 3.0
        2.2
        2.2

        314 2.0

        tomcat 7
        jetty 8
        asynchronous servlets, EL method calls, more...
        7
        340 3.1
         341 3.0

        344 2.2
        356 1.0

        tomcat 8
        jetty 9.1
        HTML 5, non blocking (Listener) servlet IO
        8
        369 4.0


        372 2.3
        1.1
        371 1.0tomcat 9 HTTP/2

        19 March 2018

        Java EE becomes Jakarta EE

        With the move of Java Enterprise edition from Oracle to the Eclipse foundation, Oracle did not transfer the right to use the Java brand.
        The reference implementation will still be Glassfish, which now becomes Eclipse Glassfish.
        The standard governance will move from JCP to the Eclipse EE.next  Working Group.

        11 October 2017

        Oracle handing over java products and standards

        Oracle is reducing its Java costs and commitment. The latest platform releases (Java SE 9 and Java EE 8) were surprisingly low key.
        With the releases out of the door, Oracle is drastically reducing its teams and handing over control of related products.

        Given that the EE spec moves to an organisation whose main product is a Java IDE, Apache seems a second choice for Netbeans.

        10 May 2016

        JPA links (updated)

        Reference implementation.

        Official documentation:

        Others:
        Providers often have good JPA documentation as well. Might include extensions (and JDO stuff) though:

        Specific topics:
        Background:

          19 April 2016

          Java EE Patterns (edit)


          • Numbers on the arrows indicate a possible call sequence in a request.
          • patterns
            • Front Controller: initial point of contact for handling all related requests. The Front Controller centralizes control logic that might otherwise be duplicated, and manages the key request handling activities.
            • Transfer Object: carries multiple data elements across a tier
            • Transfer Object Assembler:  builds an application model as a composite Transfer Object. The Transfer Object Assembler aggregates multiple Transfer Objects from various business components and services, and returns it to the client. 
            • Persistent Domain Object: Rich domain object, ie. having rich behavior/bus.logic and persistent 
            • Web Service Broker: exposes and brokers one or more services using XML and web protocols.
              • The Web Service Broker can be generalised to a Protocol Broker.
            • Service Facade: encapsulates business-tier components and exposes a coarse-grained service to remote clients. Clients access a Service Façade instead of accessing business components directly. 
            • Service: Fine-grained, reusable logic in an EJB with local access only, product of decomposition
            • Data Access Object: abstracts and encapsulates all access to the persistent store. The Data Access Object manages the connection with the data source to obtain and store data. 
            • Asynchronous Resource Integrator: Invocation of a Service from a Message-Driven Bean (invoked by a messaging system via JMS)
            • Payload extractor: factor out the (reusable) type checking and error handling for a MDB message into a reusable interceptor; poison messages moved by the interceptor to a “dead letter queue” via a stateless EJB using the JMS API
            • Resource Binder: put a custom resource into JNDI using a @Singleton with @Startup and the JNDI API (Context.(re)bind()).

          18 January 2015

          Glassfish missing DataSource: Table/View XXX does not exist

          I have a little old webapp connecting to a DB using a glassfish ConnectionPool.
          This used to run fine but on a more recent glassfish (4.0) I do net get a good datasource from Glassfish, resulting in a Table/View <name> does not exist error message (the message is a general symptom for a failed DB connection, which can have many other reasons).
          The problem exists if I configure the DataSource in web.xml and also if I inject it using @Resource.
          The solution is to explicitly map the application reference to the JNDI name in WEB-INF/glassfish-web.xml:

          <resource-ref>
              <res-ref-name>jdbc/theDB</res-ref-name>
              <jndi-name>jdbc/theDB</jndi-name>
          </resource-ref>  

          If you don't, Glassfish returns a ConnectionPoolDataSource. Some people corrected this by refering in their web.xml to the ConnectionPoolDataSource, but the solution above will work both for web.xml and Resource injection.

          servlets / JSP links (updated)

          28 March 2013

          JAX-RS 2.0 preview (updated)

          Here's an overview of the most important new features in JAX-RS 2.0 (JSR339).
          The JSR is currently in public review, so this is subject to change.

          • Asynchronous REST web services
          • REST web services are based on servlets. So the new asynchronous REST support looks a lot like the new asynchronous servlet support.
            The response to an asynchronous web service can be delegated to another thread.
             The webservice needs to pass the asynchronous response, to allow it to send a response.

            @Path ("/rest2/async")
            public class NoWaiter{
              @Asynchronous
              @GET 
              public String delegate(@Suspended AsyncResponse ctx) {
                // put context on a queue
                // for job to be picked up by a thread
                bloq.add(ctx);
                // exit immediatly
              }
            }
            
            class Handler implements Runnable{
              public void run(){
                AsyncResponse ctx bloq.take();
                // return response
                ctx.resume("response");
              }
            } 
          • Client API
          • Similar to Jersey 1 client API (some names change)
            Client client = ClientFactory.newClient();
            String result = client.target(“http://reasonsto.be”)
              .request("text/plain")
              .get(String.class); 
            
            Chaining async() in the call, the client becomes asynchronous:
            Future<String> result = client.target(“http://reasonsto.be”)
              .request("text/plain")
              .async()
              .get(String.class);
            You can also pass a listener to the asynchronous client:
            Future<String> result = client.target(“http://reasonsto.be”)
              .request("text/plain")
              .async()
              .get(new Hark()); 
            
            class Hark implements InvocationCallback<String>
            {
            public void completed(String result) {…}
            public void failed(InvocationException err) {…}
            }
          • Filters and Entity Interceptors
            • Similar to Jersey 1 filters 
            • @Provider annotated 
            • set order using @Priority
            • Filters wrap around an entire HTTP request. Mostly deal with HTTP headers, URI, method...
              • interface ContainerResponsFilter (javax.ws.rs.container)
                • void filter(ContainerResponseContext ctx) throws IOException
              • interface ContainerRequestFilter
                • void filter(ContainerRequestContext ctx) throws IOException 
                • Can have an additional @PreMatching annotation to run before JAX-RS resource method is selected (default is after resource method selection)
              • Throwing an exception will veto further processing of the message
              • javax.ws.rs.client contains similar clientside filters. Just replace Container with Client in the above interfaces. 
                • not annotated, but ClientBuilder, Client, and WebTarget all implement the Configurable interface. You can add your filter using its register(yourFilter) method.
            • Entity Interceptors wrap around the HTTP body <=> java Object marshalling/unmarshalling (e.g. for supporting compression encoding)
              •  interface WriterInterceptor
                • void aroundWriteTo(WriterInterceptorContext ctx) throws IOException, WebApplicationException
              • interface ReaderInterceptor
                • Object aroundReadFrom(ReaderInterceptorContext ctx) throws IOException, WebApplicationException
              • The aroundXXX  method naming indicate that these work like servlet filters:
                1. do some stuff
                2. ctx.proceed(): delegate to the next interceptor in the chain (of there is one)
                3. do some more stuff
            • Binding
              • Global
                •  @Provider
              • Local 
                • Using DynamicFeature
                • Using @NameBinding
                  • Indicate that the usage of this resourcemethod is to be logged, using our own annotation:
                  • @LogMe
                    @GET
                    @Produces("text/html")
                    public String getXml(){ 
                      return "<html>...</html>"
                    }
                    
                  • Define the annotation
                  • @NameBinding
                    public @interface Logme{}
                    
                  • Implement the annotation
                  • @LogMe
                    public class LoggerLoggingFilter 
                      implements ContainerRequestFilter, ContainerResponseFilter {
                    // your logging code 
                    }
                    
                • Dynamic
                  1. The filter is bound using one of the above methods, but there is an extra check to see if the filter should be applied
                  2. The filter must implement the DynamicBinding interface
                  3. The filter is applied only if the isBound() method returns true 
            • JSR303 validation
            • @Produces allows server to specify a mime type preference, using the qs attribute
            • Form class can be used as a resource method argument to capture a map of query parameters (shorthand for UriInfo.getQueryParameters()).

          11 October 2012

          We run on any Java EE Server ...

          ... except JBoss, WebLogic and WebSphere.

          My colleague, Romain, found this beauty in the features supported by Magnolia CMS Community Edition:

          Feature Description CE EE Std EE Pro
          100% Java/J2EE compliance Magnolia is developed in Java and runs on any J2EE compliant application server.
          Compatibility with Tomcat All editions of Magnolia are compatible with Tomcat application server.  ✔
          Compatibility with JBoss Standard and Pro versions of Enterprise Edition are compatible with JBoss application server.
          Compatibility with Websphere, Weblogic Only the Pro version of Magnolia Enterprise Edition can be deployed on Websphere or Weblogic application server.

          7 September 2012

          EJB version history

          Year
          Java EE
          EJB
          What’s new
          1998

          1.0
          Stateful Session Beans
          Stateless Session Beans
          Entity Beans
          JNDI
          Thread safe
          JTA
          1999
          1.2
          1.1
          XML descriptors
          RMI over IIOP
          2001
          1.3
          2.0
          local beans
          2003
          1.4
          2.1
          SOAP support
          Message driven beans
          2006
          5
          3.0
          JPA replaces Entity beans
          POJOs/annotations
          2009
          6
          3.1
          CDI
          @Asynchronous
          @Singleton
          2013
          7
          3.2

          29 July 2012

          Servlet listeners

          Scope Lifecycle listeners Attribute change listeners Register
          Application ServletContextListener ServletContextAttributeListener @WebListener
          Servlet HttpServlet @PostConstruct
          @PreDestroy
          Session HttpSessionListener HttpSessionAttributeListener @WebListener
          Request ServletRequestListener ServletRequestAttributeListener @WebListener
          Asynchronous Request AsyncListener AsyncContext#addListener

          24 June 2012

          Servlet 3 (JSR 315) containers (edit)

           Servlet v3 support in different web application containers + current support state

          • Glassfish 3+ (12/2009)
          • Resin 4 (2/2010)
          • JBoss 6 (12/2010)
          • Tomcat 7 (1/2011)
          • IBM WebSphere v8 (6/2011)
          • Oracle WebLogic 12c (12/2011) 
          • Jetty 8 (milestone)

          9 May 2012

          Apache Tommee is Java EE6 web profile certified. (edit)


          Apache Tommee is not a new product, but a bundle of Tomcat and Apache Java EE projects (OpenEJB, OpenJPA,...) by the Apache OpenEJB team. The lot is certified as a Java EE 6 Web Profile server.
          Tommee is pretty lean (24Mb) and can run embedded.
          The server bundles a set of components, all Apache gear: 
          EJBOpenEJB
          CDI OpenWebBeans
          JSP/servlet Tomcat
          JSF MyFaces
          JPAOpenJPA
          JTA Geronimo Transaction
          JavaMailGeronimo JavaMail

          Version 1.0 of Tommee was released on april 30th 2012.

          25 April 2012

          Payload extractor superclass

          This post by Jonathan Wright contains an alternative strategy for Adam Bien's payload extractor. It uses a superclass instead of interceptors.

          15 September 2010

          How to get Java EE6 libraries

          If you want to download Java EE6 libraries, Oracle bundles the whole glassfish server, and more with the java EE6 SDK. Other application servers also bundle the libraries.
          That’ a whole lot of bloat if you just want to compile a little webapp. You can just put a small subset of the glassfish jars in your classpath:

          • glassfish_install_dir/glassfish/modules/javax.servlet.jar
          • glassfish_install_dir/glassfish/modules/javax.servlet.jsp.jar
          • glassfish_install_dir/glassfish/modules/javax.servlet.jsp.jstl.jar 
          • glassfish_install_dir/glassfish/modules/jstl-impl.jar
          • glassfish_install_dir/glassfish/modules/javax.ejb.jar (if using ejb)
          If you are using maven this is not so much of a problem, just add a dependency to your POM.
          <dependencies>
            <dependency>
              <groupId>javaee</groupId>
              <artifactId>javaee-api</artifactId>
              <version>6.0</version>
              <scope>provided</scope>
            </dependency>
          </dependencies>
          <repository>
             <id>java.net</id>
             <name>GlassFish Maven Repository</name>
             <url>http://download.java.net/maven/2</url>
          </repository>
          
          Use artifactId javaee-web-api if you just want the web profile.
          If you are not using maven, you can just download the jars from the maven repository:
          For Java EE5 that is:
          <dependency>
            <groupId>javaee</groupId>
            <artifactId>javaee-api</artifactId>
            <version>5</version>
            <scope>provided</scope>
          </dependency>