Originally posted by jonny jinny:
I am trying to access container managed bean from jsp using a java bean.
It gives me following error parsing of JSP File '/TestJSP.jsp' failed:
--------------------------------------------------------------------------------
/TestJSP.jsp(7): class 'examples.ejb20.basic.containerManaged.AccountJB' could not be loaded
probably occurred due to an error in /TestJSP.jsp line 7:
<jsp:useBean id="account" scope="request" class="examples.ejb20.basic.containerManaged.AccountJB" /> There is a big difference between JavaBeans and Enterprise JavaBeans(EJBs).
The useBean tag is meant to be used with JavaBeans, not EJBs. There is a
alot more that goes into using an EJB... acquiring an initial context, looking up the home interface, getting an EJBObject, invoking the business method, etc.
If you really want to use the useBean tag to access your EJB, then you will need to wrap it with a standard JavaBean. Some tools, such as WSAD, provide this functionality for you. Overall, abstracting the details of EJB access from the client is a good thing.
Take a look at the
Business Delegate Pattern.
Since we are on the subject, it is also not advisable to directly access Entity Beans from the client.
Take a look at the
Session Facade Pattern.
[ March 27, 2003: Message edited by: Chris Mathews ]