EJB jar is included twice, once in WAR and once in EAR


(silvio.heuberger) #1

I have the following simple structure for an ear project:

.
├── ear
│   └── build.gradle
├── ejb
│   └── build.gradle
├── master
│   └── settings.gradle
└── web
    └── build.gradle

You can find the build files and everything here:

There are files in the web project that have a compile time dependency on files from the ejb project, namely the EJBs the webapp classes want to use. When I configure the project this way, the ejb.jar ends up twice in the ear and thus gives an error while deploying, because WELD finds multiple implementations of a specific class.

How do I have to configure the war project so that this does not happen?


(spencer_allain) #2

Do you mean that ejb.jar show ups directly within the ear and also within web.war?

If you want to ensure that ejb.jar is not included within web.war even though it is a compile time dependency, then you want to use the providedCompile configuration in the dependencies instead of compile.

providedCompile project(':ejb')

If you really have the ejb.jar file in the ear file twice at the top level, that’s something that I’ve not encountered before.

-Spencer