Skip to main content

Can not deploy inherited\shared bean

2 replies [Last post]
javamonkey79
Offline
Joined: 2010-06-17

Hello,

I am finishing up a migration from GF v2 to v3 and this is (hopefully) the last issue I have. Please note, this application worked on v2 marvelously.

This is the problem I get when I try to deploy my ear:
'Session because there are 2 ejbs in the application with interface'

I am not sure, but from what I can tell, the problem stems from the fact that I have another ear already deployed that implements the same local interface.

Here is what I have deployed in ear 1:
+ lib
-- + base-dao.jar
+ test-dao.jar
+ test-webservice.war
-- + WEB-INF
-- -- + lib
-- -- -- + base-dao.jar
-- -- -- + base-webservice.jar
-- -- -- + test-dao.jar

ear 2 is pretty much the same, except wherever you see 'test' replace with 'prod' - really it is just using a different persistence.xml underneath it all.

So in the base-dao I have:
* Local interface (which is what the deployment claims I am trying to deploy more than one of)
* Abstract implementation class (does all the work, expects child classes to provide entity manager)

I think what it amounts to is this:
in ear1, test-dao
@Stateless( name = "SomeDomainSessionBeanTest", mappedName = "SomeDomainSessionBeanTest" )
public class SomeDomainSessionBeanTest extends SomeDomainSessionBeanBase implements SomeDomainSessionBeanLocal

in ear2, prod-dao
@Stateless( name = "SomeDomainSessionBeanProd", mappedName = "SomeDomainSessionBeanProd" )
public class SomeDomainSessionBeanProd extends SomeDomainSessionBeanBase implements SomeDomainSessionBeanLocal

in all instances of base-dao.jar:
@Local
public interface SomeDomainSessionBeanLocal

also in all instances of base-dao.jar:
public abstract class SomeDomainSessionBeanBase implements SomeDomainSessionBeanLocal

Is there a way to make this work in GFv3?

TIA

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
hzhang_jn
Offline
Joined: 2005-07-22

The test-dao jar contains the EJB bean class which implements the local interface. This jar is included in the WEB-INF/lib directory of the war. This means the same Bean class is packaged twice, once in the ejb jar, and once in the war file by the inclusion of the ejb jar file in the WEB-INF/lib directory.
In EE6/v3, if you package a Bean class inside war file, it makes that war a "EJB in war" case (EJB lite) and the Bean class will be processed. While as in EE5/v2, this Bean class does not make any sense in the war and is just ignored.
You should only package the EJB interfaces inside the war. Does the base-dao.jar contain the interface already, if yes, you could just remove test-dao.jar from WEB-INF/lib and it should just work.
Additionally the base-dao.jar is already in the ear lib directory which is visible to the web module, so you don't need to include it again in the WEB-INF/lib.

javamonkey79
Offline
Joined: 2010-06-17

Yup, that was it. Thanks!