• Post Reply Bookmark Topic Watch Topic
  • New Topic

CDI - Inject Statless Bean into SessionScoped  RSS feed

 
Alesandro Lang
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

Firstly I should mention that Iam quite new to JEE and my problem possibly could be quit clumsy.
I tried to Inject a StatlessBean into a SessionScoped one like this:




The presentationmodel Bean (ThemenBeanPM ) is accessible via EL in JSF2 and the the DaoBean (checked by logging in the constuctor) gets created, but the injection does fail. All Annotations are from "javax.enterprise" or "javax.inject".
(I have an empty beans.xml and Iam running Glassfish 3.1)

Thanks for your help.
 
Alesandro Lang
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Even if it sounds a bit crazy but simply restarting Glassfish made it for me.
Anyway I think that there are some gotchas so if anyone is in trouble with this topic check these things first:

  • beans.xml
    There has to be a file called beans.xml in your project. It can also be empty but the container is just checking your classes if this file exists.
  • SessionScoped or ConversationScoped -> Serializable
    The container managed beans which are in scope "session" or "conversation" have to implement serializable (see JSR-299 6.6.3). Of course every property of this class has also to implement serializable or be marked as transient.
  • no args constructor
    You have to provide a default constructor.

  •  
    Consider Paul's rocket mass heater.
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!