Phanor Coll [
https://community.jboss.org/people/pcoll] created the discussion
"Re: EJB 3.1, CDI, JSF 2 ERROR java.lang.NullPointerException"
To view the discussion, visit:
https://community.jboss.org/message/724454#724454
--------------------------------------------------------------
it worked whe using @EJB instead of @Inject thanks, now I have another newbee question..
If the programming rule is that every stateless,stafull bean has to have at least one
business interface, why doesnt this code works?
*@ManagedBean(name="message")*
public class index {
@EJB
MyBean bean;
public String getMensaje(){
return "Netbeans + JbossAS 7.1 do rock! " + bean.hola();
}
}
*@Stateless*
public class MyBean implements MybeanInterface {
public String hola(){
return "it's true!";
}
}
public interface MybeanInterface {
String hola();
}
Instead of injecting the SLSB like before I have to use JNDI, It worked like this:
*@ManagedBean(name="message")*
public class index {
public String getMensaje(){
InitialContext context;
try {
context = new InitialContext();
m = (MybeanInterface)
context.lookup("java:global/practicaejb/MyBean!practica.interfaces.MybeanInterface");
} catch (NamingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return "Netbeans + JbossAS 7.1 do rock! " + m.hola();
}
whats the difference?.. and sorry for this question, this is probably EJB 101, but like I
said before, this is a newbe question..
--------------------------------------------------------------
Reply to this message by going to Community
[
https://community.jboss.org/message/724454#724454]
Start a new discussion in EJB3 at Community
[
https://community.jboss.org/choose-container!input.jspa?contentType=1&...]