Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

EjB 3.0 ?  RSS feed

 
Sam Doder
Ranch Hand
Posts: 204
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok I am trying to get this test program to work

I have below 3 classes TestB , TestBRemote , TestBLocal








I have created and deployed the ejb jar with these 3 classes into glassfish3 it deployed fine.

Now I am trying to create a simple class that uses the TestB ejb class

I have tried this class



But I get these errors


Which means their is something missing or needed in my InitialContext or missing in the lookup string (note I tried . / ,..etc )
Perhaps an env has to be set.
Or another parameter before I can get a handle to the ejb object on glassfish.
But the problem is I don't currently know the parameter or the structure of it.

Any help would be great .
 
Piotr Nowicki
Ranch Hand
Posts: 611
1
IntelliJ IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1. I guess that your client class (the one when you are injecting an EJB) is supposed to live somewhere outside the container?
That would explain why it's not a managed bean and why it have the 'public static void main' method...

2. If so, how did you invoke your EJB client code - how did you execute the 'main' method?

3. If you're accessing the JNDI from the remote location you should configure it so it will know to what JNDI you want to get access to. Do you have any jndi.properties file in your classpath?

4. You have a Local and Remote business interfaces but in your client code you use the EJB class type to recover it from the JNDI. I guess that doesn't make any sense. If you're accessing the EJB remotely, you should use the remote business interface. If you're accessing it from the same container, you should use the local business interface (I guess that @LocalBean annotation was added in EJB 3.1 and was not available in EJB 3.0 but I'm not 100% sure about that).

5. If the default JNDI configuration is not working for you, you can always try accessing the full JNDI name, like: "java:global/TestB"

6. At last, if you want to access the EJB within the container, you can use the @EJB annotation to let the container the EJB lookup and injection jobs.

HTH!

Cheers!
 
Sam Doder
Ranch Hand
Posts: 204
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
to answer some of your questions

I originally selected a new ejb project then new SessionBean in eclipse
which created the TestBlocal , TestBremote , TestB classes.
Which I then added the method that I want to call to my TestB class.
I then said export as ejb jar selected the 3 classes above and then deployed it /uploaded it to glassfish3 webserver.
Then I created another project to call this bean method.

But I am unsure how to access this or if I am missing anything.

I remember back in the day having an ejbobject , ejbhome ...etc calling create method ...etc

But this is a little different since eclipse generates annotations stuff instead.. .
On the webserver admin page do I need to create a jndi name or something?

Do you have any jndi.properties file in your classpath

No , don't understand why we would need this.

 
Piotr Nowicki
Ranch Hand
Posts: 611
1
IntelliJ IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yeah, back in the days there were something called nowadays a component view (next to the business view and no-interface view).

It's mainly legacy right now, as there is no need to provide i.e. home interface (in fact, in EJB 3.1 you don't need to specify any interface).

If you're using Glassfish AS than did you follow this post: http://glassfish.java.net/javaee5/ejb/EJB_FAQ.html#StandaloneRemoteEJB ?

Cheers!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!