javax.el - Implementation of Glassfish

Asked

Viewed 225 times

3

There is a JSR-000341(Expression Language - EL) API in version 3.0.0.

Maven dependency on the javax.el API:

<dependency>
    <groupId>javax.el</groupId>
    <artifactId>javax.el-api</artifactId>
    <version>3.0.0</version>
</dependency>

But as for the implementation I will use the glassfish one, but there are the following implementations:

Of org.glassfish (latest version):

<dependency>
    <groupId>org.glassfish</groupId>
    <artifactId>javax.el</artifactId>
    <version>3.0.0</version>
</dependency>

And org.glassfish.web (latest version):

<dependency>
    <groupId>org.glassfish.web</groupId>
    <artifactId>javax.el</artifactId>
    <version>2.2.6</version>
</dependency>

There is some difference between the implementation of org.glassfish and org.glassfish.web, disregarding the version of the two implementations?

  • I need to investigate further to give you an answer, but UEL’s website recommends the use of the artifact in org.glassfish.web.

  • On the other hand on the JSR website is being recommended to implement org.glassfish.javax.el. This has RI face that has changed over time.

  • RI? I don’t know what that means. But by kicker, you mean that the developers of the glassfish javax.el implementation have now put the implementation into the org.glassfish instead of org.glassfish.web?

  • RI = Implementation of Reference (of the specification). And yes, that was it. I elaborated the subject and tried to explain each nuncia in the answer. If you have any questions let me know.

1 answer

2


For typical web applications

Use the available implementation on the application server.

If you are developing a web application to be published on Glassfish (or any other application server), you nay needs an EL implementation, only the API (in scope provided). Glassfish itself will provide the implementation:

<dependency>
    <groupId>javax.el</groupId>
    <artifactId>javax.el-api</artifactId>
    <version>3.0.0</version>
    <scope>provided</scope>
</dependency>

In practice however we hardly include a dependency for this API directly, we usually work at a higher granularity level. Web applications are consumers of major Java EE Apis (including Servlets, JSP, JSF, Expression Language, etc.):

<dependency>  
   <groupId>javax</groupId>    
    <artifactId>javaee-web-api</artifactId> <!-- Ou javaee-api se realmente precisar -->   
    <version>7.0</version>  
    <scope>provided</scope>
</dependency> 

Don’t forget the APIS either endorsed, that is, updates to JDK necessary for the container (especially relevant to JAXB, JAX-WS, etc.):

<properties>
    <endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
</properties>

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.1</version>
            <configuration>
                <compilerArguments>
                    <endorseddirs>${endorsed.dir}</endorseddirs>
                </compilerArguments>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <version>2.6</version>
            <executions>
                <execution>
                    <phase>validate</phase>
                    <goals>
                        <goal>copy</goal>
                    </goals>
                    <configuration>
                        <outputDirectory>${endorsed.dir}</outputDirectory>
                        <silent>true</silent>
                        <artifactItems>
                            <artifactItem>
                                <groupId>javax</groupId>
                                <artifactId>javaee-endorsed-api</artifactId>
                                <version>7.0</version>
                                <type>jar</type>
                            </artifactItem>
                        </artifactItems>
                    </configuration>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <version>2.3</version>
            <configuration>
                <failOnMissingWebXml>false</failOnMissingWebXml>
            </configuration>
        </plugin>
        <!-- Demais plugins -->
    </plugins>
</build>

Et voilà:

<!-- Lambda dentro de uma EL, não fica mais legal que isso --> 
<h1>Hello World! ${((x, y) -> x + y)(3, 4)}</h1>

That’s basically what the archetype webapp-javaee7 ago.


Providing the API outside the App Server

That said, your question makes sense if you need to provide an EL implementation along with your application. For example, if you are using a Embedded container and to make available the reference implementation (ROI) of Expression Language.

EL 3.0 / Java EE 7

For EL version 3.0 use the following dependency combination:

<!-- API -->
<dependency>
    <groupId>javax.el</groupId>
    <artifactId>javax.el-api</artifactId>
    <version>3.0.0</version>                
</dependency>
<!-- Implementação -->
<dependency>
    <groupId>org.glassfish</groupId>
    <artifactId>javax.el</artifactId>
    <version>3.0.0</version>
    <scope>runtime</scope>
</dependency>

EL 2.2 / Java EE 6

The Glassfish also maintains a project with versions standalone of EL 2.2.x:

<!-- API -->
<dependency>
    <groupId>javax.el</groupId>
    <artifactId>javax.el-api</artifactId>
    <version>2.2.5</version>
</dependency>
<!-- Implementação -->
<dependency>
    <groupId>org.glassfish.web</groupId>
    <artifactId>javax.el</artifactId>
    <version>2.2.5</version>
    <scope>runtime</scope>
</dependency>

At the time of Tomcat 6 / Jetty 6 this type of arrangement was common to enable EL 2.2 (here’s a tutorial). Today both of them containers (Tomcat 8 / Jetty 9.1) already available EL 3.0.


Why are there different packages? Glassfish developers have changed the convention to Maven group names and artifacts.

  • In Glassfish version 3.x artifacts related to web development were grouped into org.glassfish.web.
  • In version 4.x the artifacts were regrouped into org.glassfish (that is, you will find recent versions of the implementations in this group). Artifact names have also been rethought to match the service root package they implement.

Coincidentally the JSR 341 (EL 3.0) was the first separate specification of the Expression Language. Version 2.2 of the API was part of JSR 245 (Javaserver Pages).

  • Anthony, thank you for the interest in my question and thank you for that answer, you answered my question very clearly and still taught me some very useful things regarding the dependencies of Maven. I would like you to tell me one more thing, where in the documentation of the application servers I can see what implementations they provide, because I need to know if Tomcat 8 meets all needs during the development of java web applications.

  • A de facto application server (such as Glassfish, Jboss, Weblogic, Websphere, etc.) implements, and is commonly certified against a Java EE version. In that case he shall make available at least all technologies of the version of Java EE it implements. Tomcat on the other hand is not an application server, it is just a cotainer for Servlets and JSP; you find the implemented Apis on that page (see also the version table).

  • 1

    Hmm got it, any application server that complies with Java EE will provide some implementation of all its specifications. So all I have to worry about is using the Java EE Apis as provided on Maven during development.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.