4

This is my understanding of relationship between the EJB spec and Java versions

  • EJB 2.0 was part of J2EE 1.3 platform, which was on top J2SE 1.3 or JDK 1.3.x
  • EJB 2.1 was part of J2EE 1.4 platform, which was on top of J2SE 1.4 or JDK 1.4.x

The EJB 2.1 specification requires backward compatibility for EJB 2.0, so containers supporting EJB 2.1 and running in JDK 1.4.x will be able to run EJB 2.0 beans as well.

  • EJB 3.0 is part of Java EE 5 platform, which required Java SE 5 (JDK 5) for annotations etc

The EJB 3 spec requires backward compatibility for earlier version of the specifications.

My question is this. If I upgrade the java code for the implementation of the EJB 2.0 beans to compile against a later version of Java (say Java 5), can I still keep the same version of the EJB spec or do I need to migrate this as well.

AJM
  • 30,452
  • 47
  • 147
  • 238
  • Voted up since it helped me created http://stackoverflow.com/questions/6921562/how-backwards-compatible-are-ejb-containers – Stephen Aug 03 '11 at 04:18

2 Answers2

4

You shouldn't even have to "upgrade" the Java code, since I think older code can only be incompatible at source level due to identifiers that collide with newly introduced keywords, but that's not a problem at the bytecode level.

So your old Java 1.3/EJB 2.0 EARs should still run unchanged on a Java 5/EJB 3 appserver, and you could even do bugfixes in code and compile it with -target 1.3 on a modern JDK without having to fix the colliding identifiers (of course you then also cannot use the new source-level features).

Michael Borgwardt
  • 327,225
  • 74
  • 458
  • 699
  • Thanks, does this mean I could keep using the EJB 2.0 version of the EJB spec and at the same time take advantage of some of the features of Java 5 within implementation of my beans? – AJM Mar 17 '11 at 10:45
  • @AJM: Yes, though that of course requires you to update your source completely to Java 5 (which isn't too bad, just rename identifiers that collide with new keywords). – Michael Borgwardt Mar 17 '11 at 10:59
3

This table shows several incompatibilities at the source (build-time) level between ejb 2.0, 2.1 and 3.0 versions, although binary (run-time) compatibility is supported for all releases, i.e. you can run your code on the new ejb versions without the need to recompile.

enter image description here

linuxbuild
  • 15,170
  • 5
  • 55
  • 84