This is my first time at attempting an EJB application. I am using eclipse 3.4 with jboss plugin, jboss 5 app server, and MySql. I have wrote a simple Stateless session bean that returns a simple String. I created this in an Enterprise Application Project in eclipse. In my web module I have a servlet that calls the remote interface to get the String. Here is the code.
String text = null;
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
env.put(Context.PROVIDER_URL, "http://localhost:1099");
env.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
try{
Context ctx = new InitialContext();
Object ref = ctx.lookup("java:comp/env/CategoriesGeneration");
CategoriesGeneration cat = (CategoriesGeneration)PortableRemoteObject.narrow(ref, CategoriesGeneration.class);
text = cat.myText();
}catch(Exception e){
e.printStackTrace();
}
The problem is that this servlet will not compile. I get an error message that says "CategoriesGeneration cannot be resolved to a type" I am also adding my Web.xml file. I was under the impression that if I added my EJB to the web.xml using <ejb-ref> tags that I would be able to call it this way. Can someone tell me what I'm doing wrong?
web.xml
<servlet>
<display-name>TestServlet</display-name>
<servlet-name>TestServlet</servlet-name>
<servlet-class>com.work.TestServlet</servlet-class>
<init-param>
<param-name>CategoriesGeneration</param-name>
<param-value>catalog/CategoriesGeneration</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>TestServlet</servlet-name>
<url-pattern>/TestServlet</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<login-config>
<auth-method>BASIC</auth-method>
</login-config>
<ejb-ref>
<ejb-ref-name>CategoriesGeneration</ejb-ref-name>
<ejb-ref-type>Session</ejb-ref-type>
<home>catalog.CategoriesGeneration</home>
<remote>catalog.CategoriesGenerationRemote</remote>
<ejb-link>CategoriesGeneration</ejb-link>
</ejb-ref>
don't remember if I mentioned this, but all the code is in the same EAR file. The EJB is in the EJB module and the servlet is in the web module. if that helps. Thanks.