1
votes

I have an EJB jar DetailsLookup.jar which needs to be shared by two consumer applications - VehicleMake.war and VehicleModel.war

I have placed the EJB jar file under <catalina_base>/lib and both the war file under <catalina_base>/webapps

When I deploy only one of the WAR files, the deployment is successful, but with 2 WAR files I get the error as below. It seems, TomEE is trying to deploy the EJB for every consumer application instead of deploying it only once

Caused by: org.apache.openejb.DuplicateDeploymentIdException: Application cannot be deployed as it contains deployment-ids which are in use: app: D:\apache-tomcat\instance1\webapps\VehicleModel
    DetailsLookup
    at org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:790)
    at org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:756)
    at org.apache.tomee.catalina.TomcatWebAppBuilder.startInternal(TomcatWebAppBuilder.java:1308)
    ... 32 more

I have also noticed that when I deploy only VehicleMake.war, the JNDI name for my EJB has the application context path also appended (which says that the EJB is deployed per project and not common)

Expected JNDI name:

global/DetailsLookup!com.my.company.details.service.DetailsLookup

Actual JNDI name:

global/VehicleMake/DetailsLookup!com.my.company.details.service.DetailsLookup

Can anyone help me to identify what the issue is with deploying EJB and if I need to change any configurations to deploy it as a common EJB instead of application specific?

1
This is why we have EAR files. Put both WARs and the EJB jar in an EAR file and then it will be shared.Steve C
Hi @SteveC, Thanks for your reply. I am migrating to 'Tomcat' from 'JBoss' and 'JBoss' supports jar deployment for EJBs. So, wanted to check if there is an option in Tomcat also for that. I know we can deploy EARs, but wanted to avoid it if there is an option for deploying EJBs as jar filesPrasann
The documentation at Deploying An Application To TomEE Or OpenEJB says that all modules (including EJB jars) should be deployed in <catalina_base>/apps/. I guess the behaviour anywhere else will be undefined, particularly regarding the computation of JNDI names.Steve C

1 Answers

0
votes

In conf/system.properties, you can change the name of deployed artifacts to avoid collisions.

Try adding this line:

openejb.deploymentId.format = {appId}/{ejbJarId}/{ejbName}