views:

31

answers:

3

Hi

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

+1  A: 

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.

Pascal Thivent
I m using netbeans... how can i update the web application for the bean...
Pradyut Bhattacharya
A: 

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

Nirmalya
A: 

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).

Pradyut Bhattacharya
So, basically, this was a deployment issue...
Pascal Thivent