[jboss-user] [EJB/JBoss] - Re: JBOSS 5 (rev 74649) having EJB rmote injection issues
rweed
do-not-reply at jboss.com
Wed Jun 18 22:12:40 EDT 2008
As I said, this worked in Beta4 and the approach is right out of the Manning EJB3 book.
Interface:
package ic.poc.wc;
|
| import javax.ejb.Remote;
|
| @Remote
| public interface CoverageWC {
| public int retrieveSubmission(int covSubmissionId);
| }
Implementation:
package ic.poc.wc;
|
| import javax.ejb.Stateless;
|
| @Stateless
| public class CoverageWCBean implements CoverageWC {
| public int retrieveSubmission(int covSubmissionId) {
| return 1;
| }
| }
Usage:
import java.io.IOException;
| import javax.servlet.ServletException;
| import javax.servlet.http.HttpServletRequest;
| import javax.servlet.http.HttpServletResponse;
| import javax.ejb.EJB;
| import ic.poc.wc.*;
|
| public class EJB3TestServlet extends javax.servlet.http.HttpServlet implements javax.servlet.Servlet {
| static final long serialVersionUID = 1L;
| @EJB
| private CoverageWC wc;
|
| public EJB3TestServlet() {
| super();
| }
|
| protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
| response.setContentType("text/plain");
| System.out.println(new java.util.Date()+"XXXXXXXEEEEEEEEEEEE");
| response.getOutputStream().println("Go !");
| response.getOutputStream().println(new java.util.Date()+"");
| response.getOutputStream().println(wc.retrieveSubmission(1));
| }
|
| protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
| // TODO Auto-generated method stub
| }
| }
I did find a work-around...it required two things:
1. Added 'mappedName="EJB3Test1/CoverageWCBean/remote"' to the @EJB annotation in the servlet.
2. That then created another exception which required that I set CallByValue=true in the Naming service.
Why are these required now?
tia, Rick
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4159138#4159138
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4159138
More information about the jboss-user
mailing list