Thanks for your tips,  I finally get it work by removing the mappedName parameter from the @EJB annotation.   It's strange.  Let me make it clearer:

1, deploy a ear package contain a session bean(deployed JNDI name "CounterBeanRemote") implement a remote interface.  

The EJB:
@Stateless
public class CounterBean implements CounterRemote, CounterLocal {


2, deploy a war package that contains a servlet using @EJB(mappedName="CounterBeanRemote") to inject the EJB.

The servlet:
public class CallEJBServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
@EJB
private CounterRemote counter;

....
}


3,  I don't have any mapping in any deployment plan.  It just worked.


On Wed, Apr 15, 2009 at 10:09 PM, Fredrik Jonson <fredrik@myrealbox.com> wrote:
Shawn Jiang wrote:

>  I encounter the same problem. Here is my case.
>  1, deploy a ear package contain a session bean(deployed JNDI name
>  "CounterBeanRemote") implement a remote interface.
>
>  2, deploy a war package that contains a servlet using
>  @EJB(mappedName="CounterBeanRemote") to inject the EJB.

I'm not sure how this is applicable to remote ejb references but to
get injection to work in G I've always had to declare a ejb-local-ref
in web.xml:

 <ejb-local-ref>
   <ejb-ref-name>SomeBean</ejb-ref-name>
   <ejb-ref-type>Session</ejb-ref-type>
   <local>com.example.app.SomeBeanRemote</local>
 </ejb-local-ref>

...or something like that. Did you do that in your project?

Without the ejb-local-ref the injection wont happen, even if the bean
is declared within the same application ear.

--
Fredrik Jonson




--
Shawn