Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Using @EJB with JBoss RESTEasy

 
Ad Tan
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi folks,

I was trying out JBoss RESTEasy on JBoss AS 6 (final), and surprisingly, it is easy to get my first RESTful web service up and running...

Basically with zero configuration (no web.xml), and a simple hello class, I could get it running:

Next, I attempt to inject an EJB by using the @EJB annotation. However, I receive a RuntimeException: javax.naming.NameNotFoundException : local not bound.

Using the usual lookup method got it working though.

I tested the same EJB with a servlet in the same web app, and it worked without a prob.

Anyone knows why it couldn't work with the @EJB annotation?

Thanks in advance.
 
Jaikiran Pai
Marshal
Pie
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Looks like a deployment ordering issue. Check this http://community.jboss.org/thread/160710
 
Ad Tan
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
According to the documentation, for JBoss 6 m4 and above (i'm using final). There should be no need for any configuration (ie. web.xml) for EJB and CDI to work. So why should this fail?
 
Jaikiran Pai
Marshal
Pie
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ad Tan wrote:According to the documentation, for JBoss 6 m4 and above (i'm using final). There should be no need for any configuration (ie. web.xml) for EJB and CDI to work. So why should this fail?


Because it's a bug in the implementation and adding the "depends" is a workaround.
 
Ad Tan
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hmm... after reading up on CDI... I added beans.xml to my WAR file, and everything works, even without the "Depends" workaround.

I guess we're learning a little every day!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic