According to the EJB JNDI Naming Reference, the JNDI lookup name for a session bean has the following syntax:
ejb:<appName>/<moduleName>/<distinctName>/<beanName>!<viewClassName>?stateful
Therefore, what you want can be achieved in two ways:
- Modify the name of your deliverable files (WAR and EAR)
In order to remove the version from your WAR you could just do the following in your WAR's POM:
<build>
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<warName>${project.artifactId}</warName>
</configuration>
</plugin>
</plugins>
</build>
Regarding your EAR, in order to remove the version from it, you could place the following in your EAR's POM:
<build>
<plugins>
<plugin>
<artifactId>maven-ear-plugin</artifactId>
<configuration>
(...)
<finalName>${project.artifactId}</finalName>
(...)
</configuration>
</plugin>
</plugins>
</build>
With the configuration above, you'd have something like:
.../TestGroup-ear/TestGroup-war/...
- Make use of ejb-jar.xml and application.xml files
Create an ejb-jar.xml, with the content below, and place it under your WAR's src/main/webapp/WEB-INF folder:
<ejb-jar xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/ejb-jar_3_2.xsd"
version="3.2">
<module-name>someModuleName</module-name>
</ejb-jar>
Afterwards, place an application.xml file, under your EAR's src/main/resources/META-INF folder, with the following content:
<?xml version="1.0" encoding="UTF-8"?>
<application xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/application_7.xsd"
version="7">
<application-name>someApplicationName</application-name>
</<module>
<web>
<web-uri>TestGroup-war-${project.version}.war</web-uri>
<context-root>testGroup</context-root>
</web>
</module>
</application>
Then, on your JNDI, you'll have something like:
java:global/someApplicationName/someModuleName/TestService!org.pkg.ejb.local.CRMDataServiceLocal
java:app/someModuleName/TestService!org.pkg.ejb.local.CRMDataServiceLocal
java:module/TestService!org.pkg.ejb.local.CRMDataServiceLocal
java:global/someApplicationName/someModuleName/TestService
java:app/someModuleName/TestService
java:module/TestService
UPDATE
As of version 2.5, the Maven EAR plugin has the option no-version
that can be set to the property fileNameMapping
, in order to omit the version from your artifact:
<plugin>
<artifactId>maven-ear-plugin</artifactId>
<configuration>
(...)
<fileNameMapping>no-version</fileNameMapping>
(...)
</configuration>
</plugin>