• Post Reply Bookmark Topic Watch Topic
  • New Topic

newbie error  RSS feed

 
Goran Markovic
Ranch Hand
Posts: 399
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi.
I'm trying to deploy simple ear application using JBoss app. server. and I get the following error :


Considering that this is my first test, I believe that it's some trivial error, but I cannot consider what is it.
This is servlet.



This is session bean interface :



and this is Session Stateless bean :


So, I figure out that my session bean is never instantiate, right? What did I wrong?Thanks in advance
 
Goran Markovic
Ranch Hand
Posts: 399
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I also try to use Stateful bean, and the thing is the same.
If I try JNDI (something like this )
i get

As much As I find in 'JBoss in action' the bean is by default bound under its name.
So why both these approaches doesn't work?
 
Goran Markovic
Ranch Hand
Posts: 399
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does anyone have an idea of my mistake nature ? ? ? Why it do not inject an EJB into my variable in servlet??
 
Goran Markovic
Ranch Hand
Posts: 399
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi. I still didn't resolve my problem. I forget to mentioned I am using Jboss 5 app. server.
Is my question so stupid and my mistake so obvious, that everyone loath on it or what? If so I would appreciate a little help to pint me at. Thanks
 
Frank Eichfelder
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you already searched the JNDI-tree of your JBoss whether your bean was bound to the JNDI-tree?
And did you see any strange log messages when deploying your application to the server?
 
Goran Markovic
Ranch Hand
Posts: 399
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
well that is a problem.JBoss DID bind EJB under specified name. Every time when I try to use DI I got NullPointerException?! Even if it display the same jndi name it had bound to.
The ONLY way I retrieved an EJB in the servlet was using JNDI lookup, but ONLY yhis way :


Every attempt using java:comp/env, or any other binding I have read from Ejb in Action like


had resulted with an exception that bean isn't bound!
Why I get a NullPointerException, when I perform DI in servlet that is a question???
 
Goran Markovic
Ranch Hand
Posts: 399
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nope... In Jboss server, injection of statless session bean using @EJB DI isn't possible...
 
Abraham Gimeno
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

First of all you should use the annotation @Local in your bean interface unless the bean's client is running in another JVM.

If you still want to use a remote call you should name the ejb bean implementation like this (for example)

and call them some similar like this :

the injection


and

I hope it helps
 
Goran Markovic
Ranch Hand
Posts: 399
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, it is little messy what you wrote here
but, I put my interface as. and this is injection in servlet
Into JMX Agen I saw that each ejb bean has been deplopyed

Still, I get

If I perform lookup I have describe, it is fine. I obtain EJB in my servlet, I CAN inject other beans into another beans using @EJB DI. But I,just as I said, I continuously receive when I try to inject bean into servlet....
Well, I would be bewildered if there are some gremlins in my pc. no really... But it doesn't matter. I will answer on scbcd that it CAN be injected, even if I cannot perform such a thing
 
Abraham Gimeno
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should establish the bean's name too



really I don't remember if it will use the mappedName at all, but like this I got it in my code

If you still get a NullPointer, copy the static function I wrote above in your servlet and call it for initalize the bean
some like this

 
Goran Markovic
Ranch Hand
Posts: 399
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
nope, it wont.
The difference is that now I got NullPointerException, unlike previously where any attempt obtaining a bean from servlet using jndi lookup (different but my way) was result a NamingException.
Use of @EJB annotation produce each time NullPointerException.
So, doesn't matter, I'm gonna use my way to obtain a reference from servlet, but I'm just in confusion, why "book-example-of-ejb-obtaining", wont work at my pc?
Thanks anyway on your efforts!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!