Hello, EJB 2.0 spec says : "If an enterprise bean is deployed multiple times in the same Container, each deployment results in the creation of a distinct home. The Deployer may set different values for the enterprise bean environment entries for each home." I got really confused by reading the above lines. when I deploy my ejb for the first time HOME1 is created and it sets a environment variable envvar to 1 and I realized that I had given a wrong value for my variable so I deply my ejb again in the same container I change the DD to have a new value for my environment variable envvar as 2 HOME2 is created this time
as per the ejb-spec lines in quote above, there will be two Homes HOME1 and HOME2 HOME1 is having an incorrect value for my variable. My question is : How to avoid getting HOME1 ?
I am not sure whether I truely understand your question. But if you found that you deploy an ejb with the env var you don't want, you can simply undeploy it. In your code you refer the ejb by their bean name declared in the DD, not the class name of the bean. You deploy the same bean class twice, one named home1 and another named home2, they are consider as two different ejb in the container point of view, though they share the same class. If you lookup "home1" then you get the home interface of home1, and if you lookup home2 then you get the home interface of home2. Since home1 and home2 has no relationship in the container point of view. Therefore there is no such case that you will get a home2 home interface, when you lookup "home1". Hope this is the answer you are looking for.