This week's book giveaway is in the HTML Pages with CSS and JavaScript forum.
We're giving away four copies of Testing JavaScript Applications and have Lucas da Costa on-line!
See this thread for details.
Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • 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 ...
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Classes initiaed with new MyClass() - can i use @EJB in MyClass

Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Guys

Im working on a system that has no injections. All classes instantiated using new. We want to change dao layer from jdbc commit/rollback code and use JTA
So I want to inject MyDAOClass classes have

I can only inject MyDaoClass by looking up the context. I want to use @EJB for MyDaoClass injection. Parent class (business layer class) is instantiated with new. i dont want to rewrite everything and have every class injected.Can i use a annotation like @SessionScoped for business class to get JBOSS 6 to inject dao class?

Posts: 10445
IntelliJ IDE Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Injection is supported only for "managed" instances. Using new() to instantiate doesn't allow injection to happen since the object is no longer managed by the container(s). So you will have to use the techniques specified by the Java EE spec to instantiate them (like using JNDI lookups or injection).
How do they get the deer to cross at the signs? Or to read this tiny ad?
Thread Boost feature
    Bookmark Topic Watch Topic
  • New Topic