How to inject a non-serializable class (like java.util.ResourceBundle) with Weld

后端 未结 2 783
太阳男子
太阳男子 2020-12-08 11:12

I want to create a Producer that makes it possible to inject a java.util.ResourceBundle into any class in order to get localized Strings easily. My ResourceBundle-Producer l

2条回答
  •  时光说笑
    2020-12-08 11:25

    Well, First of all ResourceBundle is not Serializable. See here. And The message is clear

    cannot produce non-serializable instances for injection into non-transient fields of passivating beans

    passivating beans ??? I Think web.PersonHome is Either a Stateful Session Bean or a @ConversationScoped bean. Am i right ??? If so you should mark your bundle property as transient

    private transient @Inject ResourceBundle bundle;
    

提交回复
热议问题