开发者

Not able to parameterize an ejb function

I can write a ejb like this...

@Stateless

public class AnotherBean {

@PersistenceContext(unitName = "VoidJPA-ejbPU")
private EntityManager em;

public void newTest() {
    System.out.println("Testing");

}
}

And call it using this from a servlet

@EJB
private AnotherBean nsb;
...
...
nsb.newTest();

But whenever i put a variable into newTest() i cannot access it

public void test(String i)

The servlet and EJB are both deployed but still the server gives the error

  WARNING: 开发者_如何转开发StandardWrapperValve[HelloEjb]: PWC1406: Servlet.service() for servlet 
  HelloEjb threw exception
  java.lang.NoSuchMethodError: enew.AnotherBean.newTest(Ljava/lang/String;)V
    at jpa.HelloEjb.processRequest(HelloEjb.java:44)
    at jpa.HelloEjb.doGet(HelloEjb.java:85)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:734)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
  .....
  ........
  ......

Any Help

Thanks

Pradyut

India


The Servlet clearly doesn't see the version of the Bean with the String parameter at runtime (you might have several versions on the classpath). This could be a packaging issue, a deployment issue. You need to tell us more about the way you package and deploy your application.


Clean and rebuild your application then deploy again. Also check the dependencies. It seems the EJB contract is not visible to the servlet.


Ya i got it...

In netbeans i had to do the following...

  1. Clean and Build the Ejb Project

  2. Deploy the Ejb Project

  3. Deploy the WebApplication(war) project (and make sure the ejb jar is in libraries which netbeans automatically does and needs no worry).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜