JEE6 - @ApplicationException - 未调用@Inject和@PostConstruct

我在@Inject和@PostConstruct方法中遇到问题,而在@ApplicationException annoted类中没有调用它。我在服务(= ejb)-layer中使用带有JPA,CDI和EJB的Glassfish 3.0.1,并且想要在sessionlanguage中抛出包含文本的errorMessage。 我有一个抽象的ExceptionClass
 public abstract class LocalizedException extends Exception {
        private static final long serialVersionUID = 1L;


 String localizedMessage;

 //This method should be called as @PostConstruct from the concrete classe
protected void setLocalizedMessage(LocaleHandler localeHandler, String key){
    this.setLocalizedMessage(localeHandler, key, new Object());
}

protected void setLocalizedMessage(LocaleHandler localeHandler, String key, Object... args){
    localizedMessage = ErrorMessages.getErrorMessage(key,localeHandler.getAktuelleLokale(),args);
}

 @Override
 public String getMessage() {
  return localizedMessage;
 }

 @Override
 public String getLocalizedMessage() {
  return localizedMessage;
 }}
具体课程:
 @ApplicationException
        public class ConcreteException extends LocalizedException {
        private static final long serialVersionUID = 2615388267911318734L;
 private int userId;

 public ConcreteException(int userId) {
     this.userId=userId;
 }

 public int getUserId() {
  return userId;
 }

 @PostConstruct
 @Inject  
 public void initText(LocaleHandler localeHandler){
         setLocalizedMessage(localeHandler, "msgKey");
 }
} 应注入LocaleHandler(= Sessionscoped)以提供currentLocale,该currentLocale用于从bundle中检索errormessage。 问题是,无论我尝试什么,都不会调用@PostConstruct。我甚至使用@Named注释了具体类,在具体类中使用@Inject而不是抽象,但没有任何作用。当我直接调用initText()时,我可以看到(在调试器中)没有注入LocaleHandler。 现在我问自己是否有关于异常类和CDI的限制,或者我根本找不到问题的根源! 你知道答案吗 ? 提前 托马斯     
已邀请:
问题已经解决了。 我只是将Exception用作
throw new ConcreteException()
,因为我已经习惯了。这就是问题所在。现在我将ConcreteException注入我的EJB并抛出containercreated字段。这样@Inject和@Postconstruct正在工作!     

要回复问题请先登录注册