1
  • I know how to find version of JDK I am using. I can issue java -version in command line and it will print me the version.

  • I know how to find version of Eclipse I am using. I can go to
    Eclipse menu > Help > About Eclipse and it will show me the version
    of Eclipse.

  • I know what version of JUnit I am using. I can open my pom.xml file of my root project and look for <junit.version> stanza.

  • I also know what WAS Liberty server I am using. I can go to Eclipse Servers, right click on my server, Properties, Product Info and it tels me I use version 21.0.0.4 of WebSphere Application Server.

However, it is unclear to me how do I find what version of JavaEE and/or JakartaEE is my application using.

How do I find version of JavaEE or JakartaEE Platform my app is using? I am using Maven and I dont see anything like "javaee" or "jakartaee" in my pom.xml files.

pixel
  • 9,653
  • 16
  • 82
  • 149
  • 3
    It depends on the server you are using. All EE servers will already have all the EE libraries. Different versions of that server will have different versions of EE. It should be stated in their (server's) documentation. – Paul Samsotha Jul 05 '21 at 22:02
  • Thank you. I just updated that information in my question. I use WAS Liberty 21.0.0.4. But I still dont see what version of JackartaEE it is using? – pixel Jul 05 '21 at 22:16
  • 1
    Please. It's "Jakarta" not "Jackarta". As to supported JEE version of your server, just check its docs as stated by Paul: https://openliberty.io/docs/21.0.0.4/reference/feature/javaee-8.0.html – BalusC Jul 06 '21 at 09:57
  • 1
    also usually when developing a javaee application with maven you will have a dependency on the javaee-api with scope provided thats corresponding to the application servers javaee version which you are developing for – meaningqo Jul 20 '21 at 06:53
  • @meaningqo Could you elaborate as an answer and I'll accept it please. And if you could provide bit more details, that would be appreciated. Thanks – pixel Jul 20 '21 at 15:48
  • added some more context to the answer. hope this clarifies my comment a bit – meaningqo Jul 20 '21 at 17:40

1 Answers1

2

Usually, if you are developing a JavaEE/JakartEE application using maven or gradle you will have the dependency on the javaEE/jakartaEE dependency in your gradle configuration or your maven pom.xml file.

As I have more experience using maven I will elaborate using a maven example. So basically you will have a dependency looking like this:

        <dependency>
            <groupId>javax</groupId>
            <artifactId>javaee-api</artifactId>
            <version>7.0</version>
            <scope>provided</scope>
        </dependency>

Using maven you will need this, so it knows that it needs the dependency in order to resolve java-ee features. For example @Inject Annotations, as well as CDI annotations and capabilities.

However, as the application server you are developing for, already has those jars packed with it, you dont want the default (=compile) scope used for this dependency as this would make your application unneccesarily large and might lead to issues with different classloaders.

Another option that I have seen in various projects is to, instead of adding a dependency to javaee directly is to import the bom (bill of materials) of your application with scope "import" and type "pom" in the dependencyManagement section of your own pom. Usually, this bill of materials has specified the javaee version it supports in there. This makes it easy to use required dependencies in your dependency section and omitting the version in order for your version to be in sync with your application server.

So for example, if you are developing for jboss, your dependency can look like this:

    <dependencyManagement>
       <dependencies>
           <dependency>
               <groupId>org.wildfly.bom</groupId>
               <artifactId>wildfly-javaee8</artifactId>
               <version>17.0.1.Final</version>
               <type>pom</type>
               <scope>import</scope>
           </dependency>
        </dependencies>
     </dependencyManagement> 

A closer look at the dependencies defined in the imported bom will then tell you the provided dependencies of your application server.

Further information on bill-of-materials can be found here

meaningqo
  • 1,653
  • 10
  • 16
  • Thanks @meaningqo, that is great explanation. I am using jakarta.jakartaee-api instead of javaee.api. I see the answer in this stack overflow (https://stackoverflow.com/questions/52502189/java-11-package-javax-xml-bind-does-not-exist) explains how to add dependencies to resolve issue with javax.xml.bind when using jdk 11. Should these 2 dependencies (jakarta.xml.bind-api and jaxb-impl) also have scope "provided" like you suggested for javaee.api? I use Liberty server 20x. Thanks – pixel Jul 23 '21 at 16:25
  • 1
    I havent worked with liberty myself yet, but the jars your application server provides are actually in your server. so search for the dependency, e.g. "jaxb-impl" inside your servers directory. if it's there, you can set the scope to provided. if its not there, use scope compile (or leave blank as its the default) because then you need to pack the jar with your application – meaningqo Jul 25 '21 at 05:38
  • Much, much, much appreciated ~ – pixel Jul 28 '21 at 21:23