2 Replies Latest reply on Jul 17, 2008 4:04 PM by fred duarte

    Problem Call ejb3.0

    Fred Duarte Newbie

      Hello:

      I have a problem when call ejb 3.0,
      I am use jboss-4.2.2.GA

      My problem report is

      2008-07-16 11:16:27,176 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/appprueba].[ControlServlet]] Servlet.service() para servlet ControlServlet lanzó excepción
      java.lang.NoSuchMethodError: model.CalculatorLocal.foo(Ljava/lang/String;)Ljava/lang/String;
      at control.ControlServlet.doPost(ControlServlet.java:49)
      at control.ControlServlet.doGet(ControlServlet.java:31)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
      at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
      at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
      at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
      at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
      at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
      at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
      at java.lang.Thread.run(Thread.java:595)

      My ejb is

      import javax.ejb.*;

      import org.jboss.annotation.ejb.LocalBinding;
      import org.jboss.annotation.ejb.RemoteBinding;

      @Stateless
      @Local ({CalculatorLocal.class})
      @LocalBinding (jndiBinding="EJB3Trail/LocalCalculator")
      @Remote ({Calculator.class})
      @RemoteBinding (jndiBinding="EJB3Trail/RemoteCalculator")
      public class CalculatorBean implements Calculator, CalculatorLocal {


      public String foo(String param){
      return "hola"+param;
      }
      }

      My interface ejb local is


      import javax.ejb.Local;

      @Local
      public interface CalculatorLocal {

      String foo(String param);
      }

      My Servlet invoque ejb 3.0 is

      import java.io.IOException;
      import java.io.PrintWriter;

      import javax.naming.InitialContext;

      import javax.servlet.*;
      import javax.servlet.http.*;

      import model.CalculatorLocal;

      public class ControlServlet extends HttpServlet {
      private static final String CONTENT_TYPE = "text/html; charset=windows-1252";

      public void doPost(HttpServletRequest request,
      HttpServletResponse response) throws ServletException, IOException {response.setContentType(CONTENT_TYPE);
      CalculatorLocal cal = null;
      try {
      InitialContext ctx = new InitialContext();
      cal = (CalculatorLocal) ctx.lookup("EJB3Trail/LocalCalculator");
      } catch (Exception e) {
      e.printStackTrace ();
      }

      //Problem al invoque method
      String msj = cal.foo("fred"); //The problem is here


      PrintWriter out = response.getWriter();
      out.println("");
      out.println("ControlServlet");
      out.println("");
      out.println(""+msj+"");
      out.println("");
      out.close();
      }
      }