QuestionCommonBusiness
public interface QuestionCommonBusiness {
void create(Question question);
void update (Question question);
void delete(Question question);
Question read(Integer id);
List<Question> all();
}
QuestionLocalBusiness
public interface QuestionLocalBusiness extends QuestionCommonBusiness {
}
QuestionManagerEJB
@Stateless
@Local(QuestionLocalBusiness.class)
public class QuestionManagerEJB implements QuestionLocalBusiness {
@PersistenceContext(unitName = "MyPU")
private EntityManager entityManager;
@Override
public void create(Question question) {
entityManager.persist(question);
}
@Override
public void update(Question question) {
entityManager.merge(question);
}
@Override
public void delete(Question question) {
entityManager.remove(question);
}
@Override
public Question read(Integer id) {
return entityManager.find(Question.class, id);
}
@Override
public List<Question> all() {
TypedQuery<Question> query = entityManager.createNamedQuery(
"allQuestions", Question.class);
return query.getResultList();
}
}
QuestionController (JSF bean) ... Я не знаю, правильно ли я это использую
@Named
@RequestScoped
public class QuestionController {
@Inject
private QuestionLocalBusiness questionManager;
private List<Question> questions;
@PostConstruct
public void initialize() {
questions = questionManager.all();
}
public List<Question> getQuestions() {
return questions;
}
}
Error
HTTP Status 500 -
type Exception report
message
descriptionThe server encountered an internal error () that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: WELD-000049 Unable to invoke [method] @PostConstruct public
com.myapp.interfaces.QuestionController.initialize () в
com.myapp.interfaces.QuestionController@29421836
root cause
org.jboss.weld.exceptions.WeldException: WELD-000049 Unable to invoke [method] @PostConstruct public
com.myapp.interfaces.QuestionController.initialize () в
com.myapp.interfaces.QuestionController@29421836
root cause
java.lang.reflect.InvocationTargetException
root cause
java.lang.IllegalStateException: Unable to convert ejbRef for ejb QuestionManagerEJB to a business object of type interface
com.myapp.application.QuestionCommonBusiness
note The full stack traces of the exception and its root causes are available in the GlassFish Server Open Source Edition 3.1.1 logs.