I've been stuck for days trying to call a sample entity EJB from JSP. (I
believe this question has been asked before on the list, but I can't find
any responses.) Specifically, when calling context.lookup() from testdb.jsp,
I get the following error:

javax.naming.NamingException: Error instantiating web-app JNDI-context: No
location specified and no suitable instance of the type 'com.company.Caller'
found for the ejb-ref ejb/CallerBean
 at com.evermind.server.http.HttpApplication.getEnvironmentContext(JAX)
[etc.]

I know that my ejb-jar.xml file is being located correctly, because Orion
automatically creates the CMP table (note that I am using a directory
structure instead of an actual .jar file):

***ejb-jar.xml***
  <entity>
   <description>Represents a caller in the Voyager system.</description>
   <ejb-name>com.company.Caller</ejb-name>
   <home>com.company.CallerHome</home>
   <remote>com.company.Caller</remote>
   <ejb-class>com.company.CallerBean</ejb-class>
   <persistence-type>Container</persistence-type>
   <prim-key-class>com.company.CallerPK</prim-key-class>
[etc.]

I also know that my application.xml file works, for the same reason --
otherwise, the ejb-jar.xml file could not be found and the table created
automatically:

***application.xml***
 <module>
  <ejb>ejb</ejb>
[etc.]

Lastly, I know my web.xml file works, at least in part, because the servlets
defined in it work correctly. My EJB references in web.xml are as follows:

***web.xml***
 <ejb-ref>
  <ejb-ref-name>ejb/CallerBean</ejb-ref-name>
  <ejb-ref-type>Entity</ejb-ref-type>
  <home>com.company.CallerHome</home>
  <remote>com.company.Caller</remote>

Why then can't my JSP page access the Caller EJB? Here's the JSP file:

***testdb.jsp***
<%@page language="java"%>
<%@page import="java.util.Properties"%>
<%@page import="javax.ejb.*"%>
<%@page import="javax.naming.*"%>
<%@page import="javax.rmi.*"%>
<%@page import="com.company.*"%>
[cut]
Context context = new InitialContext();
Object boundObject = context.lookup("java:comp/env/ejb/CallerBean");
[etc.]

The last line gives the error at the start of this message. I've even tried
this:

final Properties properties=new Properties();
properties.setProperty(Context.INITIAL_CONTEXT_FACTORY,
"com.evermind.server.ApplicationInitialContextFactory");
properties.setProperty(Context.PROVIDER_URL,
"ormi://localhost/voyagerApplication");
Context context = new InitialContext();

That gives the same results. Has anyone called EJB from JSP? (Yes, I have
read all the Orion tutorials. Yes, I've read the J2EE specification, the
Servlet specification, Java Blueprints, O'Reilly's _Enterprise JavaBeans_,
the Wrox _Java Server Programming J2EE Edition_, and Wiley's _Mastering
Enterprise JavaBeans_.)

Thanks for any help,

Garret
[EMAIL PROTECTED]



Reply via email to