I'm studying EJB3.0+JBoss5. I encounter a jndi error. When I access a bean in jsp it says 'InjectionBean not bound'. But I developed another EJB using jnid of the same rule it worked.
below is the code:
InjectionBean:
package com.foshanshop.ejb3.impl;
import com.foshanshop.ejb3.Injection;
import com.foshanshop.ejb3.LocalHello;
import javax.ejb.EJB;
import javax.ejb.Remote;
import javax.ejb.Stateless;
@Stateless
@Remote (Injection.class)
public class InjectionBean implements Injection {
@EJB (beanName="HelloBean") LocalHello helloworld;
public String SayHello() {
return helloworld.SayHello("injector");
}
}
Injection:
package com.foshanshop.ejb3;
public interface Injection {
public String SayHello();
}
invoker, a jsp:
<%@ page contentType="text/html; charset=GBK"%>
<%@ page import="com.foshanshop.ejb3.*, javax.naming.*"%>
<%
try {
InitialContext ctx = new InitialContext();
Injection injection = (Injection) ctx.lookup("InjectionBean/remote");
out.println(injection.SayHello());
} catch (NamingException e) {
out.println(e.getMessage());
}
%>
I don't define a ejb-jar.xml, for EJB3.0 it's not a must.
anybody with any ideas? thanks.
If the forum could offer a code template it's better to look through the pasted code.
Comments