[jboss-user] [EJB 3.0] - $Proxy146 cannot be cast to servlet... Access ejb bean from
int2
do-not-reply at jboss.com
Fri May 4 01:07:56 EDT 2007
Hi,
Thank you for read my post,
I'm new to ejb 3.0, there's a problem when I try to access an example session bean from servlet. Anyone please help :-)
The code of the test session bean is:
BLocal.java
| import ...;
| @Local
| public interface BLocal{
| public String Say(String s);
| }
|
BBean.java
| import ...
|
| @Stateless
| public class BBean implement BLocal{
| String Say(String s){
| return "hello " + s;
| }
| }
|
And the servlet,
| Context ctx = new InitialContext();
| BLocal b = (BLocal)ctx.lookup("BBean/local");
| out.println(b.Say(" world"));
|
For the class Blocal in servlet, I just copy it from the session bean above (remove annotation)
When I run the servlet, I get the result:
| ype Exception report
|
| message
|
| description The server encountered an internal error () that prevented it from fulfilling this request.
|
| exception
|
| java.lang.ClassCastException: $Proxy146 cannot be cast to servlet.Bean1Local
| servlet.S.processRequest(S.java:49)
| servlet.S.doGet(S.java:70)
| javax.servlet.http.HttpServlet.service(HttpServlet.java:697)
| javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
| org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
|
| note The full stack trace of the root cause is available in the Apache Tomcat/5.5.20 logs.
|
If the servlet and the session bean is inside an EAR, the servlet worked fine. But if the two project (servelet, session bean) deploy separately then I got the error above.
Anyone can help ?
Thank you a lot and regards
Lee
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4043066#4043066
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4043066
More information about the jboss-user
mailing list