Last week, a client came to me with a dilemma:

“Our build artifacts contain version information to help us know which release we’re on. But this information also gets deployed with our EJBs. When we reference a Remote EJB, we have to include the version. For example:

ejb:my-app-ear-1.0.0/my-app-ejb-1.0.0//MyEJB!org.codelikethewind.EJB.RemoteEJB

We don’t want to change our code every time we build a new version, but we still want the version in the filename.”

As you remember, the EJB JNDI reference syntax looks like this: ejb:<app-name>/<module-name>/<distinct-name>/<bean-name>!<fully-qualified-classname-of-the-remote-interface> We need to remove the version from the application and module name, but leave it on the filename.

We can do this with the maven-ear plugin. In the pom.xml of your EAR, you will have something like this (before the </project> tag).