Win a copy of The Journey To Enterprise Agility this week in the Agile and Other Processes forum! And see the welcome thread for 20% off.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
  • Carey Brown
  • Tim Holloway
  • Joe Ess

CDI - Inject Statless Bean into SessionScoped  RSS feed

Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
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.

    It is sorta covered in the JavaRanch Style Guide.
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!