-
2. Re: @EJB injection always injects remote object, why not loc
jainsau Jul 31, 2007 9:56 AM (in response to jainsau)sorry for less details in my earlier post.
in my case my SLSbean is annotated both @local and @remote, not the business interface. but still only the remote proxy is injected, even when i add the attribute: name="earName/beanName/local" to the @annotation.
Is this expected behavior? -
3. Re: @EJB injection always injects remote object, why not loc
jainsau Aug 1, 2007 10:24 AM (in response to jainsau)can anybody please reply to the question. i am unable to get a handle for the local proxy even when one is available , even after trying all combinations of @ejb attributes. i am stuck.
-
4. Re: @EJB injection always injects remote object, why not loc
wolfc Aug 2, 2007 4:35 AM (in response to jainsau)Post your bean code. I think the container allows an illegal construct.
You can't use the same interface both as local and remote.
So either:@Stateless @Remote(MyStatelessRemote.class) @Local(MyStatelessLocal.class) public class MyStatelessBean
or@Stateless public class MyStatelessBean implements MyStatlessLocal, MyStatelessRemote @Remote public interface MyStatelessRemote extends MyStateless @Local public interface MyStatelessLocal extends MyStateless
The proxy chosen for injection will depend on the interface used. -
5. Re: @EJB injection always injects remote object, why not loc
jainsau Aug 2, 2007 8:24 AM (in response to jainsau)Heres my code:
inteface (business interface) is unannotated:
public interface OrderService {...}
my slsb is annotated as follows:
@Stateless
@Local
@Remote
@TransactionManagement(TransactionManagementType.CONTAINER)
@TransactionAttribute(TransactionAttributeType.REQUIRED)
public class OrderServiceBean implements OrderService {...}
Now, in another SLSB (which is annotated just like above), i am accessing the above bean through injection:
public class DemographicsServiceBean implements DemographicsService{
@EJB (name = "earName/OrderServiceBean/local")
private OrderService orderService;
<!-- OR -->
@EJB
private OrderService orderService2;
.....
}
I am just testing this out, so I have a single system, and all the beans are deployed in this system. So the bean has to be available locally also. But still I get only the remote proxy. -
6. Re: @EJB injection always injects remote object, why not loc
wolfc Aug 2, 2007 9:19 AM (in response to jainsau)As I suspected. You must specify an interface when annotating a session bean with @Remote or @Local.
I've opened a bug: http://jira.jboss.com/jira/browse/EJBTHREE-1025 -
7. Re: @EJB injection always injects remote object, why not loc
jainsau Aug 2, 2007 12:36 PM (in response to jainsau)I apologize. I did not notice that in your example you are specifying the interface classes for each annotation. I just saw that the bean can be annotated with both @local and @remote, and so I thought I was doing it right.
By using two interfaces it works fine. Thanks for your time and effort.
But then to fetch a proxy we need to be aware in our code how the bean is deployed (by declaring a variable of the correct interface type).
Isnt there a way where we could be unaware of the deployment location of the EJB and depend on JBoss to intelligently return us the correct proxy?
Something like this:
@EJB
BusinessInterface interfaceVar;
where business interface could be a super interface of the local and remote interfaces. I have tried it and it doesnt work. But is there any way? -
8. Re: @EJB injection always injects remote object, why not loc
wolfc Aug 2, 2007 1:43 PM (in response to jainsau)Nope, because of the different semantics. A remote is always called by value, a local is called by reference. It would lead to strange inconsistencies.
-
9. Re: @EJB injection always injects remote object, why not loc
jainsau Aug 2, 2007 2:51 PM (in response to jainsau)Alright. Thanks.