Any idea why I get this output,

*Exam [student=null, examCode=0]*​​

​Code:

*Student.java*

import javax.annotation.PostConstruct;

public class Student {
private String name;
 @PostConstruct
public void init(){
System.out.println("Init in Student");
this.name = "John Eipe";
}
public String getName() {
return name;
}
 @Override
public String toString() {
return "Student [name=" + name + "]";
}
}


*​Exam.java​*

​import javax.annotation.PostConstruct;
import javax.inject.Inject;

public class Exam {
@Inject
private Student student;
 private int examCode;
 @PostConstruct
private void init(){
System.out.println("Init in Exam");
this.setExamCode(11);
}
public int getExamCode() {
return examCode;
}
public void setExamCode(int examCode) {
this.examCode = examCode;
}
@Override
public String toString() {
return "Exam [student=" + student + ", examCode=" + examCode + "]";
}
}

*​Servlet*

​protected void doGet(HttpServletRequest request, HttpServletResponse
response) throws ServletException, IOException {
Exam exam = new Exam();
System.out.println(exam);
}​

*WebContent/WEB-INF/​bean.xml*

​<beans xmlns="http://java.sun.com/xml/ns/javaee";
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
       xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/beans_1_0.xsd";>
</beans>​




Regards,

John Eipe

“The Roots of Violence: Wealth without work, Pleasure without conscience,
Knowledge without character, Commerce without morality, Science without
humanity, Worship without sacrifice, Politics without principles”
- Mahatma Gandhi




--
View this message in context: 
http://openejb.979440.n4.nabble.com/TomEE-and-CDI-tp4669131p4669187.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Reply via email to